Skip to content

Python script to concatenate many kubeconfig files in one consolidate file to use in a easy way the kubectl command

Notifications You must be signed in to change notification settings

reverson-farfetch/parsing_kubeconfig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

parsing_kubeconfig

This repository is to a script that concatenate many kubeconfigs file in one.

How to use

Execute the script related with the python version which you are using.

[NOTE]: The script will try looking for to files which ends like "*-config" in the path that was asked or you can setting customize prefix.
And it will concatenate every file found in one. You can pass the source directory where the files are stored and the recipient where the file will be save. Also you can keep the default recipients if as well as wished.

The script will offer the follow questions when is executing:

Where are stored the kubeconfig files?[/etc/kubernetes]:
Where do want to save the kubeconfig file?[~/.kube/config]:
Do you want to change the default prefix?[*-config]:

After you choose the path and prefix you can configure the current context if you want.
Do you want to config a current context?[None]:

To show the contexts in the file use the command: 'kubectl config get-contexts'
To change the current context: 'kubectl config use-context <context_name>'
To change the current namespace: 'kubectl config set-context --current --namespace='

Example of stdout of executation

    *****************************************************************************************************************
      [NOTE]:The script will try looking for to files which ends like "*-config" in the path that was asked or you 
      can setting customize prefix.
      And it will concatenate every file found in one. You can pass the source directory where the files are stored 
      and the recipient where the file will be save. Also you can keep the default recipients if as well as wished.
    *****************************************************************************************************************
    
Where are stored the kubeconfig files?[/etc/kubernetes]: /home/user/kubectl-files
Where do want to save the kubeconfig file?[~/.kube/config]: 
Do you want to change the default prefix?[*-config]: kubeconfig*
 ~> Context created 'context-1'
 ~> Context created 'context-2'
 ~> Context created 'context-3'
 ~> Context created 'context-4'
 ~> Context created 'context-5'

Do you want to config a current context?[None]: context-5

The file was created in "/home/user/.kube/config"

    ~> To show the contexts in the file use the command: 'kubectl config get-contexts'
    ~> To change the current context: 'kubectl config use-context <context_name>'
    ~> To change the current namespace: 'kubectl config set-context --current --namespace=<namespace>'

About

Python script to concatenate many kubeconfig files in one consolidate file to use in a easy way the kubectl command

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages