user674669
user674669

Reputation: 12352

How do I obtain Kubernetes CA Certificate?

I am setting up Vault in Kubernetes and enabling the Kubernetes Auth method. It needs the Kubernetes CA Certificate. How do I obtain that? I couldn't find much on duckduckgo's search results.

enter image description here

Running kubernetes inside Docker for mac on MacOS Mojave:

enter image description here Thank you.

Upvotes: 7

Views: 13658

Answers (3)

kmpfwgn
kmpfwgn

Reputation: 61

kubectl get cm -o jsonpath='{.items[0].data.ca\.crt}' | tr -d '\n'

Upvotes: 1

albeus
albeus

Reputation: 316

Unfortunately, the "get secret" way is not working anymore (from the release 1.24 there aren't auto-generated secrets).

In GKE clusters, I've found this way to get the ca certificate:

kubectl get cm kube-root-ca.crt -o jsonpath="{['data']['ca\.crt']}"

Upvotes: 9

cookiedough
cookiedough

Reputation: 3832

This can be found in your kube-system (or any other) namespace by running the following on your default-token secret:

kubectl get secret <secret name> -n <namespace> -o jsonpath="{['data']['ca\.crt']}" | base64 --decode

To find the secret name run kubectl get secret -n kube-system and find the secret that starts with default-token.

This will give you something like:

-----BEGIN CERTIFICATE-----
XXXXXXX
XXXX....
-----END CERTIFICATE-----

When you are entering this certificate, make sure to enter the BEGIN and END header and footer.

Upvotes: 9

Related Questions