


#Kubernetes annotations code
Further, we must note that while we stored short and simple strings in labels, we used annotation to store an entire JSON object.įor toy projects, running code within standalone pods might be okay. Great! It looks like we’ve got this one right. $ kubectl get pods nginx-pod -oyaml | grep -A5 'annotations:' $ kubectl get pods nginx-pod -oyaml | grep -A2 'labels:'

Lastly, let’s create the pod using the manifest.yaml file, and inspect the labels and annotations in the pod: $ kubectl apply -f manifest.yaml Next, let’s define a few labels and annotations within an nginx pod’s manifest.yaml file: $ cat manifest.yaml Moreover, the annotation value can take up to 256KB, which allows us to store relatively large text. On the other hand, annotation values are much more flexible and can contain multi-line strings with non-alphanumeric characters and symbols in addition to alphanumeric characters. Besides that, they have the same restrictions, including a maximum length of 63 characters. We can notice that label values can be empty, unlike label names. Now, let’s go ahead and inspect the regular expression that Kubernetes uses to validate label values: ^(((*)?))?$
