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.keyPlace the file in ~/.kube/config
Explanation #
There are 3 components:
- Clusters Specify which cluster to connecto. For example: Local, Staging, Development, Google, AWS, and etc.
- Contexts Choose which account to use that is associated to a cluster.
- 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:6443use certificate-authority-data if you want to paste the contents of ca.crt.
Contexts Section #
contexts:
- name: admin@myCluster
context:
cluster: myCluster
user: adminUsers Sections #
users:
- name: admin
users:
client-certificate: /etc/kubernetes/pki/users/admin.crt
client-key: /etc/kubernetes/pki/users/admin.keyUse client-certificate-data and paste the content of the certificate instead
of the file.