Difference between revisions of "Kubectl get secret"

From wikieduonline
Jump to navigation Jump to search
 
(25 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Draft}}
 
 
{{lowercase}}
 
{{lowercase}}
 +
* <code>[[kubectl get]] secrets</code>
 +
* <code>[[kubectl -n kube-system describe secret]] $(kubectl -n kube-system get secret | grep service-controller-token | awk '{print $1}')</code>
  
  [[kubectl get]] secret --namespace default grafana -o jsonpath="{.data.admin-password}" | [[base64]] --decode ; echo
+
  [[kubectl get]] secrets
 +
error: [[You must be logged in to the server]] (Unauthorized)
 +
 
 +
Example for [[grafana helm]]:
 +
* <code>[[kubectl get]] secret --namespace default grafana -o [[jsonpath]]="{.data.admin-password}" | [[base64 --decode]] ; echo</code>
 
  Tjp67Ib3c2PxvGoD6SH1pjTtnlq6X4XvrXo4xxx
 
  Tjp67Ib3c2PxvGoD6SH1pjTtnlq6X4XvrXo4xxx
  
  kubectl -n kube-system [[describe secret]] $(kubectl -n kube-system get secret | grep service-controller-token | awk '{print $1}')
+
Example [[Kubernetes Dashboard]]:
 +
kubectl get secret mykubedashboard-kubernetes-dashboard-token-8wfsh -o jsonpath="{.data.token}" | [[base64]] --decode; echo
 +
 
 +
Example [[Redis]]
 +
export REDIS_PASSWORD=$(kubectl get secret --namespace default myredis -o jsonpath="{.data.redis-password}" | [[base64 -d]])
 +
 
 +
[[MariaDB]]:
 +
kubectl get secret --namespace default my-mariadb -o jsonpath="{.data.mariadb-root-password}" | [[base64 -d]] ; [[echo]]
 +
 
 +
 
 +
  kubectl -n kube-system [[describe secret]] $([[kubectl -n kube-system get secret]] | grep [[service-controller-token]] | awk '{print $1}')
 +
  
 
  kubectl get secret
 
  kubectl get secret
 
  NAME                            TYPE                                  DATA  AGE
 
  NAME                            TYPE                                  DATA  AGE
  default-token-kb4hm            kubernetes.io/service-account-token  3      3h15m
+
  default-token-kb4hm            kubernetes.io/[[service-account-token]]   3      3h15m
 
  grafana                        Opaque                                3      169m
 
  grafana                        Opaque                                3      169m
 
  grafana-test-token-j4jgj        kubernetes.io/service-account-token  3      169m
 
  grafana-test-token-j4jgj        kubernetes.io/service-account-token  3      169m
Line 79: Line 95:
 
  kubernetes-dashboard-key-holder    Opaque                                2      19m
 
  kubernetes-dashboard-key-holder    Opaque                                2      19m
 
  kubernetes-dashboard-token-nj4xp  kubernetes.io/service-account-token  3      19m
 
  kubernetes-dashboard-token-nj4xp  kubernetes.io/service-account-token  3      19m
 +
 +
== kubectl get secrets -A ==
 +
<pre>
 +
kubectl get secrets  -A
 +
NAMESPACE        NAME                                              TYPE                                  DATA  AGE
 +
default          default-token-lvwjg                                kubernetes.io/service-account-token  3      2d23h
 +
default          kubernetes-dashboard-csrf                          Opaque                                1      46h
 +
default          kubernetes-dashboard-key-holder                    Opaque                                2      46h
 +
default          mykubedashboard-kubernetes-dashboard-certs        Opaque                                0      46h
 +
default          mykubedashboard-kubernetes-dashboard-token-8wfsh  kubernetes.io/service-account-token  3      46h
 +
default          mynewuser-token-vjdsc                              kubernetes.io/service-account-token  3      3m19s
 +
default          sh.helm.release.v1.mykubedashboard.v1              helm.sh/release.v1                    1      46h
 +
kube-node-lease  default-token-bzm66                                kubernetes.io/service-account-token  3      2d23h
 +
