From: Alex Date: Wed, 16 Aug 2023 23:26:53 +0000 (-0400) Subject: add install k8s installation X-Git-Url: https://git.t-ch.net/?a=commitdiff_plain;h=fbe39ea52bf2a2a57abe8de95f570e8a54bf5f35;p=malyna-ansible.git add install k8s installation --- diff --git a/install_k8s_pkgs.ansible.yaml b/install_k8s_pkgs.ansible.yaml new file mode 100644 index 0000000..8582604 --- /dev/null +++ b/install_k8s_pkgs.ansible.yaml @@ -0,0 +1,119 @@ +- name: Install k8s + hosts: malyna + vars: + ansible_become_method: doas + tasks: + - name: Enable br_netfilter kernel module + become: true + shell: + cmd: modprobe br_netfilter + + - name: Enable br_netfilter kernel module on boot + become: true + lineinfile: + path: /etc/modules-load.d/k8s.conf + line: | + #!/bin/sh + mount --make-rshared / + insertbefore: BOF + create: true + + - name: Enable ipv4 packetforwarding + become: true + shell: + cmd: sysctl net.ipv4.ip_forward=1 + + - name: Enable ipv4 packtetforwarding on boot + become: true + lineinfile: + path: /etc/sysctl.conf + line: net.ipv4.ip_forward = 1 + create: true + + - name: Update apk packages & cache + become: true + apk: + update_cache: true + name: + - cni-plugin-flannel + - cni-plugins + - flannel + - flannel-contrib-cni + - kubelet + - kubeadm + - kubectl + - containerd + - uuidgen + - nfs-utils + + - name: Make root shared mount for prometheus + become: true + shell: + cmd: mount --make-rshared / + + - name: Setup prometheus + become: true + shell: + cmd: | + echo "#!/bin/sh" > /etc/local.d/sharemetrics.start + echo "mount --make-rshared /" >> /etc/local.d/sharemetrics.start + chmod +x /etc/local.d/sharemetrics.start + + - name: Add machine-id for compatibility + become: true + shell: uuidgen > /etc/machine-id + + - name: Enable ntpd service + become: true + service: + name: ntpd + enabled: true + state: started + + - name: Enable local service + become: true + service: + name: local + enabled: true + + - name: Enable containerd service + become: true + service: + name: containerd + enabled: true + state: started + + - name: Enable kublet service + become: true + service: + name: kublet + enabled: true + state: started + + - name: Link flannel for comapatibility + become: true + shell: + cmd: ln -s /usr/libexec/cni/flannel-amd64 /usr/libexec/cni/flannel + + - name: Enable net.bridge.bridge-nf-call-iptables + become: true + shell: + cmd: sysctl net.bridge.bridge-nf-call-iptables=1 + + - name: Enable net.bridge.bridge-nf-call-iptables on startup + become: true + lineinfile: + path: /etc/sysctl.conf + line: net.bridge.bridge-nf-call-iptables = 1 + create: true + + + + + + + + + + + \ No newline at end of file diff --git a/update_system.ansible.yaml b/update_system.ansible.yaml index 415d3a0..3f46736 100644 --- a/update_system.ansible.yaml +++ b/update_system.ansible.yaml @@ -1,5 +1,3 @@ ---- - - name: Update system hosts: malyna vars: