Merging Kubernetes kubectl config files

  • To run a kubernetes cluster check whether the path of that cluster should be present in “~/ .kube/config” folder.If not there, we need to add the path of the cluster to that folder.

  • To check whether the path is present in “~/ .kube/config” folder.

$ echo $KUBECONFIG
  • If path is absent follow the below commands:

  • $ export KUBECONFIG=~/.kube/config:PATH OF THE CLUSTER $ kubectl config view --flatten >> ~/.kube/config $ echo $KUBECONFIG
  • To display the cluster contexts

$ kubectl config get-contexts
  • Sometimes when working with a new Kubernetes cluster you will be given a config file to use when authenticating with the cluster. This file should be placed at ~/.kube/config. However you may already have an existing config file at that location and you need to merge them together.

  • To merge the config files in “~/ .kube/config” follow the below steps:

  • It will create a backup file for existing config file.

consider eks_gowtham_eks = path1

eks_Gowtham_cicd = path2

  • Add those paths using following command

  • After adding the paths check they had added or not

  • If you want to switch the contexts

  • Finally check whether all the pods are running.