comparison kube.py @ 58:f39ada0b8827

push a coredns config with the right forwarding server
author drewp@bigasterisk.com
date Sun, 01 May 2022 23:27:33 -0700
parents 4c15fc1e879d
children b46df76991b6
comparison
equal deleted inserted replaced
57:16098abf8f0f 58:f39ada0b8827
26 dest='/usr/local/bin/k3s', 26 dest='/usr/local/bin/k3s',
27 user='root', 27 user='root',
28 group='root', 28 group='root',
29 mode='755', 29 mode='755',
30 cache_time=43000, 30 cache_time=43000,
31 # force=True, # to get a new version 31 # force=True, # to get a new version
32 ) 32 )
33 33
34 if is_pi: 34 if is_pi:
35 old_cmdline = host.get_fact(FindInFile, path='/boot/cmdline.txt', pattern=r'.*')[0] 35 old_cmdline = host.get_fact(FindInFile, path='/boot/cmdline.txt', pattern=r'.*')[0]
36 print(repr(old_cmdline)) 36 print(repr(old_cmdline))
67 dest=f'/etc/systemd/system/{service_name}', 67 dest=f'/etc/systemd/system/{service_name}',
68 role='server' if host.name == 'bang' else 'agent', 68 role='server' if host.name == 'bang' else 'agent',
69 ) 69 )
70 systemd.service(service=service_name, daemon_reload=True, enabled=True, restarted=True) 70 systemd.service(service=service_name, daemon_reload=True, enabled=True, restarted=True)
71 71
72 # if bang: 72 if host.name == 'bang':
73 # files.template( 73 files.put(
74 # src='templates/kube/Corefile.j2', 74 src="templates/kube/coredns.yaml",
75 # dest='/etc/k3s_coredns_config', 75 dest="/var/lib/rancher/k3s/server/manifests/coredns.yaml",
76 # ) 76 mode="600",
77 # server.shell(commands=[ 77 )
78 # 'kubectl replace configmap ' 78 # files.put(
79 # '-n kube-system ' 79 # src="templates/kube/coredns-map.yaml",
80 # 'coredns ' 80 # dest="/var/lib/rancher/k3s/server/manifests/coredns-map.yaml",
81 # '--from-file=Corefile=/etc/k3s_coredns_config ' 81 # mode="600",
82 # '-o yaml ' 82 # )
83 # '--dry-run=client | kubectl apply -', 83 # tmp = tempfile.NamedTemporaryFile(suffix='.yaml')
84 # ]) 84 # files.template(
85 # src='templates/kube/Corefile.yaml.j2',
86 # dest=tmp.name,
87 # )
88 # server.shell(commands=[
89 # 'kubectl replace configmap '
90 # # '-n kube-system '
91 # # 'coredns '
92 # f'--filename={tmp.name} '
93 # '-o yaml '
94 # # '--dry-run=client | kubectl apply -',
95 # ])
85 # one-time thing at cluster create time? not sure 96 # one-time thing at cluster create time? not sure
86 # - name: Replace https://localhost:6443 by https://master-ip:6443 97 # - name: Replace https://localhost:6443 by https://master-ip:6443
87 # command: >- 98 # command: >-
88 # k3s kubectl config set-cluster default 99 # k3s kubectl config set-cluster default
89 # --server=https://{{ master_ip }}:6443 100 # --server=https://{{ master_ip }}:6443