Skip to content
logo
Percona Operator for MySQL
Labels and annotations
Initializing search
    percona/k8sps-docs
    percona/k8sps-docs
    • Welcome
      • Design and architecture
      • Install with Helm
      • Install on Minikube
      • System Requirements
      • Install on Google Kubernetes Engine (GKE)
      • Install on Amazon Elastic Kubernetes Service (AWS EKS)
      • Generic Kubernetes installation
      • Backup and restore
      • Application and system users
      • Anti-affinity and tolerations
      • Labels and annotations
        • Setting labels and annotations in the Custom Resource
        • Specifying labels and annotations ignored by the Operator
      • Changing MySQL Options
      • Exposing the cluster
      • Transport Encryption (TLS/SSL)
      • Telemetry
      • Horizontal and vertical scaling
      • Monitor with Percona Monitoring and Management (PMM)
      • Add sidecar containers
      • Monitor Kubernetes
      • Custom Resource options
      • Percona certified images
      • Copyright and licensing information
      • Trademark policy
      • Release notes index
      • Percona Operator for MySQL 0.5.0 (2023-03-30)
      • Percona Operator for MySQL 0.4.0 (2023-01-30)
      • Percona Operator for MySQL 0.3.0 (2022-09-29)
      • Percona Operator for MySQL 0.2.0 (2022-06-30)
      • Percona Distribution for MySQL Operator based on Percona Server for MySQL 0.1.0 (2022-01-25)

    • Setting labels and annotations in the Custom Resource
    • Specifying labels and annotations ignored by the Operator

    Labels and annotations¶

    Labels and annotations are used to attach additional metadata information to Kubernetes resources.

    Labels and annotations are rather similar. The difference between them is that labels are used by Kubernetes to identify and select objects, while annotations are assigning additional non-identifying information to resources. Therefore, typical role of Annotations is facilitating integration with some external tools.

    Setting labels and annotations in the Custom Resource¶

    You can set labels and/or annotations as key/value string pairs in the Custom Resource metadata section of the deploy/cr.yaml as follows:

    apiVersion: ps.percona.com/v1alpha1
    kind: PerconaServerMySQL
    metadata:
      name: cluster1
      annotations:
        percona.com/issue-vault-token: "true"
      labels:
        ...
    

    The easiest way to check which labels are attached to a specific object with is using the additional --show-labels option of the kubectl get command. Checking the annotations is not much more difficult: it can be done as in the following example:

    $ kubectl get pod cluster1-mysql-0 -o jsonpath='{.metadata.annotations}'
    

    Specifying labels and annotations ignored by the Operator¶

    Sometimes various Kubernetes flavors can add their own annotations to the objects managed by the Operator.

    The Operator keeps track of all changes to its objects and can remove annotations that appeared without its participation.

    If there are no annotations or labels in the Custom Resource, the Operator does nothing if new label or annotation added to the object.

    If there is an annotation or a label specified in the Custom Resource, the Operator starts to manage annotations and labels. In this case it removes unknown annotations and labels.

    Still, it is possible to specify which annotations and labels should be ignored by the Operator by listing them in the spec.ignoreAnnotations or spec.ignoreLabels keys of the deploy/cr.yaml, as follows:

    spec:
      ignoreAnnotations:
        - some.custom.cloud.annotation/smth
      ignoreLabels:
        - some.custom.cloud.label/smth
    ...
    

    The Operator will ignore any annotation and label which keys starts with the mentioned above examples. For example, the following annotations and labels will be ignored after applying the above cr.yaml fragment:

    annotations:
      some.custom.cloud.annotation/smth: somethinghere
    labels:
      some.custom.cloud.label/smth: somethinghere
    

    The Operator will ignore specified annotations and labels for all objects: Pods, Services, etc.

    Contact Us

    For free technical help, visit the Percona Community Forum.

    To report bugs or submit feature requests, open a JIRA ticket.

    For paid support and managed or consulting services , contact Percona Sales.


    Last update: 2023-08-31
    Percona LLC and/or its affiliates, © 2009 - 2023
    Made with Material for MkDocs

    Cookie consent

    We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better. Read more about Percona Cookie Policy.