kube-public      default-token-djpbc                                kubernetes.io/service-account-token  3      2d23h
 +
kube-system      attachdetach-controller-token-bjsg7                kubernetes.io/service-account-token  3      2d23h
 +
kube-system      aws-cloud-provider-token-g5vfz                    kubernetes.io/service-account-token  3      2d23h
 +
kube-system      aws-node-token-dc7s8                              kubernetes.io/service-account-token  3      2d23h
 +
kube-system      certificate-controller-token-fqx5z                kubernetes.io/service-account-token  3      2d23h
 +
kube-system      clusterrole-aggregation-controller-token-vh8jq    kubernetes.io/service-account-token  3      2d23h
 +
kube-system      coredns-token-cd6dw                                kubernetes.io/service-account-token  3      2d23h
 +
kube-system      cronjob-controller-token-h5hhp                    kubernetes.io/service-account-token  3      2d23h
 +
kube-system      daemon-set-controller-token-kdgrf                  kubernetes.io/service-account-token  3      2d23h
 +
kube-system      default-token-gm76r                                kubernetes.io/service-account-token  3      2d23h
 +
kube-system      deployment-controller-token-txxtr                  kubernetes.io/service-account-token  3      2d23h
 +
kube-system      disruption-controller-token-zt94t                  kubernetes.io/service-account-token  3      2d23h
 +
kube-system      eks-vpc-resource-controller-token-427m9            kubernetes.io/service-account-token  3      2d23h
 +
kube-system      endpoint-controller-token-29bkz                    kubernetes.io/service-account-token  3      2d23h
 +
kube-system      endpointslice-controller-token-bh6jw              kubernetes.io/service-account-token  3      2d23h
 +
kube-system      endpointslicemirroring-controller-token-jq6g6      kubernetes.io/service-account-token  3      2d23h
 +
kube-system      ephemeral-volume-controller-token-mm56p            kubernetes.io/service-account-token  3      2d21h
 +
kube-system      expand-controller-token-2kq9n                      kubernetes.io/service-account-token  3      2d23h
 +
kube-system      generic-garbage-collector-token-gvlms              kubernetes.io/service-account-token  3      2d23h
 +
kube-system      horizontal-pod-autoscaler-token-h7sf7              kubernetes.io/service-account-token  3      2d23h
 +
kube-system      job-controller-token-g6xnx                        kubernetes.io/service-account-token  3      2d23h
 +
kube-system      kube-proxy-token-pmt72                            kubernetes.io/service-account-token  3      2d23h
 +
kube-system      namespace-controller-token-7srkk                  kubernetes.io/service-account-token  3      2d23h
 +
kube-system      node-controller-token-7zzzq                        kubernetes.io/service-account-token  3      2d23h
 +
kube-system      persistent-volume-binder-token-p57ql              kubernetes.io/service-account-token  3      2d23h
 +
kube-system      pod-garbage-collector-token-ffbt4                  kubernetes.io/service-account-token  3      2d23h
 +
kube-system      pv-protection-controller-token-5zq5d              kubernetes.io/service-account-token  3      2d23h
 +
kube-system      pvc-protection-controller-token-qjknx              kubernetes.io/service-account-token  3      2d23h
 +
kube-system      replicaset-controller-token-qj6gc                  kubernetes.io/service-account-token  3      2d23h
 +
kube-system      replication-controller-token-lnpkv                kubernetes.io/service-account-token  3      2d23h
 +
kube-system      resourcequota-controller-token-r7hwf              kubernetes.io/service-account-token  3      2d23h
 +
kube-system      root-ca-cert-publisher-token-v6mbf                kubernetes.io/service-account-token  3      2d23h
 +
kube-system      service-account-controller-token-79pv9            kubernetes.io/service-account-token  3      2d23h
 +
kube-system      service-controller-token-tdtfg                    kubernetes.io/service-account-token  3      2d23h
 +
kube-system      statefulset-controller-token-ncpxb                kubernetes.io/service-account-token  3      2d23h
 +
