diff 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
line wrap: on
line diff
--- a/kube.py	Sun Apr 17 22:16:28 2022 -0700
+++ b/kube.py	Sun May 01 23:27:33 2022 -0700
@@ -28,7 +28,7 @@
         group='root',
         mode='755',
         cache_time=43000,
-       # force=True,  # to get a new version
+        # force=True,  # to get a new version
     )
 
     if is_pi:
@@ -69,19 +69,30 @@
     )
     systemd.service(service=service_name, daemon_reload=True, enabled=True, restarted=True)
 
-# if bang:
-# files.template(
-#     src='templates/kube/Corefile.j2',
-#     dest='/etc/k3s_coredns_config',
-# )
-# server.shell(commands=[
-#     'kubectl replace configmap '
-#     '-n kube-system '
-#     'coredns '
-#     '--from-file=Corefile=/etc/k3s_coredns_config '
-#     '-o yaml '
-#     '--dry-run=client | kubectl apply -',
-# ])
+if host.name == 'bang':
+    files.put(
+        src="templates/kube/coredns.yaml",
+        dest="/var/lib/rancher/k3s/server/manifests/coredns.yaml",
+        mode="600",
+    )
+    # files.put(
+    #     src="templates/kube/coredns-map.yaml",
+    #     dest="/var/lib/rancher/k3s/server/manifests/coredns-map.yaml",
+    #     mode="600",
+    # )
+    # tmp = tempfile.NamedTemporaryFile(suffix='.yaml')
+    # files.template(
+    #     src='templates/kube/Corefile.yaml.j2',
+    #     dest=tmp.name,
+    # )
+    # server.shell(commands=[
+    #     'kubectl replace configmap '
+    #     # '-n kube-system '
+    #     # 'coredns '
+    #     f'--filename={tmp.name} '
+    #     '-o yaml '
+    #     # '--dry-run=client | kubectl apply -',
+    # ])
 # one-time thing at cluster create time? not sure
 # - name: Replace https://localhost:6443 by https://master-ip:6443
 #   command: >-