From acb0bd85b7d2eb1b35351739f75907caf78b1de6 Mon Sep 17 00:00:00 2001 From: Xander Harris Date: Fri, 26 Jul 2024 16:42:36 -0700 Subject: [PATCH] Update configs Closes #13 --- roles/kv/tasks/main.yml | 21 +++------- roles/kv/templates/kube-vip.yaml | 69 ++++++++++++++++++++++++++++++++ roles/reset/tasks/main.yml | 7 ++++ roles/reset/templates/hosts | 6 +++ 4 files changed, 88 insertions(+), 15 deletions(-) create mode 100644 roles/kv/templates/kube-vip.yaml create mode 100644 roles/reset/templates/hosts diff --git a/roles/kv/tasks/main.yml b/roles/kv/tasks/main.yml index 5c0bb9e..5f8d977 100644 --- a/roles/kv/tasks/main.yml +++ b/roles/kv/tasks/main.yml @@ -22,18 +22,9 @@ group: root mode: ug+rw,o-rwx - name: Deploy the manifest - ansible.builtin.shell: - cmd: |- - source /root/.bashrc - kube-vip - kube-vip manifest pod \ - --interface "{{ kv_interface }}" \ - --address "{{ kv_aa }}" \ - --controlplane \ - --services \ - --arp \ - --leaderElection | tee /etc/kubernetes/manifests/kube-vip.yaml - register: kv_manifest -- name: Output kube-vip - ansible.builtin.debug: - var: kv_manifest + ansible.builtin.template: + src: kube-vip.yaml + dest: /etc/kubernetes/manifests/kube-vip.yaml + owner: kube + group: kube + mode: ug+rw,g-rwx diff --git a/roles/kv/templates/kube-vip.yaml b/roles/kv/templates/kube-vip.yaml new file mode 100644 index 0000000..eed21b8 --- /dev/null +++ b/roles/kv/templates/kube-vip.yaml @@ -0,0 +1,69 @@ +apiVersion: v1 +kind: Pod +metadata: + creationTimestamp: null + name: kube-vip + namespace: kube-system +spec: + containers: + - args: + - manager + env: + - name: vip_arp + value: "true" + - name: port + value: "6443" + - name: vip_nodename + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: vip_interface + value: {{ kv_interface }} + - name: vip_cidr + value: "24" + - name: dns_mode + value: first + - name: cp_enable + value: "true" + - name: cp_namespace + value: kube-system + - name: svc_enable + value: "true" + - name: svc_leasename + value: plndr-svcs-lock + - name: vip_leaderelection + value: "true" + - name: vip_leasename + value: plndr-cp-lock + - name: vip_leaseduration + value: "5" + - name: vip_renewdeadline + value: "3" + - name: vip_retryperiod + value: "1" + - name: address + value: {{ kv_aa }} + - name: prometheus_server + value: :2112 + image: ghcr.io/kube-vip/kube-vip:v0.8.2 + imagePullPolicy: IfNotPresent + name: kube-vip + resources: {} + securityContext: + capabilities: + add: + - NET_ADMIN + - NET_RAW + volumeMounts: + - mountPath: /etc/kubernetes/admin.conf + name: kubeconfig + hostAliases: + - hostnames: + - kubernetes + ip: 127.0.0.1 + hostNetwork: true + volumes: + - hostPath: + path: /etc/kubernetes/admin.conf + name: kubeconfig +status: {} diff --git a/roles/reset/tasks/main.yml b/roles/reset/tasks/main.yml index 4ac1c40..f46203f 100644 --- a/roles/reset/tasks/main.yml +++ b/roles/reset/tasks/main.yml @@ -26,6 +26,13 @@ owner: root group: root mode: u+rwx,go-rwx +- name: Template hosts file + ansible.builtin.template: + src: hosts + dest: /etc/hosts + owner: root + group: root + mode: u+rw,go+r ### # ```{rubric} Show and record output # ``` diff --git a/roles/reset/templates/hosts b/roles/reset/templates/hosts new file mode 100644 index 0000000..3aefc0b --- /dev/null +++ b/roles/reset/templates/hosts @@ -0,0 +1,6 @@ +# Static table lookup for hostnames. +# See hosts(5) for details. + +{% for host in hosts_file %} +{{ host.addr }} {{ host.name }} +{% endfor %}