Cloud Engineering/Kubernetes ⚙️
[Kubernetes] Annotation 추가하기
minjiwoo
2023. 2. 9. 17:47
728x90
Annotation이란
Object에 부가적으로 붙여주고 싶은 정보를 Annotation이라고 한다. Label과 같이 Key: Value 값으로 저장되지만, Label처럼 검색이 되지 않는다.
Annotation을 추가하는 방법
1. object에 직접 Annotation을 커맨드로 추가
$ kubectl annotate pods PODNAME ANNOTATION_KEY=VALUE
[예시]
$ kubectl annotate pods myapp-pod devops-team/developer=Minjee
kubectl describe pods 명령어를 통해 다음과 같이 Annotation 필드의 마지막 줄에 내용이 추가 된 것을 확인할 수 있다.
2. Manifest File 생성시에 Annotation 추가하기
test-annotation-pod.yaml 의 내용을 다음과 같이 작성했다. metadata 하위의 annotations에 key: value 형태로 추가할 내용을 적었다.
apiVersion: v1
kind: Pod
metadata:
name: test-annotation-pod
annotations:
backend-team/developer: freemjstudio
spec:
containers:
- name: test-annotation-pod
image: ghcr.io/c1t1d0s7/go-myweb:alpine
ports:
- containerPort: 8080
protocol: TCP
pod을 생성한다
$ kubectl create -f test-annotation-pod.yaml
다음과 같이 Annotation이 추가된 것을 확인할 수 있다.
728x90