kube-system      ttl-after-finished-controller-token-nk2f4          kubernetes.io/service-account-token  3      2d23h
 +
kube-system      ttl-controller-token-vxtzn                        kubernetes.io/service-account-token  3      2d23h
 +
kube-system      vpc-resource-controller-token-m7zgm                kubernetes.io/service-account-token  3      2d23h
 +
</pre>
  
 
== Related terms ==
 
== Related terms ==
 
* [[Secret]]
 
* [[Secret]]
* <code>[[kubectl describe secret]]</code>
+
* <code>[[kubectl describe secrets]]</code>
 +
* <code>[[kubectl get pods]]</code>
 +
* [[kubernetes.io/tls]]
  
 
== See also ==
 
== See also ==
* {{kubectl get}}
+
* {{Kubernetes secrets}}
* {{kubectl}}
 
  
 
[[Category:Secrets]]
 
[[Category:Secrets]]
 
[[Category:K8]]
 
[[Category:K8]]

Latest revision as of 20:02, 15 February 2024

kubectl get secrets
error: You must be logged in to the server (Unauthorized)

Example for grafana helm:

Tjp67Ib3c2PxvGoD6SH1pjTtnlq6X4XvrXo4xxx

Example Kubernetes Dashboard:

kubectl get secret mykubedashboard-kubernetes-dashboard-token-8wfsh -o jsonpath="{.data.token}" | base64 --decode; echo

Example Redis

export REDIS_PASSWORD=$(kubectl get secret --namespace default myredis -o jsonpath="{.data.redis-password}" | base64 -d)

MariaDB:

kubectl get secret --namespace default my-mariadb -o jsonpath="{.data.mariadb-root-password}" | base64 -d ; echo


kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep service-controller-token | awk '{print $1}')

