From 7759b9270a2f4cbef8ecb1fb329750e479afc2a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Thu, 7 Jul 2022 02:21:28 +0200 Subject: [PATCH] Add option to disable kube-vip (part 2) (#386) --- .config.sample.env | 2 +- cluster/apps/kube-system/kustomization.yaml | 1 - configure | 14 +++++++++++++- .../inventory/group_vars/kubernetes/k3s.yml | 3 --- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.config.sample.env b/.config.sample.env index ee34b496..71ff16bb 100644 --- a/.config.sample.env +++ b/.config.sample.env @@ -41,7 +41,7 @@ export BOOTSTRAP_AGE_PUBLIC_KEY="" # If this is set to false (e.g. on a cluster with a single-node control plane), do not install kube-vip. # BOOTSTRAP_KUBE_VIP_ADDR needs to be set to the IP the API Server is reachable under export BOOTSTRAP_KUBE_VIP_ENABLED="true" -# The IP Address to use with KubeVIP +# The IP Address to use with kube-vip # Pick a unused IP that is on the same network as your nodes # and outside the ${BOOTSTRAP_METALLB_LB_RANGE} range # and doesn't conflict with any other IP addresses here diff --git a/cluster/apps/kube-system/kustomization.yaml b/cluster/apps/kube-system/kustomization.yaml index a20d8936..574d0d3d 100644 --- a/cluster/apps/kube-system/kustomization.yaml +++ b/cluster/apps/kube-system/kustomization.yaml @@ -4,7 +4,6 @@ kind: Kustomization resources: - namespace.yaml - cert-manager - - kube-vip # - kured - metrics-server - reflector diff --git a/configure b/configure index 5c906a32..5a2b0cdd 100755 --- a/configure +++ b/configure @@ -71,7 +71,19 @@ main() { # generate ansible settings envsubst < "${PROJECT_DIR}/tmpl/ansible/kube-vip.yml" \ > "${PROJECT_DIR}/provision/ansible/inventory/group_vars/kubernetes/kube-vip.yml" - # generate ansible hosts file and secrets + # include kube-vip if enabled + if [[ ${BOOTSTRAP_KUBE_VIP_ENABLED} == "true" ]]; then + if [[ $(yq eval --no-doc 'contains({"resources": ["kube-vip"]})' "${PROJECT_DIR}/cluster/apps/kube-system/kustomization.yaml") == false ]]; then + yq --inplace '.resources += [ "kube-vip" ]' "${PROJECT_DIR}/cluster/apps/kube-system/kustomization.yaml" + fi + if [[ $(yq eval --no-doc 'contains({"k3s_server_manifests_templates": ["kube-vip-daemonset.yaml.j2"]})' "${PROJECT_DIR}/provision/ansible/inventory/group_vars/kubernetes/k3s.yml") == false ]]; then + yq --inplace '.k3s_server_manifests_templates += [ "kube-vip-daemonset.yaml.j2" ]' "${PROJECT_DIR}/provision/ansible/inventory/group_vars/kubernetes/k3s.yml" + fi + if [[ $(yq eval --no-doc 'contains({"k3s_server_manifests_urls": [{"url": "https://kube-vip.io/manifests/rbac.yaml", "filename": "kube-vip-rbac.yaml"}]})' "${PROJECT_DIR}/provision/ansible/inventory/group_vars/kubernetes/k3s.yml") == false ]]; then + yq --inplace '.k3s_server_manifests_urls += [{"url": "https://kube-vip.io/manifests/rbac.yaml", "filename": "kube-vip-rbac.yaml"}]' "${PROJECT_DIR}/provision/ansible/inventory/group_vars/kubernetes/k3s.yml" + fi + fi + # generate ansible hosts file and secrets generate_ansible_hosts generate_ansible_host_secrets setup_github_webhook diff --git a/provision/ansible/inventory/group_vars/kubernetes/k3s.yml b/provision/ansible/inventory/group_vars/kubernetes/k3s.yml index 011bb589..0c0c4fca 100644 --- a/provision/ansible/inventory/group_vars/kubernetes/k3s.yml +++ b/provision/ansible/inventory/group_vars/kubernetes/k3s.yml @@ -30,11 +30,8 @@ k3s_registration_address: "{{ kubevip_address }}" k3s_server_manifests_urls: - url: https://docs.projectcalico.org/archive/v3.22/manifests/tigera-operator.yaml filename: tigera-operator.yaml - - url: https://kube-vip.io/manifests/rbac.yaml - filename: kube-vip-rbac.yaml # (list) A flat list of templates to deploy on the primary control plane # /var/lib/rancher/k3s/server/manifests k3s_server_manifests_templates: - "calico-installation.yaml.j2" - - "kube-vip-daemonset.yaml.j2"