From c6736e9adbc9258cf3a8198de5474a03d971300e Mon Sep 17 00:00:00 2001 From: Nick Huanca <1903525+endzyme@users.noreply.github.com> Date: Wed, 4 Jan 2023 21:10:36 -0700 Subject: [PATCH] Adjust behavior for pod labels Pod labels from the Spec.Pod.Labels were previously not propagated to the StatefulSet.Template. This change notes the differences between the two Label locations in the ZookeeperCluster CRD and denotes priority ordering. --- api/v1beta1/zookeepercluster_types.go | 9 +++++---- .../zookeeper.pravega.io_zookeeperclusters_crd.yaml | 8 +++++--- .../bases/zookeeper.pravega.io_zookeeperclusters.yaml | 8 +++++--- pkg/zk/generators.go | 1 + 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/api/v1beta1/zookeepercluster_types.go b/api/v1beta1/zookeepercluster_types.go index 3f5da83b4..ba8bcf247 100644 --- a/api/v1beta1/zookeepercluster_types.go +++ b/api/v1beta1/zookeepercluster_types.go @@ -82,8 +82,9 @@ type ZookeeperClusterSpec struct { // Image is the container image. default is zookeeper:0.2.10 Image ContainerImage `json:"image,omitempty"` - // Labels specifies the labels to attach to pods the operator creates for - // the zookeeper cluster. + // Labels specifies the labels to attach to all resources the operator + // creates for the zookeeper cluster, including StatefulSet, Pod, + // PersistentVolumeClaim, Service, ConfigMap, et al. Labels map[string]string `json:"labels,omitempty"` // Replicas is the expected size of the zookeeper cluster. @@ -433,8 +434,8 @@ func (c *ContainerImage) ToString() string { // PodPolicy defines the common pod configuration for Pods, including when used // in deployments, stateful-sets, etc. type PodPolicy struct { - // Labels specifies the labels to attach to pods the operator creates for - // the zookeeper cluster. + // Labels specifies the labels to attach to pods the operator creates for the + // zookeeper cluster. Overrides any values specified in Spec.Labels. Labels map[string]string `json:"labels,omitempty"` // NodeSelector specifies a map of key-value pairs. For the pod to be diff --git a/charts/zookeeper-operator/templates/zookeeper.pravega.io_zookeeperclusters_crd.yaml b/charts/zookeeper-operator/templates/zookeeper.pravega.io_zookeeperclusters_crd.yaml index 03555d8d9..f7e461c28 100644 --- a/charts/zookeeper-operator/templates/zookeeper.pravega.io_zookeeperclusters_crd.yaml +++ b/charts/zookeeper-operator/templates/zookeeper.pravega.io_zookeeperclusters_crd.yaml @@ -2684,8 +2684,9 @@ spec: labels: additionalProperties: type: string - description: Labels specifies the labels to attach to pods the operator - creates for the zookeeper cluster. + description: Labels specifies the labels to attach to all resources + the operator creates for the zookeeper cluster, including StatefulSet, + Pod, PersistentVolumeClaim, Service, ConfigMap, et al. type: object maxUnavailableReplicas: description: MaxUnavailableReplicas defines the MaxUnavailable Replicas @@ -3875,7 +3876,8 @@ spec: additionalProperties: type: string description: Labels specifies the labels to attach to pods the - operator creates for the zookeeper cluster. + operator creates for the zookeeper cluster. Overrides any values + specified in Spec.Labels. type: object nodeSelector: additionalProperties: diff --git a/config/crd/bases/zookeeper.pravega.io_zookeeperclusters.yaml b/config/crd/bases/zookeeper.pravega.io_zookeeperclusters.yaml index 46f114d39..eb4c7e299 100644 --- a/config/crd/bases/zookeeper.pravega.io_zookeeperclusters.yaml +++ b/config/crd/bases/zookeeper.pravega.io_zookeeperclusters.yaml @@ -2683,8 +2683,9 @@ spec: labels: additionalProperties: type: string - description: Labels specifies the labels to attach to pods the operator - creates for the zookeeper cluster. + description: Labels specifies the labels to attach to all resources + the operator creates for the zookeeper cluster, including StatefulSet, + Pod, PersistentVolumeClaim, Service, ConfigMap, et al. type: object maxUnavailableReplicas: description: MaxUnavailableReplicas defines the MaxUnavailable Replicas @@ -3874,7 +3875,8 @@ spec: additionalProperties: type: string description: Labels specifies the labels to attach to pods the - operator creates for the zookeeper cluster. + operator creates for the zookeeper cluster. Overrides any values + specified in Spec.Labels. type: object nodeSelector: additionalProperties: diff --git a/pkg/zk/generators.go b/pkg/zk/generators.go index 25da7f9a6..21801dd63 100644 --- a/pkg/zk/generators.go +++ b/pkg/zk/generators.go @@ -91,6 +91,7 @@ func MakeStatefulSet(z *v1beta1.ZookeeperCluster) *appsv1.StatefulSet { GenerateName: z.GetName(), Labels: mergeLabels( z.Spec.Labels, + z.Spec.Pod.Labels, map[string]string{ "app": z.GetName(), "kind": "ZookeeperMember",