Structure of kubeconfig
A kubeconfig file usually requires the necessary details in order to interact with the cluster. Some of them are as follows:
- apiVersion: Specify the version of Kubernetes API.
- clusters: Specify a list of clusters that are to be managed.
- users: Used to authenticate. Typically the subcategories include name and secret tokens.
- contexts: Specify contexts so as to group the clusters.
- current-context: Specify the context to which the current cluster should connect.
Below is the sample of the kubeconfig file
apiVersion: v1
kind: Config
clusters:
- name: c1
cluster:
server: https://clustersample1.example.com
certificate-authority: /path/to/cluster1-ca.crt
- name: c2
cluster:
server: https://clustersample2.example.com
certificate-authority: /path/to/cluster2-ca.crt
contexts:
- name: context1
context:
cluster: c1
user: user1
namespace: default
- name: context2
context:
cluster: c2
user: user2
namespace: developer
current-context: context1
users:
- name: user1
user:
client-certificate: /path/to/user1.crt
client-key: /path/to/user1.key
- name: user2
user:
client-certificate: /path/to/user2.crt
client-key: /path/to/user2.key
This is a sample kubeconfig file. In this we have two clusters named c1 and c2 along with server links and certificate authority. A separate client key and certificate pair is also specified for authenticating each user.
What is kubernetes kubeconfig ?
The container is a package that comprises code and libraries that are to be executed. Now to automate the deployment of Containers we need Kubernetes or K8s. Kubernetes or K8s is an open source that is used for the deployment of containers. It is a container orchestration platform that is used to automate the deployment of containers. They help to manage, schedule, and scale the applications. Kubernetes should be confused with cloud services. They are basically integrated with cloud services in order to generate comprehensive solutions.
If we go through the structure, Kubernetes basically makes use of clusters. Inside clusters there exists nodes or physical machines. Inside those physical machines are pods. Inside pods, there exist containers.