[Cloude] k8s - Label & LabelSelector

MeltingOlafยท2022๋…„ 5์›” 17์ผ
0

[Cloud]

๋ชฉ๋ก ๋ณด๊ธฐ
18/25

โœ”๏ธ Label

๋ ˆ์ด๋ธ” ํ™•์ธ

$ kubectl get pods --show-labels
$ kubectl get pods X -o yaml
$ kubectl describe pods X

๋ ˆ์ด๋ธ” ๊ด€๋ฆฌ

$ kubectl label pods myweb APP=apache
$ kubectl label pods myweb ENV=developments
$ kubectl label pods myweb ENV=staging
$ kubectl label pods myweb ENV=staging --overwirte
$ kubectl label pods myweb ENV-

โœ”๏ธ LabelSelector

LabelSelector

  • ๊ฒ€์ƒ‰
  • ๋ฆฌ์†Œ์Šค ๊ฐ„ ์—ฐ๊ฒฐ

์ผ์น˜์„ฑ(equality base)

  • =
  • ==
  • !=
$ kubectl get pods -l APP=nginx
$ kubectl get pods -l APP==nginx
$ kubectl get pods -l 'APP!=nginx'

์ง‘ํ•ฉ์„ฑ(set base)

  • in
  • notin
  • exists: ํ‚ค๋งŒ ๋งค์นญ
    - kubectl get pods -l 'APP'
  • doesnotexists: ํ‚ค ์ œ์™ธ ๋งค์นญ
    - kubectl get pods -l '!APP'

โœ”๏ธ Annotations

๋ ˆ์ด๋ธ”๊ณผ ๋น„์Šท
๋น„ ์‹๋ณ„ ๋ฉ”ํƒ€๋ฐ์ดํƒ€

๋ช…๋ นํ˜• ์ปค๋งจ๋“œ

$ kubectl annotate pods myweb created-by=luna
$ kubectl annotate pods myweb created-by=Kim --overwrite
$ kubectl annotate pods myweb created-by-

YAML

apiVersion: v1
kind: Pod
metadata:
  name: myweb-label-anno
  labels:
    APP: apache
    ENV: staging
  annotations:
    Created-by: Jang
spec:
  containers:
    - name: myweb
      image: httpd
      ports:
        - containerPort: 80
          protocol: TCP
profile
How R U Today :)

0๊ฐœ์˜ ๋Œ“๊ธ€