注解也是 key-value.
- 注解可以容纳更多信息
- 主要给工具使用
- 想 Kubernetes 引入新特性会使用注解 (不稳定时)
3.6.1 查找对象的注解
查看注解:
annotations

注解不超过 256KB.
3.6.2 添加和修改注解
添加注解:
$ kubectl annotate pod hello-pod abc="def"pod/hello-pod annotated
查看注解:
$ kubectl describe pod hello-podName: hello-podNamespace: defaultPriority: 0Node: minikube/192.168.99.100Start Time: Wed, 24 Mar 2021 10:38:47 +0800Labels: creation_method=manualAnnotations: abc: def # ------------------ 这里Status: RunningIP: 172.17.0.7IPs:IP: 172.17.0.7Containers:test-study-k8s:Container ID: docker://56271eb675225daa0f7ba39dc6613a06bcf4f545c7c096ee28e02aa609d1558cImage: jdxj/study_kubernetes:v0.1.0Image ID: docker-pullable://jdxj/study_kubernetes@sha256:91be05eac3742a5cd670526017c8a8a54705ed002a137e8b7fb0f553177abaecPort: 8080/TCPHost Port: 0/TCPState: RunningStarted: Wed, 24 Mar 2021 10:39:01 +0800Ready: TrueRestart Count: 0Environment: <none>Mounts:/var/run/secrets/kubernetes.io/serviceaccount from default-token-vvp8b (ro)Conditions:Type StatusInitialized TrueReady TrueContainersReady TruePodScheduled TrueVolumes:default-token-vvp8b:Type: Secret (a volume populated by a Secret)SecretName: default-token-vvp8bOptional: falseQoS Class: BestEffortNode-Selectors: <none>Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300snode.kubernetes.io/unreachable:NoExecute op=Exists for 300sEvents: <none>
应该使用前缀来避免命名冲突:
abc/def="def"
