From f9a7307f76ba09dccc198cf0d6251504f850d01b Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Sat, 6 Jan 2024 09:22:43 -0500 Subject: [PATCH] feat: move installing prom operator crds to taskfile Signed-off-by: Devin Buhl --- .github/renovate.json5 | 1 + .taskfiles/ClusterTasks.yaml | 35 +++++++++---------- .../group_vars/kubernetes/main.yaml.j2 | 19 +++------- .../playbooks/cluster-installation.yaml.j2 | 4 --- 4 files changed, 22 insertions(+), 37 deletions(-) diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 70bfe311..d2897040 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -224,6 +224,7 @@ "customType": "regex", "description": "Process various other dependencies", "fileMatch": [ + "(^|/).taskfiles/.+\\.ya?ml$", "(^|/)addons/.+\\.ya?ml(\\.j2)?(\\.j2)?$", "(^|/)ansible/.+\\.ya?ml(\\.j2)?(\\.j2)?$", "(^|/)kubernetes/.+\\.ya?ml(\\.j2)?(\\.j2)?$" diff --git a/.taskfiles/ClusterTasks.yaml b/.taskfiles/ClusterTasks.yaml index b9a3a19f..597bf856 100644 --- a/.taskfiles/ClusterTasks.yaml +++ b/.taskfiles/ClusterTasks.yaml @@ -1,26 +1,31 @@ --- version: "3" -tasks: +vars: + # renovate: datasource=github-releases depName=prometheus-operator/prometheus-operator + PROMETHEUS_OPERATOR_VERSION: "v0.70.0" - verify: - desc: Verify flux meets the prerequisites - cmd: flux check --pre +tasks: install: desc: Install Flux into your cluster cmds: - - kubectl apply --kustomize {{.KUBERNETES_DIR}}/bootstrap + # Install essential Prometheus Operator CRDs + - kubectl apply --server-side --filename https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/{{ .PROMETHEUS_OPERATOR_VERSION }}/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml + - kubectl apply --server-side --filename https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/{{ .PROMETHEUS_OPERATOR_VERSION }}/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml + - kubectl apply --server-side --filename https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/{{ .PROMETHEUS_OPERATOR_VERSION }}/example/prometheus-operator-crd/monitoring.coreos.com_scrapeconfigs.yaml + - kubectl apply --server-side --filename https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/{{ .PROMETHEUS_OPERATOR_VERSION }}/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml + # Install Flux + - kubectl apply --server-side --kustomize {{.KUBERNETES_DIR}}/bootstrap - cat {{.SOPS_AGE_KEY_FILE}} | kubectl -n flux-system create secret generic sops-age --from-file=age.agekey=/dev/stdin - - sops --decrypt {{.KUBERNETES_DIR}}/flux/vars/cluster-secrets.sops.yaml | kubectl apply -f - - - sops --decrypt {{.KUBERNETES_DIR}}/flux/vars/cluster-secrets-user.sops.yaml | kubectl apply -f - - - kubectl apply -f {{.KUBERNETES_DIR}}/flux/vars/cluster-settings.yaml - - kubectl apply -f {{.KUBERNETES_DIR}}/flux/vars/cluster-settings-user.yaml - - kubectl apply --kustomize {{.KUBERNETES_DIR}}/flux/config + - sops --decrypt {{.KUBERNETES_DIR}}/flux/vars/cluster-secrets.sops.yaml | kubectl apply --server-side --filename - + - sops --decrypt {{.KUBERNETES_DIR}}/flux/vars/cluster-secrets-user.sops.yaml | kubectl apply --server-side --filename - + - kubectl apply --server-side --filename {{.KUBERNETES_DIR}}/flux/vars/cluster-settings.yaml + - kubectl apply --server-side --filename {{.KUBERNETES_DIR}}/flux/vars/cluster-settings-user.yaml + - kubectl apply --server-side --kustomize {{.KUBERNETES_DIR}}/flux/config preconditions: - sh: test -f {{.SOPS_AGE_KEY_FILE}} - msg: | - Age key file is not found. Did you forget to create it? + msg: Age key file is not found. Did you forget to create it? vars: SOPS_AGE_KEY_FILE: "{{.ROOT_DIR}}/age.key" @@ -28,12 +33,6 @@ tasks: desc: Force update Flux to pull in changes from your Git repository cmd: flux reconcile -n flux-system kustomization cluster --with-source - hr-restart: - desc: Restart all failed Helm Releases - cmds: - - kubectl get hr --all-namespaces | grep False | awk '{print $2, $1}' | xargs -L1 bash -c 'flux suspend hr $0 -n $1' - - kubectl get hr --all-namespaces | grep False | awk '{print $2, $1}' | xargs -L1 bash -c 'flux resume hr $0 -n $1' - nodes: desc: List all the nodes in your cluster cmd: kubectl get nodes {{.CLI_ARGS | default "-o wide"}} diff --git a/bootstrap/templates/ansible/inventory/group_vars/kubernetes/main.yaml.j2 b/bootstrap/templates/ansible/inventory/group_vars/kubernetes/main.yaml.j2 index fe80486a..3701a004 100644 --- a/bootstrap/templates/ansible/inventory/group_vars/kubernetes/main.yaml.j2 +++ b/bootstrap/templates/ansible/inventory/group_vars/kubernetes/main.yaml.j2 @@ -15,21 +15,6 @@ k3s_etcd_datastore: true k3s_etcd_datastore: false {% endif %} k3s_registration_address: "{% raw %}{{ kube_vip_addr }}{% endraw %}" -k3s_server_manifests_urls: - {% if bootstrap_kube_vip_enabled | default(true) %} - # Kube-vip RBAC - - url: https://raw.githubusercontent.com/kube-vip/website/main/content/manifests/rbac.yaml - filename: kube-vip-rbac.yaml - {% endif %} - # Essential Prometheus Operator CRDs (the rest are installed with the kube-prometheus-stack helm release) - - url: https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.70.0/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml - filename: custom-prometheus-podmonitors.yaml - - url: https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.70.0/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml - filename: custom-prometheus-prometheusrules.yaml - - url: https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.70.0/example/prometheus-operator-crd/monitoring.coreos.com_scrapeconfigs.yaml - filename: custom-prometheus-scrapeconfigs.yaml - - url: https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.70.0/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml - filename: custom-prometheus-servicemonitors.yaml # /var/lib/rancher/k3s/server/manifests k3s_server_manifests_templates: - custom-cilium-helmchart.yaml.j2 @@ -38,6 +23,10 @@ k3s_server_manifests_templates: {% endif %} - custom-coredns-helmchart.yaml.j2 {% if bootstrap_kube_vip_enabled | default(true) %} +# /var/lib/rancher/k3s/server/manifests +k3s_server_manifests_urls: + - url: https://raw.githubusercontent.com/kube-vip/website/main/content/manifests/rbac.yaml + filename: kube-vip-rbac.yaml # /var/lib/rancher/k3s/agent/pod-manifests k3s_server_pod_manifests_templates: - kube-vip-static-pod.yaml.j2 diff --git a/bootstrap/templates/ansible/playbooks/cluster-installation.yaml.j2 b/bootstrap/templates/ansible/playbooks/cluster-installation.yaml.j2 index 3b457337..d28be378 100644 --- a/bootstrap/templates/ansible/playbooks/cluster-installation.yaml.j2 +++ b/bootstrap/templates/ansible/playbooks/cluster-installation.yaml.j2 @@ -52,10 +52,6 @@ - { name: policy, kind: CiliumL2AnnouncementPolicy } - { name: pool, kind: CiliumLoadBalancerIPPool } {% endif %} - - { name: podmonitors.monitoring.coreos.com, kind: CustomResourceDefinition } - - { name: prometheusrules.monitoring.coreos.com, kind: CustomResourceDefinition } - - { name: scrapeconfigs.monitoring.coreos.com, kind: CustomResourceDefinition } - - { name: servicemonitors.monitoring.coreos.com, kind: CustomResourceDefinition } - name: Coredns when: k3s_primary_control_node