Finding the location of admin_ca, cluster_ca and admin_cert in k8s

11/29/2018

Basically, I am trying to deploy a docker image on K8s in a concourse pipeline. I want to use this resource to deploy. https://github.com/jcderr/concourse-kubernetes-resource#installing

However, I coudn't exactly figure out the values of

cluster_ca: _base64 encoded CA pem_
admin_key: _base64 encoded key pem_
admin_cert: _base64 encoded certificate_

For finding the cluster_ca, I tried to execute a command like the following:

kubectl config view --raw -o json | jq -r '.clusters[0].cluster."certificate-authority-data"' | tr -d '"' | base64 --decode

And for the admin_ca, I logged into one of the containers in the cluster and cat /var/run/secrets/kubernetes.io/serviceaccount/ca.crt

I am not sure if these two values are correct. Also, I am not sure what admin_key is.

Could someone help me to figure this out?

-- kosta
concourse
google-kubernetes-engine
kubernetes

1 Answer

11/29/2018

You can use following three commands to identify the cluster_ca, admin_cert and admin_key. Assuming you have set the current context on the kubernetes-admin

[root@ip-10-0-1-13]# kubectl config current-context
kubernetes-admin@kubernetes

Command for cluster_ca (Output will be Encoded in base64)

kubectl config view current-context --raw -o json | ./jq -r '.clusters[].cluster."certificate-authority-data"'

Command for admin_cert (Output will be Encoded in base64)

kubectl config view current-context --raw -o json | ./jq -r '.users[].user."client-certificate-data"'

Command for admin_key (Output will be Encoded in base64)

kubectl config view current-context --raw -o json | ./jq -r '.users[].user."client-key-data"'
-- Prafull Ladha
Source: StackOverflow