반응형

<조회대상 샘플 yaml>

<deploy yaml>

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: test-nginx
    tier: frontend
spec:
  replicas: 3
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: test-nginx

 

 

<custom column 활용>

 . 조회방법 :   

1) -o custom-columns=컬럼명:경로

2) kubectl custom-columns조회시   mapping이 1번은  . 한개,   N번이라면 N번의 .을 추가하면 됨

 

 

 . ex)

1.Spec  조회 (map .한번) 

controlplane $ kubectl get deploy nginx-deployment -o custom-columns=spec:.spec

<결과>

spec
map[progressDeadlineSeconds:600 replicas:3 revisionHistoryLimit:10 selector:map[matchLabels:map[app:test-nginx]] 
<..중략>

 

 

2. replicas 조회 (map . 한번)

controlplane $ kubectl get deploy nginx-deployment -o custom-columns=replicas:.spec.replicas    #map  .  한번

<결과>

replicas
3

 

3. matchLabelsapp 조회 (map .. 두번)

< selector. 1>

controlplane $ kubectl get deploy nginx-deployment -o custom-columns=matchlabels:.spec.selector

 

matchlabels
map[matchLabels:map[app:test-nginx]]

< app는  map2, 그래서 . 2번 후 key(app)>

 

controlplane $ kubectl get deploy nginx-deployment -o custom-columns=matchlabels:.spec.selector..app

<결과>

matchlabels
test-nginx
반응형

'클라우드 > K8S' 카테고리의 다른 글

helm 명령어  (0) 2023.01.02
[system log]failed to get system container stats  (0) 2022.12.19
[k8s] orphaned pod 조치  (0) 2022.12.16
kubectl cheet sheet, useful cheet  (0) 2022.12.15
[k8s]Node Drain  (0) 2021.09.14

+ Recent posts