DEV Community

Cover image for Kubernetes - Merging kubeconfig Files
Unni P
Unni P

Posted on • Originally published at iamunnip.hashnode.dev

Kubernetes - Merging kubeconfig Files

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 the cluster name and endpoint, user credentials and the context

Steps

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

Reference

https://jacobtomlinson.dev/posts/2019/how-to-merge-kubernetes-kubectl-config-files/

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Billboard image

Try REST API Generation for Snowflake

DevOps for Private APIs. Automate the building, securing, and documenting of internal/private REST APIs with built-in enterprise security on bare-metal, VMs, or containers.

  • Auto-generated live APIs mapped from Snowflake database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay