Skip to main content

Kubernetes Configuration File

·159 words·1 min

TLDR
#

Here is an example of a config file.

apiVersion: v1
kind: Config

clusters:
  - name: myCluster
    cluster:
      certificate-authority: ca.crt
      server: https://IP/hostname:6443
contexts:
  - name: admin@myCluster
    context:
      cluster: myCluster
      user: admin
users:
  - name: admin
    users:
      client-certificate: /etc/kubernetes/pki/users/admin.crt
      client-key: /etc/kubernetes/pki/users/admin.key

Place the file in ~/.kube/config

Explanation
#

There are 3 components:

  1. Clusters Specify which cluster to connecto. For example: Local, Staging, Development, Google, AWS, and etc.
  2. Contexts Choose which account to use that is associated to a cluster.
  3. Users The accounts that is allowed to connect to the API of a cluster. Example: Admin, Dev User, Prod User.

Cluster Section
#

clusters:
  - name: myCluster
    cluster:
      certificate-authority: ca.crt
      server: https://IP/hostname:6443

use certificate-authority-data if you want to paste the contents of ca.crt.

Contexts Section
#

contexts:
  - name: admin@myCluster
    context:
      cluster: myCluster
      user: admin

Users Sections
#

users:
  - name: admin
    users:
      client-certificate: /etc/kubernetes/pki/users/admin.crt
      client-key: /etc/kubernetes/pki/users/admin.key

Use client-certificate-data and paste the content of the certificate instead of the file.