Last active
April 6, 2017 08:43
-
-
Save lcharkiewicz/9d48633fec47dc9ccef297e1202d8cd4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# usage: | |
# python kube_config_merge.py ~/.kube/config1 ~/.kube/config2 | |
import sys | |
import yaml # PyYAML | |
configs = [] | |
for config in sys.argv[1:]: | |
print(config) | |
configs.append(yaml.load(open(config, 'r'))) | |
# load first config | |
merged = configs[0] | |
# merge next configs with the first one | |
for config in configs[1:]: | |
for cluster in config['clusters']: | |
merged['clusters'].append(cluster) | |
for context in config['contexts']: | |
merged['contexts'].append(context) | |
for user in config['users']: | |
merged['users'].append(user) | |
print(yaml.dump(merged, default_flow_style=False)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment