kubectl get secrets 디코딩

Jmnote (토론 | 기여)님의 2019년 4월 1일 (월) 11:25 판 (→‎같이 보기)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

kubectl get secrets 디코딩
Console
Copy
$ kubectl get secrets test-secret -oyaml | grep ^data: -A2
data:
  password: YTYyZmpiZDM3OTQyZGNz
  username: YWRtaW4=

2 without jq[ | ]

Console
Copy
$ kubectl get secrets test-secret -ojsonpath='{.data.password}' |base64 -d;echo
a62fjbd37942dcs
$ kubectl get secrets test-secret -ojsonpath='{.data.username}' |base64 -d;echo
admin
Console
Copy
$ kubectl get secrets test-secret -oyaml | grep ^data: -A2 |tail -n+2|awk '{print $NF}'|xargs -IR sh -c 'echo R|base64 -d;echo'
a62fjbd37942dcs
admin
Console
Copy
$ kubectl get secrets test-secret -oyaml | grep ^data: -A2 |tail -n+2|awk '{print $NF}'|while read -r R;do echo $R|base64 -d;echo;done
a62fjbd37942dcs
admin
Console
Copy
$ kubectl get secrets test-secret -oyaml | grep ^data: -A2 |grep -v ^data:|awk '{print $NF}'|while read -r R;do echo $R|base64 -d;echo;done
a62fjbd37942dcs
admin

3 with jq 1.5[ | ]

Console
Copy
$ kubectl get secrets test-secret -ojson | jq -r '.data[]' |xargs -IR sh -c 'echo R|base64 -d;echo'
a62fjbd37942dcs
admin
Console
Copy
$ kubectl get secrets test-secret -ojson | jq -r '.data[]' |while read -r R;do echo $R|base64 -d;echo;done
a62fjbd37942dcs
admin

4 with jq 1.6+[ | ]

Console
Copy
$ kubectl get secrets test-secret -ojson | jq -r '.data[] | @base64d'
a62fjbd37942dcs
admin

5 같이 보기[ | ]