Welcome to Linux guru, In this article i will explain you how to get kubernetes cluster token and certificate information by commands.
Connect your kubernetes cluster using glocud command to your local machine.
$ kubectl get secret
NAME TYPE DATA AGE
default-token-7Dghp kubernetes.io/service-account-token 3 3d
Now, we will get token information using that secret which we got from above command.
$ kubectl -o json get secret default-token-7Dghp | jq -r ‘.data.token’ | base64 -d
(Replace your secret in above command).
Token Output :
sdklwksdKLJJDKASKLFkljfasjflaskfjasjflasjflkjasdfjasjfklasfjasfasfjskjfjslfkjkljfaksjfkljfklasjfkjskfjlakflassjfakfjkKLJAKFJKAJjlkJAKLFJASLFJLSJFLSAJafjLAKSJJSFlaKJKJFSJFAJSLKSJLJFLF.
Now we will get certificate information of that cluster using below command.
$ kubectl -o json get secret default-token-7Dghp | jq -r ‘.data.”ca.crt”‘ | base64 -d – | my ca.crt
(Replace your service secret number in above command, It will provide you cluster CA certificate).
—–BEGIN CERTIFICATE—–
agzS69lnVTLumhinlWvmni
LXaOofGtMqFfhdjhfjskdkjfkhfksdjhKJHKJHKJHKJHJJKHJhjhjkhHKHKKHABoyMwITAOBgNV
HQ8BAf8EBAMCAgQwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEA
UiTNLITJNODmh211ptA9U2KTJhQJH2I9t8AVwoTv9VRY/cpoW3BCdjXRKNEZmFMpsdsdsdsdsdsdsdsdsdsdsdsds====
—–END CERTIFICATE—–
Linuxguru