Merging kubeconfig Files

Unni P
Apr 24, 2023

In this short article, we will look how we can merge a new kubeconfig file to an existing config file

Introduction

  • Kubernetes is an open-source container orchestration tool to manage containerized applications
  • An important component of Kubernetes is kubeconfig, a configuration file used to connect to our clusters
  • A kubeconfig file contains cluster name and endpoint, user credentials and the context

Steps

  • Make a copy of your existing kubeconfig file
$ cp ~/.kube/config ~/.kube/config.bak
  • Merge the old and new kubeconfig files using the below command
$ KUBECONFIG=~/.kube/config:~/new-kubeconfig.yml \
kubectl config view --flatten > ~/merged-kubeconfig.yml
  • Replace your old config with new merged config file
$ cp ~/merged-kubeconfig.yml ~/.kube/config
  • List the contexts, now you can see our new cluster
$ kubectl config get-contexts

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Unni P
Unni P

Written by Unni P

SysAdmin turned into DevOps Engineer | Collaboration and Shared Responsibility

No responses yet

Write a response