kubectl get secret
NAME                            TYPE                                  DATA   AGE
default-token-kb4hm             kubernetes.io/service-account-token   3      3h15m
grafana                         Opaque                                3      169m
grafana-test-token-j4jgj        kubernetes.io/service-account-token   3      169m
grafana-token-fsxtt             kubernetes.io/service-account-token   3      169m
sh.helm.release.v1.grafana.v1   helm.sh/release.v1                    1      169m
kubectl get secret --namespace default
NAME                            TYPE                                  DATA   AGE
default-token-kb4hm             kubernetes.io/service-account-token   3      3h13m
grafana                         Opaque                                3      167m
grafana-test-token-j4jgj        kubernetes.io/service-account-token   3      167m
grafana-token-fsxtt             kubernetes.io/service-account-token   3      167m
sh.helm.release.v1.grafana.v1   helm.sh/release.v1                    1      167m
kubectl get secret
NAME                                   TYPE                                  DATA   AGE
default-token-wdzsn                    kubernetes.io/service-account-token   3      2d23h
metrics-server-token-cwzgk             kubernetes.io/service-account-token   3      2d5h
sh.helm.release.v1.metrics-server.v1   helm.sh/release.v1                    1      2d5h
kubectl get secret -n kube-system
NAME                                             TYPE                                  DATA   AGE
admin-user-token-8mwp5                           kubernetes.io/service-account-token   3      2d5h
attachdetach-controller-token-w5pvm              kubernetes.io/service-account-token   3      2d23h
aws-cloud-provider-token-5dk62                   kubernetes.io/service-account-token   3      2d23h
aws-node-token-lkqvj                             kubernetes.io/service-account-token   3      2d23h
certificate-controller-token-dwhlr               kubernetes.io/service-account-token   3      2d23h
clusterrole-aggregation-controller-token-j9kcz   kubernetes.io/service-account-token   3      2d23h
coredns-token-t69l7                              kubernetes.io/service-account-token   3      2d23h
cronjob-controller-token-m7jkm                   kubernetes.io/service-account-token   3      2d23h
daemon-set-controller-token-69rdz                kubernetes.io/service-account-token   3      2d23h
default-token-z9vs8                              kubernetes.io/service-account-token   3      2d23h
deployment-controller-token-vrfdp                kubernetes.io/service-account-token   3      2d23h
disruption-controller-token-8zzgr                kubernetes.io/service-account-token   3      2d23h
eks-vpc-resource-controller-token-v9dd7          kubernetes.io/service-account-token   3      2d23h
endpoint-controller-token-2fjkq                  kubernetes.io/service-account-token   3      2d23h
endpointslice-controller-token-jfbvz             kubernetes.io/service-account-token   3      2d23h
endpointslicemirroring-controller-token-rvzsv    kubernetes.io/service-account-token   3      2d23h
ephemeral-volume-controller-token-ktpbl          kubernetes.io/service-account-token   3      2d23h
expand-controller-token-zjdrp                    kubernetes.io/service-account-token   3      2d23h
generic-garbage-collector-token-46dmh            kubernetes.io/service-account-token   3      2d23h
horizontal-pod-autoscaler-token-x4ptb            kubernetes.io/service-account-token   3      2d23h
job-controller-token-6bbpn                       kubernetes.io/service-account-token   3      2d23h
kube-proxy-token-x9md9                           kubernetes.io/service-account-token   3      2d23h
namespace-controller-token-8rw2g                 kubernetes.io/service-account-token   3      2d23h
node-controller-token-tbhlj                      kubernetes.io/service-account-token   3      2d23h
persistent-volume-binder-token-xsf66             kubernetes.io/service-account-token   3      2d23h
pod-garbage-collector-token-fb9zk                kubernetes.io/service-account-token   3      2d23h
pv-protection-controller-token-sbvqz             kubernetes.io/service-account-token   3      2d23h
pvc-protection-controller-token-b6gtg            kubernetes.io/service-account-token   3      2d23h
replicaset-controller-token-jj4mp                kubernetes.io/service-account-token   3      2d23h
replication-controller-token-64z6b               kubernetes.io/service-account-token   3      2d23h
resourcequota-controller-token-pvv9x             kubernetes.io/service-account-token   3      2d23h
root-ca-cert-publisher-token-76wkq               kubernetes.io/service-account-token   3      2d23h
service-account-controller-token-d7qkk           kubernetes.io/service-account-token   3      2d23h
service-controller-token-qljq5                   kubernetes.io/service-account-token   3      2d23h
statefulset-controller-token-jl4rm               kubernetes.io/service-account-token   3      2d23h
ttl-after-finished-controller-token-hp6h9        kubernetes.io/service-account-token   3      2d23h
ttl-controller-token-28vng                       kubernetes.io/service-account-token   3      2d23h
vpc-resource-controller-token-6rtfp              kubernetes.io/service-account-token   3      2d23h
kubectl get secrets -n kubernetes-dashboard
NAME                               TYPE                                  DATA   AGE
default-token-qjs5l                kubernetes.io/service-account-token   3      20m
kubernetes-dashboard-certs         Opaque                                0      19m
kubernetes-dashboard-csrf          Opaque                                1      19m
kubernetes-dashboard-key-holder    Opaque                                2      19m
kubernetes-dashboard-token-nj4xp   kubernetes.io/service-account-token   3      19m

kubectl get secrets -A[edit]

