kubernetes

[따배쿠] Annotation

bbiyak2da 2024. 12. 10. 13:10

Annotation

  • Label과 동일하게 key-value를 통해 리소스 특성 기록
  • Kubernetes에게 특정 정보 전달할 용도로 사용
    • 예를 들어, Deployment의 rolling update 정보 기록
annotations:
  kubernetes.io/change-cause:version 1.15

 

  • 관리를 위해 필요한 정보를 기록할 용도로 사용
    • 릴리즈, 로깅, 모니터링에 필요 한 정보들을 기록
annotations:
  builder: "seongmi Lee (seongmi.lee@gmail.com)"
  buildDate: "20210502"
  imageRegistry: https://hub.docker.com

 

  • 즉, 운영 환경에서 꼭! 전달해주어야 할 정보 등은 annotation을 이용하면 되겠당

 

예시

 

# annotation.yaml 파일 작성

apiVersion: v1
kind: Pod
metadata:
  name: pod-annotation
  annotations:
    builder: "seongmi Lee (seongmi.lee@gmail.com)"
    buildDate: "20210502"
    imageRegistry: https://hub.docker.com/
spec:
  containers:
  - name: nginx
    image: nginx:1.14
    ports:
    - containerPort: 80

 

# 생성 

root@master:~/Getting-Start-Kubernetes/9# kubectl create -f annotation.yaml
pod/pod-annotation created

 

# 확인

root@master:~/Getting-Start-Kubernetes/9# kubectl describe pod pod-annotation
Name:             pod-annotation
Namespace:        default
Priority:         0
Service Account:  default
Node:             node2/10.100.0.102
Start Time:       Tue, 10 Dec 2024 04:16:07 +0000
Labels:           <none>
Annotations:      buildDate: 20210502
                  builder: seongmi Lee (seongmi.lee@gmail.com)
                  cni.projectcalico.org/containerID: 180ad131f2eb6a9add56790a739bb4d5e2b3a5178d87d17932fb719f1e4ff875
                  cni.projectcalico.org/podIP: 192.168.104.33/32
                  cni.projectcalico.org/podIPs: 192.168.104.33/32
                  imageRegistry: https://hub.docker.com/

 


참고 영상

https://www.youtube.com/watch?v=Q5UBx7MAQLw&list=PLApuRlvrZKohaBHvXAOhUD-RxD0uQ3z0c&index=32