Mercurial > code > home > repos > infra
diff kube.py @ 289:65e28d2e0cd8
move static templates to files/ ; use inventory tags for selecting hosts+features ; other refactors
author | drewp@bigasterisk.com |
---|---|
date | Sun, 21 Apr 2024 17:07:23 -0700 |
parents | 3af02e24eaf9 |
children | 7f0482453ead |
line wrap: on
line diff
--- a/kube.py Sun Apr 21 17:01:13 2024 -0700 +++ b/kube.py Sun Apr 21 17:07:23 2024 -0700 @@ -5,8 +5,6 @@ from pyinfra.facts.server import Arch, LinuxDistribution from pyinfra.operations import files, server, systemd -is_pi = host.get_fact(LinuxDistribution)['name'] in ['Debian', 'Raspbian GNU/Linux'] - # https://github.com/GoogleContainerTools/skaffold/releases skaffold_version = 'v2.10.1' @@ -34,21 +32,7 @@ mode='755', cache_time=1000) # one time; writes to $HOME - server.shell("skaffold config set --global insecure-registries reg:5000") - - -def pi_cgroup_setup(): - ''' - fixes this: - - Mar 29 23:47:11 ws-printer k3s[5999]: time="2024-03-29T23:47:11-07:00" level=fatal msg="failed to find memory cgroup (v2)" - ''' - return 'cmdline.txt lives on pipe now, not on the pi host' - old_cmdline = host.get_fact(FindInFile, path='/boot/cmdline.txt', pattern=r'.*')[0] - if 'cgroup' not in old_cmdline: - cmdline = old_cmdline + ' cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory' - files.line(path='/boot/cmdline.txt', line='.*', replace=cmdline) - # pi needs reboot now + server.shell(commands="skaffold config set --global insecure-registries reg:5000") def host_prep(): @@ -61,9 +45,6 @@ none, strict, loose = 0, 1, 2 server.sysctl(key='net.ipv4.conf.default.rp_filter', value=loose, persist=True) - if is_pi: - pi_cgroup_setup() - # don't try to get aufs-dkms on rpi-- https://github.com/docker/for-linux/issues/709 def podman_insecure_registry(reg): @@ -100,7 +81,7 @@ dest=f'/etc/systemd/system/{service_name}', role=role, ) - if host.name in ['bang', 'garage']: + if not host.data.get('gpu'): # no supported gpu ''' kubectl label --overwrite node bang nvidia.com/gpu.deploy.gpu-feature-discovery=false @@ -135,7 +116,6 @@ server_ip, server_node, nodes, - admin_from, # https://github.com/k3s-io/k3s/releases # 1.23.6 per https://github.com/cilium/cilium/issues/20331 k3s_version, @@ -151,7 +131,7 @@ # also note that podman dropped the default `docker.io/` prefix on image names (see https://unix.stackexchange.com/a/701785/419418) config_and_run_service(k3s_version, server_node, server_ip) - if host.name in admin_from: + if host.data.get('k8s_admin'): podman_insecure_registry(reg='reg:5000') files.directory(path='/etc/rancher/k3s') install_skaffold()