kubectl get secrets  -A
NAMESPACE         NAME                                               TYPE                                  DATA   AGE
default           default-token-lvwjg                                kubernetes.io/service-account-token   3      2d23h
default           kubernetes-dashboard-csrf                          Opaque                                1      46h
default           kubernetes-dashboard-key-holder                    Opaque                                2      46h
default           mykubedashboard-kubernetes-dashboard-certs         Opaque                                0      46h
default           mykubedashboard-kubernetes-dashboard-token-8wfsh   kubernetes.io/service-account-token   3      46h
default           mynewuser-token-vjdsc                              kubernetes.io/service-account-token   3      3m19s
default           sh.helm.release.v1.mykubedashboard.v1              helm.sh/release.v1                    1      46h
kube-node-lease   default-token-bzm66                                kubernetes.io/service-account-token   3      2d23h
kube-public       default-token-djpbc                                kubernetes.io/service-account-token   3      2d23h
kube-system       attachdetach-controller-token-bjsg7                kubernetes.io/service-account-token   3      2d23h
kube-system       aws-cloud-provider-token-g5vfz                     kubernetes.io/service-account-token   3      2d23h
kube-system       aws-node-token-dc7s8                               kubernetes.io/service-account-token   3      2d23h
kube-system       certificate-controller-token-fqx5z                 kubernetes.io/service-account-token   3      2d23h
kube-system       clusterrole-aggregation-controller-token-vh8jq     kubernetes.io/service-account-token   3      2d23h
kube-system       coredns-token-cd6dw                                kubernetes.io/service-account-token   3      2d23h
kube-system       cronjob-controller-token-h5hhp                     kubernetes.io/service-account-token   3      2d23h
kube-system       daemon-set-controller-token-kdgrf                  kubernetes.io/service-account-token   3      2d23h
kube-system       default-token-gm76r                                kubernetes.io/service-account-token   3      2d23h
kube-system       deployment-controller-token-txxtr                  kubernetes.io/service-account-token   3      2d23h
kube-system       disruption-controller-token-zt94t                  kubernetes.io/service-account-token   3      2d23h
kube-system       eks-vpc-resource-controller-token-427m9            kubernetes.io/service-account-token   3      2d23h
kube-system       endpoint-controller-token-29bkz                    kubernetes.io/service-account-token   3      2d23h
kube-system       endpointslice-controller-token-bh6jw               kubernetes.io/service-account-token   3      2d23h
kube-system       endpointslicemirroring-controller-token-jq6g6      kubernetes.io/service-account-token   3      2d23h
kube-system       ephemeral-volume-controller-token-mm56p            kubernetes.io/service-account-token   3      2d21h
kube-system       expand-controller-token-2kq9n                      kubernetes.io/service-account-token   3      2d23h
kube-system       generic-garbage-collector-token-gvlms              kubernetes.io/service-account-token   3      2d23h
kube-system       horizontal-pod-autoscaler-token-h7sf7              kubernetes.io/service-account-token   3      2d23h
kube-system       job-controller-token-g6xnx                         kubernetes.io/service-account-token   3      2d23h
kube-system       kube-proxy-token-pmt72                             kubernetes.io/service-account-token   3      2d23h
kube-system       namespace-controller-token-7srkk                   kubernetes.io/service-account-token   3      2d23h
kube-system       node-controller-token-7zzzq                        kubernetes.io/service-account-token   3      2d23h
kube-system       persistent-volume-binder-token-p57ql               kubernetes.io/service-account-token   3      2d23h
kube-system       pod-garbage-collector-token-ffbt4                  kubernetes.io/service-account-token   3      2d23h
kube-system       pv-protection-controller-token-5zq5d               kubernetes.io/service-account-token   3      2d23h
kube-system       pvc-protection-controller-token-qjknx              kubernetes.io/service-account-token   3      2d23h
kube-system       replicaset-controller-token-qj6gc                  kubernetes.io/service-account-token   3      2d23h
kube-system       replication-controller-token-lnpkv                 kubernetes.io/service-account-token   3      2d23h
kube-system       resourcequota-controller-token-r7hwf               kubernetes.io/service-account-token   3      2d23h
kube-system       root-ca-cert-publisher-token-v6mbf                 kubernetes.io/service-account-token   3      2d23h
kube-system       service-account-controller-token-79pv9             kubernetes.io/service-account-token   3      2d23h
kube-system       service-controller-token-tdtfg                     kubernetes.io/service-account-token   3      2d23h
kube-system       statefulset-controller-token-ncpxb                 kubernetes.io/service-account-token   3      2d23h
kube-system       ttl-after-finished-controller-token-nk2f4          kubernetes.io/service-account-token   3      2d23h
kube-system       ttl-controller-token-vxtzn                         kubernetes.io/service-account-token   3      2d23h
kube-system       vpc-resource-controller-token-m7zgm                kubernetes.io/service-account-token   3      2d23h

Related terms[edit]

See also[edit]

Advertising: