github.com/annchain/OG@v0.0.9/scripts/config/generator.py (about) 1 import yaml 2 3 var = 7 4 5 if __name__ == '__main__': 6 # ex 7 for i in range(var): 8 with open('service_ex.yaml') as f: 9 y = yaml.load(f) 10 11 y['metadata']['name'] = 'ognb-ex-%d' % (i) 12 for portset in y['spec']['ports']: 13 portset['nodePort'] = portset['nodePort'] + i * 10 14 y['spec']['selector']['statefulset.kubernetes.io/pod-name'] = 'ognb-%d' % (i) 15 16 with open('ex/%d.yaml' % (i), 'w') as f: 17 yaml.dump(y, f) 18 19 if __name__ == '__main__': 20 # in 21 for i in range(var): 22 with open('service_in.yaml') as f: 23 y = yaml.load(f) 24 25 y['metadata']['name'] = 'ognb-%d' % (i) 26 y['spec']['selector']['statefulset.kubernetes.io/pod-name'] = 'ognb-%d' % (i) 27 28 with open('in/%d.yaml' % (i), 'w') as f: 29 yaml.dump(y, f)