How to add labels and annotations to all pods of a cluster? #7557
-
I'm trying write a custom addon. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 10 replies
-
It depends on which version of KubeBlocks you are working with. Prior to Release 0.8say you are working with k explain clusterdefinition.spec.componentDefs.customLabelSpecs
GROUP: apps.kubeblocks.io
KIND: ClusterDefinition
VERSION: v1alpha1
FIELD: customLabelSpecs <[]Object>
DESCRIPTION:
customLabelSpecs is used for custom label tags which you want to add to the
component resources.
FIELDS:
key <string> -required-
key name of label
resources <[]Object>
resources defines the resources to be labeled.
value <string> -required-
value of label An example could be found at: https://github.com/apecloud/kubeblocks-addons/blob/ae54e3901285f297ee0d3fcf0c4821f2fcfde8d7/addons/postgresql/templates/clusterdefinition.yaml#L19-L20 componentDefs:
- name: postgresql
workloadType: Replication
characterType: postgresql
customLabelSpecs:
- key: apps.kubeblocks.postgres.patroni/scope
value: "$(KB_CLUSTER_NAME)-$(KB_COMP_NAME)-patroni$(KB_CLUSTER_UID_POSTFIX_8)"
resources:
- gvk: "v1/Pod"
selector:
app.kubernetes.io/managed-by: kubeblocks
- gvk: "apps/v1/StatefulSet"
selector:
app.kubernetes.io/managed-by: kubeblocks Release 0.8 and aboveKubeBlocks supports k explain cmpd.spec.labels
GROUP: apps.kubeblocks.io
KIND: ComponentDefinition
VERSION: v1alpha1
FIELD: labels <map[string]string>
DESCRIPTION:
Specifies static labels that will be patched to all Kubernetes resources
created for the Component.
Note: If a label key in the `labels` field conflicts with any system labels
or user-specified labels, it will be silently ignored to avoid overriding
higher-priority labels.
This field is immutable. An example could be found in Oceanbase ComponentDefinition: labels: &oblabels
kubeblocks.io/ready-without-primary: "true" And likewise, you can customize you annotaion using k explain cmpd.spec.annotations
GROUP: apps.kubeblocks.io
KIND: ComponentDefinition
VERSION: v1alpha1
FIELD: annotations <map[string]string>
DESCRIPTION:
Specifies static annotations that will be patched to all Kubernetes
resources created for the Component.
Note: If an annotation key in the `annotations` field conflicts with any
system annotations or user-specified annotations, it will be silently
ignored to avoid overriding higher-priority annotations.
This field is immutable. |
Beta Was this translation helpful? Give feedback.
It depends on which version of KubeBlocks you are working with.
Prior to Release 0.8
say you are working with
ClusterDefinition
you can put your customized lable to
clusterdefinition.spec.componentDefs.customLabelSpecs