Kubernetes Fundamentals by Himanshu Agrawal

Kubernetes Fundamentals by Himanshu Agrawal

Author:Himanshu Agrawal
Language: eng
Format: epub
ISBN: 9781484297292
Publisher: Apress


Listing 5-12 A Pod Object with Annotation

You can put the template/specification code shown in Listing 5-12 in a YAML file and execute it using the kubectl create -f <<<YAML_FILE_NAME>>> command. Once the object is created, you can use the kubectl describe pod ha-annotation-pod command to check those annotations got successfully added to the pod object, as shown in Figure 5-30.

Figure 5-30 Execution logs depicting the specified annotations got successfully attached to the pod

Using annotations, you cannot select objects in the same way as in the case of labels. But using an external JSON parsing tool like the jq tool, you can select objects based on annotations. You can use the following command and verify that the pod can be selected based on annotations, as shown in Figure 5-31: kubectl get pods --output=json | jq -r '["KIND","NAME","UID","STATUS"],(.items[]|[select(.metadata.annotations["chapter-number"]="five")|.kind,.metadata.name,.metadata.uid,.status.phase])|@tsv' | column --table --separator $' '



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.