skip to content
Alvin Lucillo

Using cert data in kube cfg

/ 1 min read

In the example config file below (~/.kube/config), certificates and key values are referenced their absolute file path.

apiVersion: v1
clusters:
  - cluster:
      certificate-authority: /somedir/ca.crt
      server: https://somedomain.com:443
    name: cluster1
users:
  - name: user1
    user:
      client-certificate: /somedir/client.crt
      client-key: /somedir/client.key

Alternative, you can use cert data in place. Be sure to use the content is base64 decoded without line breaks. To do that, encode the contents of the files in base64. This applies to both .crt and .key files.

cat ca.crt | base64 -w 0
LS0tLS1CR...

Then remove the file references and provide the encoded files into their respective locations. Notice that the counterpart property has -data suffix.

apiVersion: v1
clusters:
  - cluster:
      certificate-authority-data: LS0tLS1CR...
      server: https://somedomain.com:443
    name: cluster1
users:
  - name: user1
    user:
      client-certificate-data: LS0tLS1CR...
      client-key-data: LS0tLS1CR...