From 31960eb83a7c9ae4d7c6f869397d98ee157026f7 Mon Sep 17 00:00:00 2001 From: Alpha Shaw Date: Mon, 13 Jan 2025 05:22:29 +0000 Subject: [PATCH] update... --- api/v1alpha1/pulsarcluster_spec.go | 7 ++- .../pulsar.monime.sl_pulsarclusters.yaml | 48 +++++++++++++++++++ internal/controller/pulsarcluster/job.go | 5 ++ 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/api/v1alpha1/pulsarcluster_spec.go b/api/v1alpha1/pulsarcluster_spec.go index 1257c54..a13adad 100755 --- a/api/v1alpha1/pulsarcluster_spec.go +++ b/api/v1alpha1/pulsarcluster_spec.go @@ -107,8 +107,9 @@ type PulsarClusterSpec struct { // JVMOptions defines the JVM options for pulsar broker; this is useful for performance tuning. // If unspecified, a reasonable defaults will be set // +optional - JVMOptions JVMOptions `json:"jvmOptions"` - Persistence *v1.PersistentVolumeClaimSpec `json:"persistence,omitempty"` + JVMOptions JVMOptions `json:"jvmOptions"` + InitJobResources v1.ResourceRequirements `json:"resources,omitempty"` + Persistence *v1.PersistentVolumeClaimSpec `json:"persistence,omitempty"` // PodConfig defines common configuration for the broker pods // +optional PodConfig basetype.PodConfig `json:"podConfig,omitempty"` @@ -327,10 +328,8 @@ func (in *PulsarClusterSpec) createLabels(clusterName string, broker bool) map[s labels["broker"] = "true" } labels["app"] = "pulsar" - labels["version"] = in.PulsarVersion labels[k8s.LabelAppName] = "pulsar" labels[k8s.LabelAppInstance] = clusterName - labels[k8s.LabelAppVersion] = in.PulsarVersion labels[k8s.LabelAppManagedBy] = internal.OperatorName return labels } diff --git a/config/crd/bases/pulsar.monime.sl_pulsarclusters.yaml b/config/crd/bases/pulsar.monime.sl_pulsarclusters.yaml index c602b4a..3d3b06f 100644 --- a/config/crd/bases/pulsar.monime.sl_pulsarclusters.yaml +++ b/config/crd/bases/pulsar.monime.sl_pulsarclusters.yaml @@ -1807,6 +1807,54 @@ spec: pulsarVersion: description: PulsarVersion defines the version of broker to use type: string + resources: + description: ResourceRequirements describes the compute resource requirements. + properties: + claims: + description: "Claims lists the names of resources, defined in + spec.resourceClaims, that are used by this container. \n This + is an alpha field and requires enabling the DynamicResourceAllocation + feature gate. \n This field is immutable. It can only be set + for containers." + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry in pod.spec.resourceClaims + of the Pod where this field is used. It makes that resource + available inside a container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute resources + allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Requests describes the minimum amount of compute + resources required. If Requests is omitted for a container, + it defaults to Limits if that is explicitly specified, otherwise + to an implementation-defined value. Requests cannot exceed Limits. + More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + type: object size: format: int32 minimum: 0 diff --git a/internal/controller/pulsarcluster/job.go b/internal/controller/pulsarcluster/job.go index 086c3d8..3ee9098 100755 --- a/internal/controller/pulsarcluster/job.go +++ b/internal/controller/pulsarcluster/job.go @@ -99,11 +99,16 @@ func createClusterMetadataInitJob(c *v1alpha1.PulsarCluster) *v1.Job { } func createJobPodSpecContainers(c *v1alpha1.PulsarCluster) []coreV1.Container { + initJobResources := c.Spec.InitJobResources + if initJobResources.Limits == nil || initJobResources.Requests == nil { + initJobResources = c.Spec.PodConfig.Spec.Resources + } return []coreV1.Container{ { Name: "cluster-metadata-init", Image: c.Image().ToString(), ImagePullPolicy: c.Image().PullPolicy, + Resources: initJobResources, Command: k8s.ContainerShellCommand(), Args: createJobPodContainerArguments(c), EnvFrom: []coreV1.EnvFromSource{