From 1c3a82e91ccd7c836af4d793ae4629123cff6d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=98eho=C5=99?= Date: Sun, 21 Apr 2024 22:08:06 +0200 Subject: [PATCH] Initial multi-cluster configuration --- .envrc | 6 +- .github/labeler.yaml | 27 +- .github/labels.yaml | 9 +- .github/renovate.json5 | 236 +------- .github/renovate/automerge.json5 | 13 + .github/renovate/clusters.json5 | 23 + .github/renovate/commit-messages.json5 | 125 +++++ .github/renovate/custom-managers.json5 | 25 + .github/renovate/groups.json5 | 26 + .github/renovate/labels.json5 | 37 ++ .github/renovate/versioning.json5 | 11 + .github/workflows/flux-diff.yaml | 46 +- .github/workflows/release.yaml | 1 - .gitignore | 1 + .sops.yaml | 11 + README.md | 516 +----------------- ansible/.ansible-lint | 9 + .../group_vars/controllers/main.yaml | 26 + .../inventory/group_vars/kubernetes/main.yaml | 23 + ansible/main/inventory/hosts.yaml | 14 + .../main/playbooks/cluster-installation.yaml | 91 +++ ansible/main/playbooks/cluster-nuke.yaml | 105 ++++ ansible/main/playbooks/cluster-prepare.yaml | 113 ++++ ansible/main/playbooks/cluster-reboot.yaml | 15 + .../playbooks/cluster-rollout-update.yaml | 70 +++ ansible/main/playbooks/tasks/cilium.yaml | 56 ++ ansible/main/playbooks/tasks/cruft.yaml | 31 ++ ansible/main/playbooks/tasks/kubeconfig.yaml | 35 ++ .../main/playbooks/tasks/version-check.yaml | 17 + .../templates/custom-cilium-helmchart.yaml | 82 +++ .../templates/custom-kube-vip-ds.yaml | 75 +++ .../templates/custom-kube-vip-rbac.yaml | 42 ++ ansible/requirements.txt | 4 + ansible/requirements.yaml | 14 + .../group_vars/controllers/main.yaml | 26 + .../inventory/group_vars/kubernetes/main.yaml | 23 + ansible/storage/inventory/hosts.yaml | 8 + .../playbooks/cluster-installation.yaml | 91 +++ ansible/storage/playbooks/cluster-nuke.yaml | 105 ++++ .../storage/playbooks/cluster-prepare.yaml | 113 ++++ ansible/storage/playbooks/cluster-reboot.yaml | 15 + .../playbooks/cluster-rollout-update.yaml | 70 +++ ansible/storage/playbooks/tasks/cilium.yaml | 56 ++ ansible/storage/playbooks/tasks/cruft.yaml | 31 ++ .../storage/playbooks/tasks/kubeconfig.yaml | 35 ++ .../playbooks/tasks/version-check.yaml | 17 + .../templates/custom-cilium-helmchart.yaml | 82 +++ .../templates/custom-kube-vip-ds.yaml | 75 +++ .../templates/custom-kube-vip-rbac.yaml | 42 ++ .../images/home-ops-kubernetes-logo.png | Bin 0 -> 18691 bytes kubernetes/github-deploy-key.sops.yaml | 28 + .../cert-manager/app/helmrelease.yaml | 35 ++ .../cert-manager/app/kustomization.yaml | 5 + .../cert-manager/issuers/issuers.yaml | 39 ++ .../cert-manager/issuers/kustomization.yaml | 6 + .../cert-manager/issuers/secret.sops.yaml | 26 + .../apps/cert-manager/cert-manager/ks.yaml | 42 ++ .../main/apps/cert-manager/kustomization.yaml | 6 + .../main/apps/cert-manager/namespace.yaml | 7 + .../main/apps/flux-system/kustomization.yaml | 6 + .../main/apps/flux-system/namespace.yaml | 7 + .../webhooks/app/github/ingress.yaml | 20 + .../webhooks/app/github/kustomization.yaml | 7 + .../webhooks/app/github/receiver.yaml | 25 + .../webhooks/app/github/secret.sops.yaml | 26 + .../webhooks/app/kustomization.yaml | 5 + .../main/apps/flux-system/webhooks/ks.yaml | 20 + .../kube-system/cilium/app/helmrelease.yaml | 136 +++++ .../kube-system/cilium/app/kustomization.yaml | 5 + .../kube-system/cilium/config/cilium-l2.yaml | 26 + .../cilium/config/kustomization.yaml | 5 + .../main/apps/kube-system/cilium/ks.yaml | 42 ++ .../kube-system/kube-vip/app/daemonset.yaml | 75 +++ .../kube-vip/app/kustomization.yaml | 6 + .../apps/kube-system/kube-vip/app/rbac.yaml | 42 ++ .../main/apps/kube-system/kube-vip/ks.yaml | 20 + .../main/apps/kube-system/kustomization.yaml | 9 + .../metrics-server/app/helmrelease.yaml | 32 ++ .../metrics-server/app/kustomization.yaml | 5 + .../apps/kube-system/metrics-server/ks.yaml | 20 + .../main/apps/kube-system/namespace.yaml | 7 + .../kube-system/reloader/app/helmrelease.yaml | 29 + .../reloader/app/kustomization.yaml | 5 + .../main/apps/kube-system/reloader/ks.yaml | 20 + .../cloudflared/app/configs/config.yaml | 10 + .../network/cloudflared/app/dnsendpoint.yaml | 10 + .../network/cloudflared/app/helmrelease.yaml | 110 ++++ .../cloudflared/app/kustomization.yaml | 13 + .../network/cloudflared/app/secret.sops.yaml | 27 + .../main/apps/network/cloudflared/ks.yaml | 22 + .../network/echo-server/app/helmrelease.yaml | 91 +++ .../echo-server/app/kustomization.yaml | 5 + .../main/apps/network/echo-server/ks.yaml | 20 + .../network/external-dns/app/helmrelease.yaml | 48 ++ .../external-dns/app/kustomization.yaml | 6 + .../network/external-dns/app/secret.sops.yaml | 26 + .../main/apps/network/external-dns/ks.yaml | 20 + .../certificates/kustomization.yaml | 5 + .../certificates/production.yaml | 14 + .../ingress-nginx/certificates/staging.yaml | 14 + .../ingress-nginx/external/helmrelease.yaml | 87 +++ .../ingress-nginx/external/kustomization.yaml | 5 + .../ingress-nginx/internal/helmrelease.yaml | 84 +++ .../ingress-nginx/internal/kustomization.yaml | 5 + .../main/apps/network/ingress-nginx/ks.yaml | 66 +++ .../network/k8s-gateway/app/helmrelease.yaml | 32 ++ .../k8s-gateway/app/kustomization.yaml | 5 + .../main/apps/network/k8s-gateway/ks.yaml | 20 + .../main/apps/network/kustomization.yaml | 10 + kubernetes/main/apps/network/namespace.yaml | 7 + .../apps/openebs-system/kustomization.yaml | 6 + .../main/apps/openebs-system/namespace.yaml | 7 + .../openebs/app/helmrelease.yaml | 36 ++ .../openebs/app/kustomization.yaml | 5 + .../main/apps/openebs-system/openebs/ks.yaml | 20 + .../system-upgrade/k3s/app/kustomization.yaml | 5 + .../apps/system-upgrade/k3s/app/plan.yaml | 50 ++ .../main/apps/system-upgrade/k3s/ks.yaml | 26 + .../apps/system-upgrade/kustomization.yaml | 7 + .../main/apps/system-upgrade/namespace.yaml | 7 + .../app/helmrelease.yaml | 101 ++++ .../app/kustomization.yaml | 8 + .../system-upgrade-controller/app/rbac.yaml | 13 + .../system-upgrade-controller/ks.yaml | 20 + .../main/bootstrap/flux/kustomization.yaml | 61 +++ kubernetes/main/flux/apps.yaml | 56 ++ kubernetes/main/flux/config/cluster.yaml | 44 ++ kubernetes/main/flux/config/flux.yaml | 88 +++ .../main/flux/config/kustomization.yaml | 6 + .../flux/repositories/git/kustomization.yaml | 4 + .../main/flux/repositories/helm/bjw-s.yaml | 10 + .../main/flux/repositories/helm/cilium.yaml | 9 + .../flux/repositories/helm/external-dns.yaml | 9 + .../flux/repositories/helm/ingress-nginx.yaml | 9 + .../main/flux/repositories/helm/jetstack.yaml | 9 + .../flux/repositories/helm/k8s-gateway.yaml | 9 + .../flux/repositories/helm/kustomization.yaml | 13 + .../repositories/helm/metrics-server.yaml | 9 + .../main/flux/repositories/helm/openebs.yaml | 9 + .../main/flux/repositories/helm/stakater.yaml | 9 + .../main/flux/repositories/kustomization.yaml | 7 + .../flux/repositories/oci/kustomization.yaml | 4 + .../main/flux/vars/cluster-secrets.sops.yaml | 30 + .../main/flux/vars/cluster-settings.yaml | 10 + kubernetes/main/flux/vars/kustomization.yaml | 5 + .../cert-manager/app/helmrelease.yaml | 35 ++ .../cert-manager/app/kustomization.yaml | 5 + .../cert-manager/issuers/issuers.yaml | 39 ++ .../cert-manager/issuers/kustomization.yaml | 6 + .../cert-manager/issuers/secret.sops.yaml | 26 + .../apps/cert-manager/cert-manager/ks.yaml | 42 ++ .../apps/cert-manager/kustomization.yaml | 6 + .../storage/apps/cert-manager/namespace.yaml | 7 + .../apps/flux-system/kustomization.yaml | 6 + .../storage/apps/flux-system/namespace.yaml | 7 + .../webhooks/app/github/ingress.yaml | 20 + .../webhooks/app/github/kustomization.yaml | 7 + .../webhooks/app/github/receiver.yaml | 25 + .../webhooks/app/github/secret.sops.yaml | 26 + .../webhooks/app/kustomization.yaml | 5 + .../storage/apps/flux-system/webhooks/ks.yaml | 20 + .../kube-system/cilium/app/helmrelease.yaml | 136 +++++ .../kube-system/cilium/app/kustomization.yaml | 5 + .../kube-system/cilium/config/cilium-l2.yaml | 26 + .../cilium/config/kustomization.yaml | 5 + .../storage/apps/kube-system/cilium/ks.yaml | 42 ++ .../kube-system/kube-vip/app/daemonset.yaml | 75 +++ .../kube-vip/app/kustomization.yaml | 6 + .../apps/kube-system/kube-vip/app/rbac.yaml | 42 ++ .../storage/apps/kube-system/kube-vip/ks.yaml | 20 + .../apps/kube-system/kustomization.yaml | 9 + .../metrics-server/app/helmrelease.yaml | 32 ++ .../metrics-server/app/kustomization.yaml | 5 + .../apps/kube-system/metrics-server/ks.yaml | 20 + .../storage/apps/kube-system/namespace.yaml | 7 + .../kube-system/reloader/app/helmrelease.yaml | 29 + .../reloader/app/kustomization.yaml | 5 + .../storage/apps/kube-system/reloader/ks.yaml | 20 + .../network/echo-server/app/helmrelease.yaml | 91 +++ .../echo-server/app/kustomization.yaml | 5 + .../storage/apps/network/echo-server/ks.yaml | 20 + .../certificates/kustomization.yaml | 5 + .../certificates/production.yaml | 14 + .../ingress-nginx/certificates/staging.yaml | 14 + .../ingress-nginx/internal/helmrelease.yaml | 84 +++ .../ingress-nginx/internal/kustomization.yaml | 5 + .../apps/network/ingress-nginx/ks.yaml | 44 ++ .../network/k8s-gateway/app/helmrelease.yaml | 32 ++ .../k8s-gateway/app/kustomization.yaml | 5 + .../storage/apps/network/k8s-gateway/ks.yaml | 20 + .../storage/apps/network/kustomization.yaml | 8 + .../storage/apps/network/namespace.yaml | 7 + .../apps/openebs-system/kustomization.yaml | 6 + .../apps/openebs-system/namespace.yaml | 7 + .../openebs/app/helmrelease.yaml | 36 ++ .../openebs/app/kustomization.yaml | 5 + .../apps/openebs-system/openebs/ks.yaml | 20 + .../system-upgrade/k3s/app/kustomization.yaml | 5 + .../apps/system-upgrade/k3s/app/plan.yaml | 50 ++ .../storage/apps/system-upgrade/k3s/ks.yaml | 26 + .../apps/system-upgrade/kustomization.yaml | 7 + .../apps/system-upgrade/namespace.yaml | 7 + .../app/helmrelease.yaml | 101 ++++ .../app/kustomization.yaml | 8 + .../system-upgrade-controller/app/rbac.yaml | 13 + .../system-upgrade-controller/ks.yaml | 20 + .../storage/bootstrap/flux/kustomization.yaml | 61 +++ kubernetes/storage/flux/apps.yaml | 56 ++ kubernetes/storage/flux/config/cluster.yaml | 44 ++ kubernetes/storage/flux/config/flux.yaml | 88 +++ .../storage/flux/config/kustomization.yaml | 6 + .../flux/repositories/git/kustomization.yaml | 4 + .../storage/flux/repositories/helm/bjw-s.yaml | 10 + .../flux/repositories/helm/cilium.yaml | 9 + .../flux/repositories/helm/external-dns.yaml | 9 + .../flux/repositories/helm/ingress-nginx.yaml | 9 + .../flux/repositories/helm/jetstack.yaml | 9 + .../flux/repositories/helm/k8s-gateway.yaml | 9 + .../flux/repositories/helm/kustomization.yaml | 13 + .../repositories/helm/metrics-server.yaml | 9 + .../flux/repositories/helm/openebs.yaml | 9 + .../flux/repositories/helm/stakater.yaml | 9 + .../flux/repositories/kustomization.yaml | 7 + .../flux/repositories/oci/kustomization.yaml | 4 + .../flux/vars/cluster-secrets.sops.yaml | 30 + .../storage/flux/vars/cluster-settings.yaml | 10 + .../storage/flux/vars/kustomization.yaml | 5 + 227 files changed, 6108 insertions(+), 734 deletions(-) create mode 100644 .github/renovate/automerge.json5 create mode 100644 .github/renovate/clusters.json5 create mode 100644 .github/renovate/commit-messages.json5 create mode 100644 .github/renovate/custom-managers.json5 create mode 100644 .github/renovate/groups.json5 create mode 100644 .github/renovate/labels.json5 create mode 100644 .github/renovate/versioning.json5 create mode 100644 .sops.yaml create mode 100644 ansible/.ansible-lint create mode 100644 ansible/main/inventory/group_vars/controllers/main.yaml create mode 100644 ansible/main/inventory/group_vars/kubernetes/main.yaml create mode 100644 ansible/main/inventory/hosts.yaml create mode 100644 ansible/main/playbooks/cluster-installation.yaml create mode 100644 ansible/main/playbooks/cluster-nuke.yaml create mode 100644 ansible/main/playbooks/cluster-prepare.yaml create mode 100644 ansible/main/playbooks/cluster-reboot.yaml create mode 100644 ansible/main/playbooks/cluster-rollout-update.yaml create mode 100644 ansible/main/playbooks/tasks/cilium.yaml create mode 100644 ansible/main/playbooks/tasks/cruft.yaml create mode 100644 ansible/main/playbooks/tasks/kubeconfig.yaml create mode 100644 ansible/main/playbooks/tasks/version-check.yaml create mode 100644 ansible/main/playbooks/templates/custom-cilium-helmchart.yaml create mode 100644 ansible/main/playbooks/templates/custom-kube-vip-ds.yaml create mode 100644 ansible/main/playbooks/templates/custom-kube-vip-rbac.yaml create mode 100644 ansible/requirements.txt create mode 100644 ansible/requirements.yaml create mode 100644 ansible/storage/inventory/group_vars/controllers/main.yaml create mode 100644 ansible/storage/inventory/group_vars/kubernetes/main.yaml create mode 100644 ansible/storage/inventory/hosts.yaml create mode 100644 ansible/storage/playbooks/cluster-installation.yaml create mode 100644 ansible/storage/playbooks/cluster-nuke.yaml create mode 100644 ansible/storage/playbooks/cluster-prepare.yaml create mode 100644 ansible/storage/playbooks/cluster-reboot.yaml create mode 100644 ansible/storage/playbooks/cluster-rollout-update.yaml create mode 100644 ansible/storage/playbooks/tasks/cilium.yaml create mode 100644 ansible/storage/playbooks/tasks/cruft.yaml create mode 100644 ansible/storage/playbooks/tasks/kubeconfig.yaml create mode 100644 ansible/storage/playbooks/tasks/version-check.yaml create mode 100644 ansible/storage/playbooks/templates/custom-cilium-helmchart.yaml create mode 100644 ansible/storage/playbooks/templates/custom-kube-vip-ds.yaml create mode 100644 ansible/storage/playbooks/templates/custom-kube-vip-rbac.yaml create mode 100644 docs/assets/images/home-ops-kubernetes-logo.png create mode 100644 kubernetes/github-deploy-key.sops.yaml create mode 100644 kubernetes/main/apps/cert-manager/cert-manager/app/helmrelease.yaml create mode 100644 kubernetes/main/apps/cert-manager/cert-manager/app/kustomization.yaml create mode 100644 kubernetes/main/apps/cert-manager/cert-manager/issuers/issuers.yaml create mode 100644 kubernetes/main/apps/cert-manager/cert-manager/issuers/kustomization.yaml create mode 100644 kubernetes/main/apps/cert-manager/cert-manager/issuers/secret.sops.yaml create mode 100644 kubernetes/main/apps/cert-manager/cert-manager/ks.yaml create mode 100644 kubernetes/main/apps/cert-manager/kustomization.yaml create mode 100644 kubernetes/main/apps/cert-manager/namespace.yaml create mode 100644 kubernetes/main/apps/flux-system/kustomization.yaml create mode 100644 kubernetes/main/apps/flux-system/namespace.yaml create mode 100644 kubernetes/main/apps/flux-system/webhooks/app/github/ingress.yaml create mode 100644 kubernetes/main/apps/flux-system/webhooks/app/github/kustomization.yaml create mode 100644 kubernetes/main/apps/flux-system/webhooks/app/github/receiver.yaml create mode 100644 kubernetes/main/apps/flux-system/webhooks/app/github/secret.sops.yaml create mode 100644 kubernetes/main/apps/flux-system/webhooks/app/kustomization.yaml create mode 100644 kubernetes/main/apps/flux-system/webhooks/ks.yaml create mode 100644 kubernetes/main/apps/kube-system/cilium/app/helmrelease.yaml create mode 100644 kubernetes/main/apps/kube-system/cilium/app/kustomization.yaml create mode 100644 kubernetes/main/apps/kube-system/cilium/config/cilium-l2.yaml create mode 100644 kubernetes/main/apps/kube-system/cilium/config/kustomization.yaml create mode 100644 kubernetes/main/apps/kube-system/cilium/ks.yaml create mode 100644 kubernetes/main/apps/kube-system/kube-vip/app/daemonset.yaml create mode 100644 kubernetes/main/apps/kube-system/kube-vip/app/kustomization.yaml create mode 100644 kubernetes/main/apps/kube-system/kube-vip/app/rbac.yaml create mode 100644 kubernetes/main/apps/kube-system/kube-vip/ks.yaml create mode 100644 kubernetes/main/apps/kube-system/kustomization.yaml create mode 100644 kubernetes/main/apps/kube-system/metrics-server/app/helmrelease.yaml create mode 100644 kubernetes/main/apps/kube-system/metrics-server/app/kustomization.yaml create mode 100644 kubernetes/main/apps/kube-system/metrics-server/ks.yaml create mode 100644 kubernetes/main/apps/kube-system/namespace.yaml create mode 100644 kubernetes/main/apps/kube-system/reloader/app/helmrelease.yaml create mode 100644 kubernetes/main/apps/kube-system/reloader/app/kustomization.yaml create mode 100644 kubernetes/main/apps/kube-system/reloader/ks.yaml create mode 100644 kubernetes/main/apps/network/cloudflared/app/configs/config.yaml create mode 100644 kubernetes/main/apps/network/cloudflared/app/dnsendpoint.yaml create mode 100644 kubernetes/main/apps/network/cloudflared/app/helmrelease.yaml create mode 100644 kubernetes/main/apps/network/cloudflared/app/kustomization.yaml create mode 100644 kubernetes/main/apps/network/cloudflared/app/secret.sops.yaml create mode 100644 kubernetes/main/apps/network/cloudflared/ks.yaml create mode 100644 kubernetes/main/apps/network/echo-server/app/helmrelease.yaml create mode 100644 kubernetes/main/apps/network/echo-server/app/kustomization.yaml create mode 100644 kubernetes/main/apps/network/echo-server/ks.yaml create mode 100644 kubernetes/main/apps/network/external-dns/app/helmrelease.yaml create mode 100644 kubernetes/main/apps/network/external-dns/app/kustomization.yaml create mode 100644 kubernetes/main/apps/network/external-dns/app/secret.sops.yaml create mode 100644 kubernetes/main/apps/network/external-dns/ks.yaml create mode 100644 kubernetes/main/apps/network/ingress-nginx/certificates/kustomization.yaml create mode 100644 kubernetes/main/apps/network/ingress-nginx/certificates/production.yaml create mode 100644 kubernetes/main/apps/network/ingress-nginx/certificates/staging.yaml create mode 100644 kubernetes/main/apps/network/ingress-nginx/external/helmrelease.yaml create mode 100644 kubernetes/main/apps/network/ingress-nginx/external/kustomization.yaml create mode 100644 kubernetes/main/apps/network/ingress-nginx/internal/helmrelease.yaml create mode 100644 kubernetes/main/apps/network/ingress-nginx/internal/kustomization.yaml create mode 100644 kubernetes/main/apps/network/ingress-nginx/ks.yaml create mode 100644 kubernetes/main/apps/network/k8s-gateway/app/helmrelease.yaml create mode 100644 kubernetes/main/apps/network/k8s-gateway/app/kustomization.yaml create mode 100644 kubernetes/main/apps/network/k8s-gateway/ks.yaml create mode 100644 kubernetes/main/apps/network/kustomization.yaml create mode 100644 kubernetes/main/apps/network/namespace.yaml create mode 100644 kubernetes/main/apps/openebs-system/kustomization.yaml create mode 100644 kubernetes/main/apps/openebs-system/namespace.yaml create mode 100644 kubernetes/main/apps/openebs-system/openebs/app/helmrelease.yaml create mode 100644 kubernetes/main/apps/openebs-system/openebs/app/kustomization.yaml create mode 100644 kubernetes/main/apps/openebs-system/openebs/ks.yaml create mode 100644 kubernetes/main/apps/system-upgrade/k3s/app/kustomization.yaml create mode 100644 kubernetes/main/apps/system-upgrade/k3s/app/plan.yaml create mode 100644 kubernetes/main/apps/system-upgrade/k3s/ks.yaml create mode 100644 kubernetes/main/apps/system-upgrade/kustomization.yaml create mode 100644 kubernetes/main/apps/system-upgrade/namespace.yaml create mode 100644 kubernetes/main/apps/system-upgrade/system-upgrade-controller/app/helmrelease.yaml create mode 100644 kubernetes/main/apps/system-upgrade/system-upgrade-controller/app/kustomization.yaml create mode 100644 kubernetes/main/apps/system-upgrade/system-upgrade-controller/app/rbac.yaml create mode 100644 kubernetes/main/apps/system-upgrade/system-upgrade-controller/ks.yaml create mode 100644 kubernetes/main/bootstrap/flux/kustomization.yaml create mode 100644 kubernetes/main/flux/apps.yaml create mode 100644 kubernetes/main/flux/config/cluster.yaml create mode 100644 kubernetes/main/flux/config/flux.yaml create mode 100644 kubernetes/main/flux/config/kustomization.yaml create mode 100644 kubernetes/main/flux/repositories/git/kustomization.yaml create mode 100644 kubernetes/main/flux/repositories/helm/bjw-s.yaml create mode 100644 kubernetes/main/flux/repositories/helm/cilium.yaml create mode 100644 kubernetes/main/flux/repositories/helm/external-dns.yaml create mode 100644 kubernetes/main/flux/repositories/helm/ingress-nginx.yaml create mode 100644 kubernetes/main/flux/repositories/helm/jetstack.yaml create mode 100644 kubernetes/main/flux/repositories/helm/k8s-gateway.yaml create mode 100644 kubernetes/main/flux/repositories/helm/kustomization.yaml create mode 100644 kubernetes/main/flux/repositories/helm/metrics-server.yaml create mode 100644 kubernetes/main/flux/repositories/helm/openebs.yaml create mode 100644 kubernetes/main/flux/repositories/helm/stakater.yaml create mode 100644 kubernetes/main/flux/repositories/kustomization.yaml create mode 100644 kubernetes/main/flux/repositories/oci/kustomization.yaml create mode 100644 kubernetes/main/flux/vars/cluster-secrets.sops.yaml create mode 100644 kubernetes/main/flux/vars/cluster-settings.yaml create mode 100644 kubernetes/main/flux/vars/kustomization.yaml create mode 100644 kubernetes/storage/apps/cert-manager/cert-manager/app/helmrelease.yaml create mode 100644 kubernetes/storage/apps/cert-manager/cert-manager/app/kustomization.yaml create mode 100644 kubernetes/storage/apps/cert-manager/cert-manager/issuers/issuers.yaml create mode 100644 kubernetes/storage/apps/cert-manager/cert-manager/issuers/kustomization.yaml create mode 100644 kubernetes/storage/apps/cert-manager/cert-manager/issuers/secret.sops.yaml create mode 100644 kubernetes/storage/apps/cert-manager/cert-manager/ks.yaml create mode 100644 kubernetes/storage/apps/cert-manager/kustomization.yaml create mode 100644 kubernetes/storage/apps/cert-manager/namespace.yaml create mode 100644 kubernetes/storage/apps/flux-system/kustomization.yaml create mode 100644 kubernetes/storage/apps/flux-system/namespace.yaml create mode 100644 kubernetes/storage/apps/flux-system/webhooks/app/github/ingress.yaml create mode 100644 kubernetes/storage/apps/flux-system/webhooks/app/github/kustomization.yaml create mode 100644 kubernetes/storage/apps/flux-system/webhooks/app/github/receiver.yaml create mode 100644 kubernetes/storage/apps/flux-system/webhooks/app/github/secret.sops.yaml create mode 100644 kubernetes/storage/apps/flux-system/webhooks/app/kustomization.yaml create mode 100644 kubernetes/storage/apps/flux-system/webhooks/ks.yaml create mode 100644 kubernetes/storage/apps/kube-system/cilium/app/helmrelease.yaml create mode 100644 kubernetes/storage/apps/kube-system/cilium/app/kustomization.yaml create mode 100644 kubernetes/storage/apps/kube-system/cilium/config/cilium-l2.yaml create mode 100644 kubernetes/storage/apps/kube-system/cilium/config/kustomization.yaml create mode 100644 kubernetes/storage/apps/kube-system/cilium/ks.yaml create mode 100644 kubernetes/storage/apps/kube-system/kube-vip/app/daemonset.yaml create mode 100644 kubernetes/storage/apps/kube-system/kube-vip/app/kustomization.yaml create mode 100644 kubernetes/storage/apps/kube-system/kube-vip/app/rbac.yaml create mode 100644 kubernetes/storage/apps/kube-system/kube-vip/ks.yaml create mode 100644 kubernetes/storage/apps/kube-system/kustomization.yaml create mode 100644 kubernetes/storage/apps/kube-system/metrics-server/app/helmrelease.yaml create mode 100644 kubernetes/storage/apps/kube-system/metrics-server/app/kustomization.yaml create mode 100644 kubernetes/storage/apps/kube-system/metrics-server/ks.yaml create mode 100644 kubernetes/storage/apps/kube-system/namespace.yaml create mode 100644 kubernetes/storage/apps/kube-system/reloader/app/helmrelease.yaml create mode 100644 kubernetes/storage/apps/kube-system/reloader/app/kustomization.yaml create mode 100644 kubernetes/storage/apps/kube-system/reloader/ks.yaml create mode 100644 kubernetes/storage/apps/network/echo-server/app/helmrelease.yaml create mode 100644 kubernetes/storage/apps/network/echo-server/app/kustomization.yaml create mode 100644 kubernetes/storage/apps/network/echo-server/ks.yaml create mode 100644 kubernetes/storage/apps/network/ingress-nginx/certificates/kustomization.yaml create mode 100644 kubernetes/storage/apps/network/ingress-nginx/certificates/production.yaml create mode 100644 kubernetes/storage/apps/network/ingress-nginx/certificates/staging.yaml create mode 100644 kubernetes/storage/apps/network/ingress-nginx/internal/helmrelease.yaml create mode 100644 kubernetes/storage/apps/network/ingress-nginx/internal/kustomization.yaml create mode 100644 kubernetes/storage/apps/network/ingress-nginx/ks.yaml create mode 100644 kubernetes/storage/apps/network/k8s-gateway/app/helmrelease.yaml create mode 100644 kubernetes/storage/apps/network/k8s-gateway/app/kustomization.yaml create mode 100644 kubernetes/storage/apps/network/k8s-gateway/ks.yaml create mode 100644 kubernetes/storage/apps/network/kustomization.yaml create mode 100644 kubernetes/storage/apps/network/namespace.yaml create mode 100644 kubernetes/storage/apps/openebs-system/kustomization.yaml create mode 100644 kubernetes/storage/apps/openebs-system/namespace.yaml create mode 100644 kubernetes/storage/apps/openebs-system/openebs/app/helmrelease.yaml create mode 100644 kubernetes/storage/apps/openebs-system/openebs/app/kustomization.yaml create mode 100644 kubernetes/storage/apps/openebs-system/openebs/ks.yaml create mode 100644 kubernetes/storage/apps/system-upgrade/k3s/app/kustomization.yaml create mode 100644 kubernetes/storage/apps/system-upgrade/k3s/app/plan.yaml create mode 100644 kubernetes/storage/apps/system-upgrade/k3s/ks.yaml create mode 100644 kubernetes/storage/apps/system-upgrade/kustomization.yaml create mode 100644 kubernetes/storage/apps/system-upgrade/namespace.yaml create mode 100644 kubernetes/storage/apps/system-upgrade/system-upgrade-controller/app/helmrelease.yaml create mode 100644 kubernetes/storage/apps/system-upgrade/system-upgrade-controller/app/kustomization.yaml create mode 100644 kubernetes/storage/apps/system-upgrade/system-upgrade-controller/app/rbac.yaml create mode 100644 kubernetes/storage/apps/system-upgrade/system-upgrade-controller/ks.yaml create mode 100644 kubernetes/storage/bootstrap/flux/kustomization.yaml create mode 100644 kubernetes/storage/flux/apps.yaml create mode 100644 kubernetes/storage/flux/config/cluster.yaml create mode 100644 kubernetes/storage/flux/config/flux.yaml create mode 100644 kubernetes/storage/flux/config/kustomization.yaml create mode 100644 kubernetes/storage/flux/repositories/git/kustomization.yaml create mode 100644 kubernetes/storage/flux/repositories/helm/bjw-s.yaml create mode 100644 kubernetes/storage/flux/repositories/helm/cilium.yaml create mode 100644 kubernetes/storage/flux/repositories/helm/external-dns.yaml create mode 100644 kubernetes/storage/flux/repositories/helm/ingress-nginx.yaml create mode 100644 kubernetes/storage/flux/repositories/helm/jetstack.yaml create mode 100644 kubernetes/storage/flux/repositories/helm/k8s-gateway.yaml create mode 100644 kubernetes/storage/flux/repositories/helm/kustomization.yaml create mode 100644 kubernetes/storage/flux/repositories/helm/metrics-server.yaml create mode 100644 kubernetes/storage/flux/repositories/helm/openebs.yaml create mode 100644 kubernetes/storage/flux/repositories/helm/stakater.yaml create mode 100644 kubernetes/storage/flux/repositories/kustomization.yaml create mode 100644 kubernetes/storage/flux/repositories/oci/kustomization.yaml create mode 100644 kubernetes/storage/flux/vars/cluster-secrets.sops.yaml create mode 100644 kubernetes/storage/flux/vars/cluster-settings.yaml create mode 100644 kubernetes/storage/flux/vars/kustomization.yaml diff --git a/.envrc b/.envrc index 23b9adce..7184eab4 100644 --- a/.envrc +++ b/.envrc @@ -1,5 +1,5 @@ #shellcheck disable=SC2148,SC2155 -export KUBECONFIG="$(expand_path ./kubeconfig)" +export KUBECONFIG="$(expand_path ./kubernetes/main/kubeconfig):$(expand_path ./kubernetes/storage/kubeconfig)" export SOPS_AGE_KEY_FILE="$(expand_path ./age.key)" # Venv PATH_add "$(expand_path ./.venv/bin)" @@ -11,8 +11,8 @@ export ANSIBLE_ROLES_PATH=$(expand_path ./.venv/galaxy/ansible_roles) export ANSIBLE_VARS_ENABLED="host_group_vars" export ANSIBLE_LOCALHOST_WARNING="False" export ANSIBLE_INVENTORY_UNPARSED_WARNING="False" -export K8S_AUTH_KUBECONFIG="$(expand_path ./kubeconfig)" +export K8S_AUTH_KUBECONFIG="$(expand_path ./kubernetes/main/kubeconfig):$(expand_path ./kubernetes/storage/kubeconfig)" # Talos -export TALOSCONFIG="$(expand_path ./kubernetes/bootstrap/talos/clusterconfig/talosconfig)" +export TALOSCONFIG="$(expand_path ./kubernetes/main/bootstrap/talos/clusterconfig/talosconfig)" # Bin PATH_add "$(expand_path ./.bin)" diff --git a/.github/labeler.yaml b/.github/labeler.yaml index f0a70f56..6813bf36 100644 --- a/.github/labeler.yaml +++ b/.github/labeler.yaml @@ -1,17 +1,34 @@ --- +# Areas area/ansible: - changed-files: - any-glob-to-any-file: ansible/**/* -area/bootstrap: +area/docs: - changed-files: - - any-glob-to-any-file: bootstrap/**/* + - any-glob-to-any-file: + - "docs/**/*" + - "README.md" area/github: - changed-files: - any-glob-to-any-file: .github/**/* area/kubernetes: - changed-files: - - any-glob-to-any-file: kubernetes/**/* + - any-glob-to-any-file: + - .sops.yaml + - kubernetes/**/* area/taskfile: - changed-files: - - any-glob-to-any-file: .taskfiles/**/* - - any-glob-to-any-file: Taskfile* + - any-glob-to-any-file: + - .taskfiles/**/* + - Taskfile* +# Clusters +cluster/main: + - changed-files: + - any-glob-to-any-file: + - "ansible/main/**/*" + - "kubernetes/main/**/*" +cluster/storage: + - changed-files: + - any-glob-to-any-file: + - "ansible/storage/**/*" + - "kubernetes/storage/**/*" diff --git a/.github/labels.yaml b/.github/labels.yaml index 88510325..cabc56b9 100644 --- a/.github/labels.yaml +++ b/.github/labels.yaml @@ -1,13 +1,13 @@ --- # Area - { name: "area/ansible", color: "0e8a16" } -- { name: "area/bootstrap", color: "0e8a16" } +- { name: "area/docs", color: "0e8a16" } - { name: "area/github", color: "0e8a16" } - { name: "area/kubernetes", color: "0e8a16" } - { name: "area/taskfile", color: "0e8a16" } -# Distro -- { name: "distro/k3s", color: "ffc300" } -- { name: "distro/talos", color: "ffc300" } +# Clusters +- { name: "cluster/main", color: "ffc300" } +- { name: "cluster/storage", color: "ffc300" } # Renovate - { name: "renovate/ansible", color: "027fa0" } - { name: "renovate/container", color: "027fa0" } @@ -15,6 +15,7 @@ - { name: "renovate/github-release", color: "027fa0" } - { name: "renovate/helm", color: "027fa0" } # Semantic Type +- { name: "type/digest", color: "ffec19" } - { name: "type/patch", color: "ffec19" } - { name: "type/minor", color: "ff9800" } - { name: "type/major", color: "f6412d" } diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 35adbef8..327099b9 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -6,251 +6,57 @@ ":disableRateLimiting", ":dependencyDashboard", ":semanticCommits", - ":automergeBranch" + ":automergeBranch", + ":timezone(Europe/Prague)", + "github>prehor/home-ops//.github/renovate/automerge.json5", + "github>prehor/home-ops//.github/renovate/clusters.json5", + "github>prehor/home-ops//.github/renovate/commit-messages.json5", + "github>prehor/home-ops//.github/renovate/custom-managers.json5", + "github>prehor/home-ops//.github/renovate/groups.json5", + "github>prehor/home-ops//.github/renovate/labels.json5", + "github>prehor/home-ops//.github/renovate/versioning.json5" ], "dependencyDashboard": true, "dependencyDashboardTitle": "Renovate Dashboard 🤖", "suppressNotifications": ["prEditedNotification", "prIgnoreNotification"], "rebaseWhen": "conflicted", - "schedule": ["on saturday"], + "schedule": ["on friday and saturday"], "flux": { "fileMatch": [ - "(^|/)ansible/.+\\.ya?ml(?:\\.j2)?$", - "(^|/)kubernetes/.+\\.ya?ml(?:\\.j2)?$" + "(^|/)ansible/.+\\.ya?ml$", + "(^|/)kubernetes/.+\\.ya?ml$" ] }, "helm-values": { "fileMatch": [ - "(^|/)ansible/.+\\.ya?ml(?:\\.j2)?$", - "(^|/)kubernetes/.+\\.ya?ml(?:\\.j2)?$" + "(^|/)ansible/.+\\.ya?ml$", + "(^|/)kubernetes/.+\\.ya?ml$" ] }, "helmfile": { "fileMatch": [ - "(^|/)helmfile\\.ya?ml(?:\\.j2)?$" + "(^|/)helmfile\\.ya?ml$" ] }, "kubernetes": { "fileMatch": [ - "(^|/)ansible/.+\\.ya?ml(?:\\.j2)?$", - "(^|/)kubernetes/.+\\.ya?ml(?:\\.j2)?$" + "(^|/)ansible/.+\\.ya?ml$", + "(^|/)kubernetes/.+\\.ya?ml$" ] }, "kustomize": { "fileMatch": [ - "(^|/)kustomization\\.ya?ml(?:\\.j2)?$" + "(^|/)kustomization\\.ya?ml$" ] }, "pip_requirements": { "fileMatch": [ - "(^|/)[\\w-]*requirements(-\\w+)?\\.(txt|pip)(?:\\.j2)?$" + "(^|/)[\\w-]*requirements(-\\w+)?\\.(txt|pip)$" ] }, "ansible-galaxy": { "fileMatch": [ - "(^|/)(galaxy|requirements)(\\.ansible)?\\.ya?ml(?:\\.j2)?$" + "(^|/)(galaxy|requirements)(\\.ansible)?\\.ya?ml$" ] - }, - // commit message topics - "commitMessageTopic": "{{depName}}", - "commitMessageExtra": "to {{newVersion}}", - "commitMessageSuffix": "", - // package rules - "packageRules": [ - // automerge - { - "description": ["Auto merge Github Actions"], - "matchManagers": ["github-actions"], - "automerge": true, - "automergeType": "branch", - "ignoreTests": true, - "matchUpdateTypes": ["minor", "patch"] - }, - // groups - { - "description": ["Flux Group"], - "groupName": "Flux", - "matchPackagePatterns": ["flux"], - "matchDatasources": ["docker", "github-tags"], - "versioning": "semver", - "group": { - "commitMessageTopic": "{{{groupName}}} group" - }, - "separateMinorPatch": true - }, - { - "description": ["System Upgrade Controller Group"], - "groupName": "System Upgrade Controller", - "matchPackagePatterns": ["system-upgrade-controller"], - "matchDatasources": ["docker", "github-releases"], - "group": { - "commitMessageTopic": "{{{groupName}}} group" - }, - "separateMinorPatch": true - }, - // custom versioning - { - "description": ["Use custom versioning for k3s"], - "matchDatasources": ["github-releases"], - "versioning": "regex:^v(?\\d+)\\.(?\\d+)\\.(?\\d+)(?\\+k.s)\\.?(?\\d+)$", - "matchPackagePatterns": ["k3s"] - }, - // commit message topics - { - "matchDatasources": ["helm"], - "commitMessageTopic": "chart {{depName}}" - }, - { - "matchDatasources": ["docker"], - "commitMessageTopic": "image {{depName}}" - }, - // commit messages - { - "matchDatasources": ["docker"], - "matchUpdateTypes": ["major"], - "commitMessagePrefix": "feat(container)!: " - }, - { - "matchDatasources": ["docker"], - "matchUpdateTypes": ["minor"], - "semanticCommitType": "feat", - "semanticCommitScope": "container" - }, - { - "matchDatasources": ["docker"], - "matchUpdateTypes": ["patch"], - "semanticCommitType": "fix", - "semanticCommitScope": "container" - }, - { - "matchDatasources": ["docker"], - "matchUpdateTypes": ["digest"], - "semanticCommitType": "chore", - "semanticCommitScope": "container" - }, - { - "matchDatasources": ["helm"], - "matchUpdateTypes": ["major"], - "commitMessagePrefix": "feat(helm)!: " - }, - { - "matchDatasources": ["helm"], - "matchUpdateTypes": ["minor"], - "semanticCommitType": "feat", - "semanticCommitScope": "helm" - }, - { - "matchDatasources": ["helm"], - "matchUpdateTypes": ["patch"], - "semanticCommitType": "fix", - "semanticCommitScope": "helm" - }, - { - "matchDatasources": ["galaxy", "galaxy-collection"], - "matchUpdateTypes": ["major"], - "commitMessagePrefix": "feat(ansible)!: " - }, - { - "matchDatasources": ["galaxy", "galaxy-collection"], - "matchUpdateTypes": ["minor"], - "semanticCommitType": "feat", - "semanticCommitScope": "ansible" - }, - { - "matchDatasources": ["galaxy", "galaxy-collection"], - "matchUpdateTypes": ["patch"], - "semanticCommitType": "fix", - "semanticCommitScope": "ansible" - }, - { - "matchDatasources": ["github-releases", "github-tags"], - "matchUpdateTypes": ["major"], - "commitMessagePrefix": "feat(github-release)!: " - }, - { - "matchDatasources": ["github-releases", "github-tags"], - "matchUpdateTypes": ["minor"], - "semanticCommitType": "feat", - "semanticCommitScope": "github-release" - }, - { - "matchDatasources": ["github-releases", "github-tags"], - "matchUpdateTypes": ["patch"], - "semanticCommitType": "fix", - "semanticCommitScope": "github-release" - }, - { - "matchManagers": ["github-actions"], - "matchUpdateTypes": ["major"], - "commitMessagePrefix": "feat(github-action)!: " - }, - { - "matchManagers": ["github-actions"], - "matchUpdateTypes": ["minor"], - "semanticCommitType": "feat", - "semanticCommitScope": "github-action" - }, - { - "matchManagers": ["github-actions"], - "matchUpdateTypes": ["patch"], - "semanticCommitType": "fix", - "semanticCommitScope": "github-action" - }, - // labels - { - "matchUpdateTypes": ["major"], - "labels": ["type/major"] - }, - { - "matchUpdateTypes": ["minor"], - "labels": ["type/minor"] - }, - { - "matchUpdateTypes": ["patch"], - "labels": ["type/patch"] - }, - { - "matchDatasources": ["docker"], - "addLabels": ["renovate/container"] - }, - { - "matchDatasources": ["helm"], - "addLabels": ["renovate/helm"] - }, - { - "matchDatasources": ["galaxy", "galaxy-collection"], - "addLabels": ["renovate/ansible"] - }, - { - "matchDatasources": ["github-releases", "github-tags"], - "addLabels": ["renovate/github-release"] - }, - { - "matchManagers": ["github-actions"], - "addLabels": ["renovate/github-action"] - } - ], - // custom managers - "customManagers": [ - { - "customType": "regex", - "description": ["Process custom dependencies"], - "fileMatch": [ - "(^|/).taskfiles/.+\\.ya?ml$", - "(^|/)ansible/.+\\.ya?ml(?:\\.j2)?$", - "(^|/)kubernetes/.+\\.ya?ml(?:\\.j2)?$" - ], - "matchStrings": [ - // # renovate: datasource=github-releases depName=k3s-io/k3s - // k3s_release_version: &version v1.29.0+k3s1 - // # renovate: datasource=helm depName=cilium repository=https://helm.cilium.io - // version: 1.15.1 - "datasource=(?\\S+) depName=(?\\S+)( repository=(?\\S+))?\\n.+: (&\\S+\\s)?(?\\S+)", - // # renovate: datasource=github-releases depName=rancher/system-upgrade-controller - // https://github.com/rancher/system-upgrade-controller/releases/download/v0.13.2/crd.yaml - "datasource=(?\\S+) depName=(?\\S+)\\n.+/(?(v|\\d)[^/]+)" - ], - "datasourceTemplate": "{{#if datasource}}{{{datasource}}}{{else}}github-releases{{/if}}" - } - ] + } } diff --git a/.github/renovate/automerge.json5 b/.github/renovate/automerge.json5 new file mode 100644 index 00000000..742919a1 --- /dev/null +++ b/.github/renovate/automerge.json5 @@ -0,0 +1,13 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "packageRules": [ + { + "description": ["Auto merge Github Actions"], + "matchManagers": ["github-actions"], + "automerge": true, + "automergeType": "branch", + "ignoreTests": true, + "matchUpdateTypes": ["minor", "patch"] + } + ] +} diff --git a/.github/renovate/clusters.json5 b/.github/renovate/clusters.json5 new file mode 100644 index 00000000..8a3845aa --- /dev/null +++ b/.github/renovate/clusters.json5 @@ -0,0 +1,23 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "packageRules": [ + { + "description": ["Separate PRs for main cluster"], + "matchFileNames": [ + "**/kubernetes/main/**", + "**/ansible/main/**", + "**/terraform/main/**" + ], + "additionalBranchPrefix": "main-" + }, + { + "description": ["Separate PRs for storage cluster"], + "matchFileNames": [ + "**/kubernetes/storage/**", + "**/ansible/storage/**", + "**/terraform/storage/**" + ], + "additionalBranchPrefix": "storage-" + } + ] +} diff --git a/.github/renovate/commit-messages.json5 b/.github/renovate/commit-messages.json5 new file mode 100644 index 00000000..30b5ce47 --- /dev/null +++ b/.github/renovate/commit-messages.json5 @@ -0,0 +1,125 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + // default commit messages + "commitMessageTopic": "{{depName}}", + // custom commit messages + "packageRules": [ + // commit message topics + { + "matchDatasources": ["helm"], + "commitMessageTopic": "chart {{depName}}" + }, + { + "matchDatasources": ["docker"], + "commitMessageTopic": "image {{depName}}" + }, + // commit messages + { + "matchDatasources": ["docker"], + "matchUpdateTypes": ["major"], + "commitMessagePrefix": "feat(container)!: ", + "commitMessageExtra": " ( {{currentVersion}} → {{newVersion}} )" + }, + { + "matchDatasources": ["docker"], + "matchUpdateTypes": ["minor"], + "semanticCommitType": "feat", + "semanticCommitScope": "container", + "commitMessageExtra": " ( {{currentVersion}} → {{newVersion}} )" + }, + { + "matchDatasources": ["docker"], + "matchUpdateTypes": ["patch"], + "semanticCommitType": "fix", + "semanticCommitScope": "container", + "commitMessageExtra": " ( {{currentVersion}} → {{newVersion}} )" + }, + { + "matchDatasources": ["docker"], + "matchUpdateTypes": ["digest"], + "semanticCommitType": "chore", + "semanticCommitScope": "container", + "commitMessageExtra": "( {{currentDigestShort}} → {{newDigestShort}} )" + }, + { + "matchDatasources": ["helm"], + "matchUpdateTypes": ["major"], + "commitMessagePrefix": "feat(helm)!: ", + "commitMessageExtra": "( {{currentVersion}} → {{newVersion}} )" + }, + { + "matchDatasources": ["helm"], + "matchUpdateTypes": ["minor"], + "semanticCommitType": "feat", + "semanticCommitScope": "helm", + "commitMessageExtra": "( {{currentVersion}} → {{newVersion}} )" + }, + { + "matchDatasources": ["helm"], + "matchUpdateTypes": ["patch"], + "semanticCommitType": "fix", + "semanticCommitScope": "helm", + "commitMessageExtra": "( {{currentVersion}} → {{newVersion}} )" + }, + { + "matchDatasources": ["galaxy", "galaxy-collection"], + "matchUpdateTypes": ["major"], + "commitMessagePrefix": "feat(ansible)!: ", + "commitMessageExtra": "( {{currentVersion}} → {{newVersion}} )" + }, + { + "matchDatasources": ["galaxy", "galaxy-collection"], + "matchUpdateTypes": ["minor"], + "semanticCommitType": "feat", + "semanticCommitScope": "ansible", + "commitMessageExtra": "( {{currentVersion}} → {{newVersion}} )" + }, + { + "matchDatasources": ["galaxy", "galaxy-collection"], + "matchUpdateTypes": ["patch"], + "semanticCommitType": "fix", + "semanticCommitScope": "ansible", + "commitMessageExtra": "( {{currentVersion}} → {{newVersion}} )" + }, + { + "matchDatasources": ["github-releases", "github-tags"], + "matchUpdateTypes": ["major"], + "commitMessagePrefix": "feat(github-release)!: ", + "commitMessageExtra": "( {{currentVersion}} → {{newVersion}} )" + }, + { + "matchDatasources": ["github-releases", "github-tags"], + "matchUpdateTypes": ["minor"], + "semanticCommitType": "feat", + "semanticCommitScope": "github-release", + "commitMessageExtra": "( {{currentVersion}} → {{newVersion}} )" + }, + { + "matchDatasources": ["github-releases", "github-tags"], + "matchUpdateTypes": ["patch"], + "semanticCommitType": "fix", + "semanticCommitScope": "github-release", + "commitMessageExtra": "( {{currentVersion}} → {{newVersion}} )" + }, + { + "matchManagers": ["github-actions"], + "matchUpdateTypes": ["major"], + "commitMessagePrefix": "feat(github-action)!: ", + "commitMessageExtra": "( {{currentVersion}} → {{newVersion}} )" + }, + { + "matchManagers": ["github-actions"], + "matchUpdateTypes": ["minor"], + "semanticCommitType": "feat", + "semanticCommitScope": "github-action", + "commitMessageExtra": "( {{currentVersion}} → {{newVersion}} )" + }, + { + "matchManagers": ["github-actions"], + "matchUpdateTypes": ["patch"], + "semanticCommitType": "fix", + "semanticCommitScope": "github-action", + "commitMessageExtra": "( {{currentVersion}} → {{newVersion}} )" + } + ] +} diff --git a/.github/renovate/custom-managers.json5 b/.github/renovate/custom-managers.json5 new file mode 100644 index 00000000..7e74c4ac --- /dev/null +++ b/.github/renovate/custom-managers.json5 @@ -0,0 +1,25 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "customManagers": [ + { + "customType": "regex", + "description": ["Process custom dependencies"], + "fileMatch": [ + "(^|/).taskfiles/.+\\.ya?ml$", + "(^|/)ansible/.+\\.ya?ml$", + "(^|/)kubernetes/.+\\.ya?ml$" + ], + "matchStrings": [ + // # renovate: datasource=github-releases depName=k3s-io/k3s + // k3s_release_version: &version v1.29.0+k3s1 + // # renovate: datasource=helm depName=cilium repository=https://helm.cilium.io + // version: 1.15.1 + "datasource=(?\\S+) depName=(?\\S+)( repository=(?\\S+))?\\n.+: (&\\S+\\s)?(?\\S+)", + // # renovate: datasource=github-releases depName=rancher/system-upgrade-controller + // https://github.com/rancher/system-upgrade-controller/releases/download/v0.13.2/crd.yaml + "datasource=(?\\S+) depName=(?\\S+)\\n.+/(?(v|\\d)[^/]+)" + ], + "datasourceTemplate": "{{#if datasource}}{{{datasource}}}{{else}}github-releases{{/if}}" + } + ] +} diff --git a/.github/renovate/groups.json5 b/.github/renovate/groups.json5 new file mode 100644 index 00000000..0fb2d464 --- /dev/null +++ b/.github/renovate/groups.json5 @@ -0,0 +1,26 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "packageRules": [ + { + "description": ["Flux Group"], + "groupName": "Flux", + "matchPackagePatterns": ["flux"], + "matchDatasources": ["docker", "github-tags"], + "versioning": "semver", + "group": { + "commitMessageTopic": "{{{groupName}}} group" + }, + "separateMinorPatch": true + }, + { + "description": ["System Upgrade Controller Group"], + "groupName": "System Upgrade Controller", + "matchPackagePatterns": ["system-upgrade-controller"], + "matchDatasources": ["docker", "github-releases"], + "group": { + "commitMessageTopic": "{{{groupName}}} group" + }, + "separateMinorPatch": true + } + ] +} diff --git a/.github/renovate/labels.json5 b/.github/renovate/labels.json5 new file mode 100644 index 00000000..494472cb --- /dev/null +++ b/.github/renovate/labels.json5 @@ -0,0 +1,37 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "packageRules": [ + { + "matchUpdateTypes": ["major"], + "labels": ["type/major"] + }, + { + "matchUpdateTypes": ["minor"], + "labels": ["type/minor"] + }, + { + "matchUpdateTypes": ["patch"], + "labels": ["type/patch"] + }, + { + "matchDatasources": ["docker"], + "addLabels": ["renovate/container"] + }, + { + "matchDatasources": ["helm"], + "addLabels": ["renovate/helm"] + }, + { + "matchDatasources": ["galaxy", "galaxy-collection"], + "addLabels": ["renovate/ansible"] + }, + { + "matchDatasources": ["github-releases", "github-tags"], + "addLabels": ["renovate/github-release"] + }, + { + "matchManagers": ["github-actions"], + "addLabels": ["renovate/github-action"] + } + ] +} diff --git a/.github/renovate/versioning.json5 b/.github/renovate/versioning.json5 new file mode 100644 index 00000000..c7cca877 --- /dev/null +++ b/.github/renovate/versioning.json5 @@ -0,0 +1,11 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "packageRules": [ + { + "description": ["Use custom versioning for k3s"], + "matchDatasources": ["github-releases"], + "versioning": "regex:^v(?\\d+)\\.(?\\d+)\\.(?\\d+)(?\\+k.s)\\.?(?\\d+)$", + "matchPackagePatterns": ["k3s"] + } + ] +} diff --git a/.github/workflows/flux-diff.yaml b/.github/workflows/flux-diff.yaml index 574d9216..6b06a757 100644 --- a/.github/workflows/flux-diff.yaml +++ b/.github/workflows/flux-diff.yaml @@ -12,16 +12,44 @@ concurrency: cancel-in-progress: true jobs: + changed-clusters: + name: Changed Clusters + runs-on: ubuntu-latest + permissions: + pull-requests: read + outputs: + matrix: "${{ steps.changed-clusters.outputs.all_changed_and_modified_files }}" + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get Changed Clusters + id: changed-clusters + uses: tj-actions/changed-files@v44 + with: + files: kubernetes/** + dir_names: true + dir_names_max_depth: 2 + matrix: true + + - name: List All Changed Clusters + run: echo "${{ steps.changed-clusters.outputs.all_changed_and_modified_files }}" + flux-diff: name: Flux Diff runs-on: ubuntu-latest + needs: ["changed-clusters"] permissions: contents: read pull-requests: write strategy: matrix: - paths: ["kubernetes"] + paths: "${{ fromJSON(needs.changed-clusters.outputs.matrix) }}" resources: ["helmrelease", "kustomization"] + max-parallel: 4 + fail-fast: false steps: - name: Checkout uses: actions/checkout@v4 @@ -51,10 +79,13 @@ jobs: - name: Generate Diff id: diff run: | - cat diff.patch echo "diff<> $GITHUB_OUTPUT cat diff.patch >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT + echo "### Diff" >> $GITHUB_STEP_SUMMARY + echo '```diff' >> $GITHUB_STEP_SUMMARY + cat diff.patch >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY - if: ${{ steps.diff.outputs.diff != '' }} name: Add comment @@ -66,3 +97,14 @@ jobs: ```diff ${{ steps.diff.outputs.diff }} ``` + + # Summarize matrix https://github.community/t/status-check-for-a-matrix-jobs/127354/7 + flux-diff-success: + if: ${{ always() }} + needs: ["flux-diff"] + name: Flux Diff Successful + runs-on: ubuntu-latest + steps: + - if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} + name: Check matrix status + run: exit 1 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ff8eabe4..fb943f8f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -9,7 +9,6 @@ on: jobs: release: - if: ${{ github.repository == 'onedr0p/cluster-template' }} name: Release runs-on: ubuntu-latest steps: diff --git a/.gitignore b/.gitignore index 4f71d416..3283bce7 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ Brewfile.lock.json wiki # Bootstrap /config.yaml +/config-*.yaml diff --git a/.sops.yaml b/.sops.yaml new file mode 100644 index 00000000..c406a450 --- /dev/null +++ b/.sops.yaml @@ -0,0 +1,11 @@ +--- +creation_rules: + - path_regex: kubernetes/.*\.sops\.ya?ml + encrypted_regex: "^(data|stringData)$" + key_groups: + - age: + - "age1ve9kzacrwq7l9l0emvs326uk6t576d75r596e083r2tq6xu28qcsacy3s7" + - path_regex: ansible/.*\.sops\.ya?ml + key_groups: + - age: + - "age1ve9kzacrwq7l9l0emvs326uk6t576d75r596e083r2tq6xu28qcsacy3s7" diff --git a/README.md b/README.md index 5d4d4006..c2926e75 100644 --- a/README.md +++ b/README.md @@ -1,516 +1,24 @@ -# ⛵ Cluster Template - -Welcome to my opinionated and extensible template for deploying a single Kubernetes cluster. The goal of this project is to make it easier for people interested in using Kubernetes to deploy a cluster at home on bare-metal or VMs. - -At a high level this project makes use of [makejinja](https://github.com/mirkolenz/makejinja) to read in a [configuration file](./config.sample.yaml) which renders out templates that will allow you to install and manage your Kubernetes cluster with. - -## ✨ Features - -The features included will depend on the type of configuration you want to use. There are currently **2 different types** of **configurations** available with this template. - -1. **"Flux cluster"** - a Kubernetes distribution of your choosing: [k3s](https://github.com/k3s-io/k3s) or [Talos](https://github.com/siderolabs/talos). Deploys an opinionated implementation of [Flux](https://github.com/fluxcd/flux2) using [GitHub](https://github.com/) as the Git provider and [sops](https://github.com/getsops/sops) to manage secrets. - - - **Required:** Debian 12 or Talos Linux installed on bare metal (or VMs) and some knowledge of [Containers](https://opencontainers.org/) and [YAML](https://yaml.org/). Some knowledge of [Git](https://git-scm.com/) practices & terminology is also required. - - **Components:** [Cilium](https://github.com/cilium/cilium) and [kube-vip](https://github.com/kube-vip/kube-vip) _(k3s)_. [flux](https://github.com/fluxcd/flux2), [cert-manager](https://github.com/cert-manager/cert-manager), [spegel](https://github.com/spegel-org/spegel), [reloader](https://github.com/stakater/Reloader), [system-upgrade-controller](https://github.com/rancher/system-upgrade-controller) _(k3s)_, and [openebs](https://github.com/openebs/openebs). - -3. **"Flux cluster with Cloudflare"** - An addition to "**Flux cluster**" that provides DNS and SSL with [Cloudflare](https://www.cloudflare.com/). [Cloudflare Tunnel](https://www.cloudflare.com/products/tunnel/) is also included to provide external access to certain applications deployed in your cluster. - - - **Required:** A Cloudflare account with a domain managed in your Cloudflare account. - - **Components:** [ingress-nginx](https://github.com/kubernetes/ingress-nginx/), [external-dns](https://github.com/kubernetes-sigs/external-dns) and [cloudflared](https://github.com/cloudflare/cloudflared). - -**Other features include:** - -- A [Renovate](https://www.mend.io/renovate)-ready repository with pull request diffs provided by [flux-local](https://github.com/allenporter/flux-local) -- Integrated [GitHub Actions](https://github.com/features/actions) with helpful workflows. - -## 💻 Machine Preparation - -Hopefully some of this peeked your interests! If you are marching forward, now is a good time to choose whether you will deploy a Kubernetes cluster with [k3s](https://github.com/k3s-io/k3s) or [Talos](https://github.com/siderolabs/talos). - -### System requirements - -> [!NOTE] -> 1. The included behaviour of Talos or k3s is that all nodes are able to run workloads, **including** the controller nodes. **Worker nodes** are therefore **optional**. -> 2. Do you have 3 or more nodes? It is highly recommended to make 3 of them controller nodes for a highly available control plane. -> 3. Running the cluster on Proxmox VE? My thoughts and recommendations about that are documented [here](https://onedr0p.github.io/home-ops/notes/proxmox-considerations.html). - -| Role | Cores | Memory | System Disk | -|---------|----------|---------------|---------------------------| -| Control | 4 _(6*)_ | 8GB _(24GB*)_ | 100GB _(500GB*)_ SSD/NVMe | -| Worker | 4 _(6*)_ | 8GB _(24GB*)_ | 100GB _(500GB*)_ SSD/NVMe | -| _\* recommended_ | - -### Talos - -1. Download the latest stable release of Talos from their [GitHub releases](https://github.com/siderolabs/talos/releases). You will want to grab either `metal-amd64.iso` or `metal-rpi_generic-arm64.raw.xz` depending on your system. - -2. Take note of the OS drive serial numbers you will need them later on. - -3. Flash the iso or raw file to a USB drive and boot to Talos on your nodes with it. - -4. Continue on to 🚀 [**Getting Started**](#-getting-started) - -### k3s (AMD64) - -1. Download the latest stable release of Debian from [here](https://cdimage.debian.org/debian-cd/current/amd64/iso-dvd), then follow [this guide](https://www.linuxtechi.com/how-to-install-debian-12-step-by-step) to get it installed. Deviations from the guide: - - ```txt - Choose "Guided - use entire disk" - Choose "All files in one partition" - Delete Swap partition - Uncheck all Debian desktop environment options - ``` - -2. [Post install] Remove CD/DVD as apt source - - ```sh - su - - sed -i '/deb cdrom/d' /etc/apt/sources.list - apt update - exit - ``` - -3. [Post install] Enable sudo for your non-root user - - ```sh - su - - apt update - apt install -y sudo - usermod -aG sudo ${username} - echo "${username} ALL=(ALL) NOPASSWD:ALL" | tee /etc/sudoers.d/${username} - exit - newgrp sudo - sudo apt update - ``` - -4. [Post install] Add SSH keys (or use `ssh-copy-id` on the client that is connecting) - - 📍 _First make sure your ssh keys are up-to-date and added to your github account as [instructed](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account)._ - - ```sh - mkdir -m 700 ~/.ssh - sudo apt install -y curl - curl https://github.com/${github_username}.keys > ~/.ssh/authorized_keys - chmod 600 ~/.ssh/authorized_keys - ``` - -### k3s (RasPi4) - -
-Click here to read about using a RasPi4 - - -> [!NOTE] -> 1. It is recommended to have an 8GB RasPi model. Most important is to **boot from an external SSD/NVMe** rather than an SD card. This is [supported natively](https://www.raspberrypi.com/documentation/computers/raspberry-pi.html), however if you have an early model you may need to [update the bootloader](https://www.tomshardware.com/how-to/boot-raspberry-pi-4-usb) first. -> 2. Check the [power requirements](https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#power-supply) if using a PoE Hat and a SSD/NVMe dongle. - -1. Download the latest stable release of Debian from [here](https://raspi.debian.net/tested-images). _**Do not** use Raspbian or DietPi or any other flavor Linux OS._ - -2. Flash the image onto an SSD/NVMe drive. - -3. Re-mount the drive to your workstation and then do the following (per the [official documentation](https://raspi.debian.net/defaults-and-settings)): - - ```txt - Open 'sysconf.txt' in a text editor and save it upon updating the information below - - Change 'root_authorized_key' to your desired public SSH key - - Change 'root_pw' to your desired root password - - Change 'hostname' to your desired hostname - ``` - -4. Connect SSD/NVMe drive to the Raspberry Pi 4 and power it on. - -5. [Post install] SSH into the device with the `root` user and then create a normal user account with `adduser ${username}` - -6. [Post install] Follow steps 3 and 4 from [k3s (AMD64)](##k3s-amd64). - -7. [Post install] Install `python3` which is needed by Ansible. - - ```sh - sudo apt install -y python3 - ``` - -8. Continue on to 🚀 [**Getting Started**](#-getting-started) - -
- -## 🚀 Getting Started - -Once you have installed Talos or Debian on your nodes, there are six stages to getting a Flux-managed cluster up and runnning. - -> [!NOTE] -> For all stages below the commands **MUST** be ran on your personal workstation within your repository directory - -### 🎉 Stage 1: Create a Git repository - -1. Create a new **public** repository by clicking the big green "Use this template" button at the top of this page. - -2. Clone **your new repo** to you local workstation and `cd` into it. - -3. Continue on to 🌱 [**Stage 2**](#-stage-2-setup-your-local-workstation-environment) - -### 🌱 Stage 2: Setup your local workstation - -You have two different options for setting up your local workstation. - -- First option is using a `devcontainer` which requires you to have Docker and VSCode installed. This method is the fastest to get going because all the required CLI tools are provided for you in my [devcontainer](https://github.com/onedr0p/cluster-template/pkgs/container/cluster-template%2Fdevcontainer) image. -- The second option is setting up the CLI tools directly on your workstation. - -#### Devcontainer method - -1. Start Docker and open your repository in VSCode. There will be a pop-up asking you to use the `devcontainer`, click the button to start using it. - -2. Continue on to 🔧 [**Stage 3**](#-stage-3-bootstrap-configuration) - -#### Non-devcontainer method - -1. Install the most recent version of [task](https://taskfile.dev/), see the [installation docs](https://taskfile.dev/installation/) for other supported platforms. - - ```sh - # Homebrew - brew install go-task - # or, Arch - pacman -S --noconfirm go-task && ln -sf /usr/bin/go-task /usr/local/bin/task - ``` - -2. Install the most recent version of [direnv](https://direnv.net/), see the [installation docs](https://direnv.net/docs/installation.html) for other supported platforms. - - ```sh - # Homebrew - brew install direnv - # or, Arch - pacman -S --noconfirm direnv - ``` - - 📍 _After `direnv` is installed be sure to **[hook it into your preferred shell](https://direnv.net/docs/hook.html)** and then run `task workstation:direnv`_ - -3. Install the additional **required** CLI tools - - 📍 _**Not using Homebrew or ArchLinux?** Try using the generic Linux task below, if that fails check out the [Brewfile](.taskfiles/Workstation/Brewfile)/[Archfile](.taskfiles/Workstation/Archfile) for what CLI tools needed and install them._ - - ```sh - # Homebrew - task workstation:brew - # or, Arch with yay/paru - task workstation:arch - # or, Generic Linux (YMMV, this pulls binaires in to ./bin) - task workstation:generic-linux - ``` - -4. Setup a Python virual environment by running the following task command. - - 📍 _This commands requires Python 3.11+ to be installed._ - - ```sh - task workstation:venv - ``` - -5. Continue on to 🔧 [**Stage 3**](#-stage-3-bootstrap-configuration) - -### 🔧 Stage 3: Bootstrap configuration - -> [!NOTE] -> The [config.sample.yaml](./config.sample.yaml) file contains config that is **vital** to the bootstrap process. - -1. Generate the `config.yaml` from the [config.sample.yaml](./config.sample.yaml) configuration file. - - ```sh - task init - ``` - -2. Fill out the `config.yaml` configuration file using the comments in that file as a guide. - -3. Run the following command which will generate all the files needed to continue. - - ```sh - task configure - ``` - -4. Push you changes to git - - 📍 _**Verify** all the `./kubernetes/**/*.sops.*` files are **encrypted** with SOPS_ - - ```sh - git add -A - git commit -m "Initial commit :rocket:" - git push - ``` - -5. Continue on to ⚡ [**Stage 4**](#-stage-4-prepare-your-nodes-for-kubernetes) - -### ⚡ Stage 4: Prepare your nodes for Kubernetes - -> [!NOTE] -> For **Talos** skip ahead to ⛵ [**Stage 5**](#-stage-5-install-kubernetes) - -#### k3s - -📍 _Here we will be running an Ansible playbook to prepare your nodes for running a Kubernetes cluster._ - -1. Ensure you are able to SSH into your nodes from your workstation using a private SSH key **without a passphrase** (for example using a SSH agent). This lets Ansible interact with your nodes. - -3. Install the Ansible dependencies - - ```sh - task ansible:deps - ``` - -4. Verify Ansible can view your config and ping your nodes - - ```sh - task ansible:list - task ansible:ping - ``` - -5. Run the Ansible prepare playbook (nodes wil reboot when done) - - ```sh - task ansible:run playbook=cluster-prepare - ``` - -6. Continue on to ⛵ [**Stage 5**](#-stage-5-install-kubernetes) - -### ⛵ Stage 5: Install Kubernetes - -#### Talos - -1. Deploy your cluster and bootstrap it. This generates secrets, generates the config files for your nodes and applies them. It bootstraps the cluster afterwards, fetches the kubeconfig file and installs Cilium and kubelet-csr-approver. It finishes with some health checks. - - ```sh - task talos:bootstrap - ``` - -#### k3s - -1. Install Kubernetes depending on the distribution you chose - - ```sh - task ansible:run playbook=cluster-installation - ``` - -#### Cluster validation - -1. The `kubeconfig` for interacting with your cluster should have been created in the root of your repository. - -2. Verify the nodes are online - - 📍 _If this command **fails** you likely haven't configured `direnv` as mentioned previously in the guide._ - - ```sh - kubectl get nodes -o wide - # NAME STATUS ROLES AGE VERSION - # k8s-0 Ready control-plane,etcd,master 1h v1.29.1 - # k8s-1 Ready worker 1h v1.29.1 - ``` - -3. Continue on to 🔹 [**Stage 6**](#-stage-6-install-flux-in-your-cluster) - -### 🔹 Stage 6: Install Flux in your cluster - -1. Verify Flux can be installed - - ```sh - flux check --pre - # ► checking prerequisites - # ✔ kubectl 1.27.3 >=1.18.0-0 - # ✔ Kubernetes 1.27.3+k3s1 >=1.16.0-0 - # ✔ prerequisites checks passed - ``` - -2. Install Flux and sync the cluster to the Git repository - - 📍 _Run `task flux:github-deploy-key` first if using a private repository._ - - ```sh - task flux:bootstrap - # namespace/flux-system configured - # customresourcedefinition.apiextensions.k8s.io/alerts.notification.toolkit.fluxcd.io created - # ... - ``` - -1. Verify Flux components are running in the cluster - - ```sh - kubectl -n flux-system get pods -o wide - # NAME READY STATUS RESTARTS AGE - # helm-controller-5bbd94c75-89sb4 1/1 Running 0 1h - # kustomize-controller-7b67b6b77d-nqc67 1/1 Running 0 1h - # notification-controller-7c46575844-k4bvr 1/1 Running 0 1h - # source-controller-7d6875bcb4-zqw9f 1/1 Running 0 1h - ``` - -### 🎤 Verification Steps - -_Mic check, 1, 2_ - In a few moments applications should be lighting up like Christmas in July 🎄 - -1. Output all the common resources in your cluster. - - 📍 _Feel free to use the provided [kubernetes tasks](.taskfiles/Kubernetes/Taskfile.yaml) for validation of cluster resources or continue to get familiar with the `kubectl` and `flux` CLI tools._ - - ```sh - task kubernetes:resources - ``` - -2. ⚠️ It might take `cert-manager` awhile to generate certificates, this is normal so be patient. - -3. 🏆 **Congratulations** if all goes smooth you will have a Kubernetes cluster managed by Flux and your Git repository is driving the state of your cluster. - -4. 🧠 Now it's time to pause and go get some motel motor oil ☕ and admire you made it this far! - -## 📣 Flux w/ Cloudflare post installation - -#### 🌐 Public DNS - -The `external-dns` application created in the `networking` namespace will handle creating public DNS records. By default, `echo-server` and the `flux-webhook` are the only subdomains reachable from the public internet. In order to make additional applications public you must set set the correct ingress class name and ingress annotations like in the HelmRelease for `echo-server`. - -#### 🏠 Home DNS - -`k8s_gateway` will provide DNS resolution to external Kubernetes resources (i.e. points of entry to the cluster) from any device that uses your home DNS server. For this to work, your home DNS server must be configured to forward DNS queries for `${bootstrap_cloudflare.domain}` to `${bootstrap_cloudflare.gateway_vip}` instead of the upstream DNS server(s) it normally uses. This is a form of **split DNS** (aka split-horizon DNS / conditional forwarding). - -> [!TIP] -> Below is how to configure a Pi-hole for split DNS. Other platforms should be similar. -> 1. Apply this file on the Pihole server while substituting the variables -> ```sh -> # /etc/dnsmasq.d/99-k8s-gateway-forward.conf -> server=/${bootstrap_cloudflare.domain}/${bootstrap_cloudflare.gateway_vip} -> ``` -> 2. Restart dnsmasq on the server. -> 3. Query an internal-only subdomain from your workstation (any `internal` class ingresses): `dig @${home-dns-server-ip} echo-server-internal.${bootstrap_cloudflare.domain}`. It should resolve to `${bootstrap_cloudflare.ingress_vip}`. - -If you're having trouble with DNS be sure to check out these two GitHub discussions: [Internal DNS](https://github.com/onedr0p/cluster-template/discussions/719) and [Pod DNS resolution broken](https://github.com/onedr0p/cluster-template/discussions/635). - -... Nothing working? That is expected, this is DNS after all! - -#### 📜 Certificates - -By default this template will deploy a wildcard certificate using the Let's Encrypt **staging environment**, which prevents you from getting rate-limited by the Let's Encrypt production servers if your cluster doesn't deploy properly (for example due to a misconfiguration). Once you are sure you will keep the cluster up for more than a few hours be sure to switch to the production servers as outlined in `config.yaml`. - -📍 _You will need a production certificate to reach internet-exposed applications through `cloudflared`._ - -#### 🪝 Github Webhook - -By default Flux will periodically check your git repository for changes. In order to have Flux reconcile on `git push` you must configure Github to send `push` events to Flux. - -> [!NOTE] -> This will only work after you have switched over certificates to the Let's Encrypt Production servers. - -1. Obtain the webhook path - - 📍 _Hook id and path should look like `/hook/12ebd1e363c641dc3c2e430ecf3cee2b3c7a5ac9e1234506f6f5f3ce1230e123`_ - - ```sh - kubectl -n flux-system get receiver github-receiver -o jsonpath='{.status.webhookPath}' - ``` - -2. Piece together the full URL with the webhook path appended - - ```text - https://flux-webhook.${bootstrap_cloudflare.domain}/hook/12ebd1e363c641dc3c2e430ecf3cee2b3c7a5ac9e1234506f6f5f3ce1230e123 - ``` - -3. Navigate to the settings of your repository on Github, under "Settings/Webhooks" press the "Add webhook" button. Fill in the webhook url and your `bootstrap_github_webhook_token` secret and save. - -## 💥 Nuke - -There might be a situation where you want to destroy your Kubernetes cluster. This will completely clean the OS of all traces of the Kubernetes distribution you chose and then reboot the nodes. - -```sh -# k3s: Remove all traces of k3s from the nodes -task ansible:run playbook=cluster-nuke -# Talos: Reset your nodes back to maintenance mode and reboot -task talos:soft-nuke -# Talos: Comletely format your the Talos installation and reboot -task talos:hard-nuke -``` - -## 🤖 Renovate - -[Renovate](https://www.mend.io/renovate) is a tool that automates dependency management. It is designed to scan your repository around the clock and open PRs for out-of-date dependencies it finds. Common dependencies it can discover are Helm charts, container images, GitHub Actions, Ansible roles... even Flux itself! Merging a PR will cause Flux to apply the update to your cluster. - -To enable Renovate, click the 'Configure' button over at their [Github app page](https://github.com/apps/renovate) and select your repository. Renovate creates a "Dependency Dashboard" as an issue in your repository, giving an overview of the status of all updates. The dashboard has interactive checkboxes that let you do things like advance scheduling or reattempt update PRs you closed without merging. - -The base Renovate configuration in your repository can be viewed at [.github/renovate.json5](./.github/renovate.json5). By default it is scheduled to be active with PRs every weekend, but you can [change the schedule to anything you want](https://docs.renovatebot.com/presets-schedule), or remove it if you want Renovate to open PRs right away. - -## 🐛 Debugging - -Below is a general guide on trying to debug an issue with an resource or application. For example, if a workload/resource is not showing up or a pod has started but in a `CrashLoopBackOff` or `Pending` state. - -1. Start by checking all Flux Kustomizations & Git Repository & OCI Repository and verify they are healthy. - - ```sh - flux get sources oci -A - flux get sources git -A - flux get ks -A - ``` - -2. Then check all the Flux Helm Releases and verify they are healthy. - - ```sh - flux get hr -A - ``` - -3. Then check the if the pod is present. - - ```sh - kubectl -n get pods -o wide - ``` - -4. Then check the logs of the pod if its there. - - ```sh - kubectl -n logs -f - # or - stern -n - ``` - -5. If a resource exists try to describe it to see what problems it might have. - - ```sh - kubectl -n describe - ``` - -6. Check the namespace events - - ```sh - kubectl -n get events --sort-by='.metadata.creationTimestamp' - ``` - -Resolving problems that you have could take some tweaking of your YAML manifests in order to get things working, other times it could be a external factor like permissions on NFS. If you are unable to figure out your problem see the help section below. - -## 👉 Help - -- Make a post in this repository's Github [Discussions](https://github.com/onedr0p/cluster-template/discussions). -- Start a thread in the `#support` or `#cluster-template` channels in the [Home Operations](https://discord.gg/home-operations) Discord server. - -## ❔ What's next - -The cluster is your oyster (or something like that). Below are some optional considerations you might want to review. +
-#### Ship it + -To browse or get ideas on applications people are running, community member [@whazor](https://github.com/whazor) created [Kubesearch](https://kubesearch.dev) as a creative way to search Flux HelmReleases across Github and Gitlab. +### My Home Operations Repository :octocat: -#### Storage +_... managed with Flux, Renovate, and GitHub Actions_ 🤖 -The included CSI (openebs in local-hostpath mode) is a great start for storage but soon you might find you need more features like replicated block storage, or to connect to a NFS/SMB/iSCSI server. If you need any of those features be sure to check out the projects like [rook-ceph](https://github.com/rook/rook), [longhorn](https://github.com/longhorn/longhorn), [openebs](https://github.com/openebs/openebs), [democratic-csi](https://github.com/democratic-csi/democratic-csi), [csi-driver-nfs](https://github.com/kubernetes-csi/csi-driver-nfs), -and [synology-csi](https://github.com/SynologyOpenSource/synology-csi). +
-## 🙌 Related Projects +--- -If this repo is too hot to handle or too cold to hold check out these following projects. +## Overview -- [khuedoan/homelab](https://github.com/khuedoan/homelab) - _Modern self-hosting framework, fully automated from empty disk to operating services with a single command._ -- [danmanners/aws-argo-cluster-template](https://github.com/danmanners/aws-argo-cluster-template) - _A community opinionated template for deploying Kubernetes clusters on-prem and in AWS using Pulumi, SOPS, Sealed Secrets, GitHub Actions, Renovate, Cilium and more!_ -- [ricsanfre/pi-cluster](https://github.com/ricsanfre/pi-cluster) - _Pi Kubernetes Cluster. Homelab kubernetes cluster automated with Ansible and ArgoCD_ -- [techno-tim/k3s-ansible](https://github.com/techno-tim/k3s-ansible) - _The easiest way to bootstrap a self-hosted High Availability Kubernetes cluster. A fully automated HA k3s etcd install with kube-vip, MetalLB, and more_ +This is a repository for my home infrastructure and Kubernetes cluster. I try to adhere to Infrastructure as Code (IaC) and GitOps practices using tools like [Ansible](https://www.ansible.com/), [Terraform](https://www.terraform.io/), [Kubernetes](https://kubernetes.io/), [Flux](https://github.com/fluxcd/flux2), [Renovate](https://github.com/renovatebot/renovate), and [GitHub Actions](https://github.com/features/actions). -## ⭐ Stargazers +--- -
+## Thanks -[![Star History Chart](https://api.star-history.com/svg?repos=onedr0p/cluster-template&type=Date)](https://star-history.com/#onedr0p/cluster-template&Date) - -
+Special thanks to Devin (@onedr0p) whose [onedr0p/cluster-template](https://github.com/onedr0p/cluster-template) and [onedr0p/home-ops](https://github.com/onedr0p/home-ops) I used as a starting point. -## 🤝 Thanks +Thanks to all the people who donate their time to the [Kubernetes @Home](https://discord.gg/k8s-at-home) Discord community. A lot of inspiration for my cluster comes from the people that have shared their clusters using the [k8s-at-home](https://github.com/topics/k8s-at-home) GitHub topic. Be sure to check out the [Kubernetes @Home search](https://nanne.dev/k8s-at-home-search/) for ideas on how to deploy applications or get ideas on what you can deploy. -Big shout out to all the contributors, sponsors and everyone else who has helped on this project. diff --git a/ansible/.ansible-lint b/ansible/.ansible-lint new file mode 100644 index 00000000..36f6b441 --- /dev/null +++ b/ansible/.ansible-lint @@ -0,0 +1,9 @@ +skip_list: + - yaml[commas] + - yaml[line-length] + - var-naming +warn_list: + - command-instead-of-shell + - deprecated-command-syntax + - experimental + - no-changed-when diff --git a/ansible/main/inventory/group_vars/controllers/main.yaml b/ansible/main/inventory/group_vars/controllers/main.yaml new file mode 100644 index 00000000..04f4a7e4 --- /dev/null +++ b/ansible/main/inventory/group_vars/controllers/main.yaml @@ -0,0 +1,26 @@ +--- +k3s_control_node: true +k3s_server: + cluster-cidr: "10.40.0.0/16" + service-cidr: "10.41.0.0/16" + disable: ["flannel", "local-storage", "metrics-server", "servicelb", "traefik"] + disable-cloud-controller: true + disable-kube-proxy: true + disable-network-policy: true + docker: false + embedded-registry: true + etcd-expose-metrics: true + flannel-backend: "none" + kube-apiserver-arg: + - "anonymous-auth=true" + kube-controller-manager-arg: + - "bind-address=0.0.0.0" + kube-scheduler-arg: + - "bind-address=0.0.0.0" + node-ip: "{{ ansible_host }}" + secrets-encryption: true + tls-san: + - "192.168.1.40" + - "home-ops" + - "home-ops.rx.cz" + write-kubeconfig-mode: "644" diff --git a/ansible/main/inventory/group_vars/kubernetes/main.yaml b/ansible/main/inventory/group_vars/kubernetes/main.yaml new file mode 100644 index 00000000..e37bcc95 --- /dev/null +++ b/ansible/main/inventory/group_vars/kubernetes/main.yaml @@ -0,0 +1,23 @@ +--- +k3s_become: true +k3s_etcd_datastore: true +k3s_install_hard_links: true +k3s_registration_address: "192.168.1.40" +k3s_registries: + mirrors: + docker.io: + gcr.io: + ghcr.io: + k8s.gcr.io: + lscr.io: + mcr.microsoft.com: + public.ecr.aws: + quay.io: + registry.k8s.io: +# renovate: datasource=github-releases depName=k3s-io/k3s +k3s_release_version: v1.29.3+k3s1 +k3s_server_manifests_templates: + - custom-cilium-helmchart.yaml + - custom-kube-vip-ds.yaml + - custom-kube-vip-rbac.yaml +k3s_use_unsupported_config: true diff --git a/ansible/main/inventory/hosts.yaml b/ansible/main/inventory/hosts.yaml new file mode 100644 index 00000000..f9795ae4 --- /dev/null +++ b/ansible/main/inventory/hosts.yaml @@ -0,0 +1,14 @@ +--- +kubernetes: + children: + controllers: + hosts: + "k1": + ansible_user: "home-ops" + ansible_host: "192.168.1.41" + "k2": + ansible_user: "home-ops" + ansible_host: "192.168.1.42" + "k3": + ansible_user: "home-ops" + ansible_host: "192.168.1.43" diff --git a/ansible/main/playbooks/cluster-installation.yaml b/ansible/main/playbooks/cluster-installation.yaml new file mode 100644 index 00000000..507b7b29 --- /dev/null +++ b/ansible/main/playbooks/cluster-installation.yaml @@ -0,0 +1,91 @@ +--- +- name: Cluster Installation + hosts: kubernetes + become: true + gather_facts: true + any_errors_fatal: true + pre_tasks: + - name: Pausing for 5 seconds... + ansible.builtin.pause: + seconds: 5 + tasks: + - name: Check if cluster is installed + check_mode: false + ansible.builtin.stat: + path: /etc/rancher/k3s/config.yaml + register: k3s_installed + + - name: Ignore manifests templates and urls if the cluster is already installed + when: k3s_installed.stat.exists + ansible.builtin.set_fact: + k3s_server_manifests_templates: [] + k3s_server_manifests_urls: [] + + - name: Prevent downgrades + when: k3s_installed.stat.exists + ansible.builtin.include_tasks: tasks/version-check.yaml + + - name: Ensure that the /opt/cni directory exists + ansible.builtin.file: + path: /opt/cni + mode: '755' + state: directory + - name: Ensure that the /opt/cni/bin is a link to /var/lib/rancher/k3s/data/current/bin + ansible.builtin.file: + src: /var/lib/rancher/k3s/data/current/bin + dest: /opt/cni/bin + follow: false + force: true + state: link + + - name: Ensure that the /etc/cni directory exists + ansible.builtin.file: + path: /etc/cni + mode: '755' + state: directory + - name: Ensure that the /var/lib/rancher/k3s/agent/etc/cni/net.d directory exists + ansible.builtin.file: + path: /var/lib/rancher/k3s/agent/etc/cni/net.d + mode: '755' + state: directory + - name: Ensure that the /etc/cni/net.d is a link to /var/lib/rancher/k3s/agent/etc/cni/net.d + ansible.builtin.file: + src: /var/lib/rancher/k3s/agent/etc/cni/net.d + dest: /etc/cni/net.d + force: true + state: link + + - name: Install Kubernetes + ansible.builtin.include_role: + name: xanmanning.k3s + public: true + vars: + k3s_state: installed + + - name: Kubeconfig + ansible.builtin.include_tasks: tasks/kubeconfig.yaml + + - name: Wait for custom manifests to rollout + when: + - k3s_primary_control_node + - (k3s_server_manifests_templates | length > 0 + or k3s_server_manifests_urls | length > 0) + kubernetes.core.k8s_info: + kubeconfig: /etc/rancher/k3s/k3s.yaml + kind: "{{ item.kind }}" + name: "{{ item.name }}" + namespace: "{{ item.namespace | default('') }}" + wait: true + wait_sleep: 10 + wait_timeout: 360 + loop: + - { name: cilium, kind: HelmChart, namespace: kube-system } + - { name: kube-vip, kind: DaemonSet, namespace: kube-system } + + - name: Cilium + when: k3s_primary_control_node + ansible.builtin.include_tasks: tasks/cilium.yaml + + - name: Cruft + when: k3s_primary_control_node + ansible.builtin.include_tasks: tasks/cruft.yaml diff --git a/ansible/main/playbooks/cluster-nuke.yaml b/ansible/main/playbooks/cluster-nuke.yaml new file mode 100644 index 00000000..415e98ed --- /dev/null +++ b/ansible/main/playbooks/cluster-nuke.yaml @@ -0,0 +1,105 @@ +--- +- name: Cluster Nuke + hosts: kubernetes + become: true + gather_facts: true + any_errors_fatal: true + vars_prompt: + - name: nuke + prompt: |- + Are you sure you want to nuke this cluster? + Type 'YES I WANT TO DESTROY THIS CLUSTER' to proceed + default: "n" + private: false + pre_tasks: + - name: Check for confirmation + ansible.builtin.fail: + msg: Aborted nuking the cluster + when: nuke != 'YES I WANT TO DESTROY THIS CLUSTER' + + - name: Pausing for 5 seconds... + ansible.builtin.pause: + seconds: 5 + tasks: + - name: Stop Kubernetes # noqa: ignore-errors + ignore_errors: true + block: + - name: Stop Kubernetes + ansible.builtin.include_role: + name: xanmanning.k3s + public: true + vars: + k3s_state: stopped + + # https://github.com/k3s-io/docs/blob/main/docs/installation/network-options.md + - name: Networking + block: + - name: Networking | Delete Cilium links + ansible.builtin.command: + cmd: "ip link delete {{ item }}" + removes: "/sys/class/net/{{ item }}" + loop: ["cilium_host", "cilium_net", "cilium_vxlan"] + - name: Networking | Flush iptables + ansible.builtin.iptables: + table: "{{ item }}" + flush: true + loop: ["filter", "nat", "mangle", "raw"] + - name: Networking | Flush ip6tables + ansible.builtin.iptables: + table: "{{ item }}" + flush: true + ip_version: ipv6 + loop: ["filter", "nat", "mangle", "raw"] + - name: Networking | Delete CNI bin link + ansible.builtin.file: + path: /opt/cni/bin + state: absent + - name: Networking | Delete CNI conf link + ansible.builtin.file: + path: /etc/cni/net.d + state: absent + + - name: Check to see if k3s-killall.sh exits + ansible.builtin.stat: + path: /usr/local/bin/k3s-killall.sh + register: check_k3s_killall_script + + - name: Check to see if k3s-uninstall.sh exits + ansible.builtin.stat: + path: /usr/local/bin/k3s-uninstall.sh + register: check_k3s_uninstall_script + + - name: Run k3s-killall.sh + when: check_k3s_killall_script.stat.exists + ansible.builtin.command: + cmd: /usr/local/bin/k3s-killall.sh + register: k3s_killall + changed_when: k3s_killall.rc == 0 + + - name: Run k3s-uninstall.sh + when: check_k3s_uninstall_script.stat.exists + ansible.builtin.command: + cmd: /usr/local/bin/k3s-uninstall.sh + args: + removes: /usr/local/bin/k3s-uninstall.sh + register: k3s_uninstall + changed_when: k3s_uninstall.rc == 0 + + - name: Ensure hard links are removed + when: + - k3s_install_hard_links + - not ansible_check_mode + ansible.builtin.file: + path: "{{ k3s_install_dir }}/{{ item }}" + state: absent + loop: ["kubectl", "crictl", "ctr"] + + - name: Remove local storage path + ansible.builtin.file: + path: /var/openebs/local + state: absent + + - name: Reboot + ansible.builtin.reboot: + msg: Rebooting hosts + reboot_timeout: 3600 diff --git a/ansible/main/playbooks/cluster-prepare.yaml b/ansible/main/playbooks/cluster-prepare.yaml new file mode 100644 index 00000000..152220c9 --- /dev/null +++ b/ansible/main/playbooks/cluster-prepare.yaml @@ -0,0 +1,113 @@ +--- +- name: Prepare System + hosts: kubernetes + become: true + gather_facts: true + any_errors_fatal: true + pre_tasks: + - name: Pausing for 5 seconds... + ansible.builtin.pause: + seconds: 5 + - name: Populate service facts + ansible.builtin.service_facts: + tasks: + - name: Locale + block: + - name: Locale | Set timezone + community.general.timezone: + name: "Europe/Prague" + + - name: Packages + block: + - name: Packages | Install + ansible.builtin.apt: + name: apt-transport-https,ca-certificates,conntrack,curl,dirmngr,gdisk,gnupg,hdparm,htop, + iptables,iputils-ping,ipvsadm,libseccomp2,lm-sensors,net-tools,nfs-common, + nvme-cli,open-iscsi,parted,psmisc,python3,python3-apt,python3-kubernetes,python3-yaml, + smartmontools,socat,software-properties-common,unzip,util-linux + install_recommends: false + + - name: Network Configuration + notify: Reboot + block: + - name: Network Configuration | Set hostname + ansible.builtin.hostname: + name: "{{ inventory_hostname }}" + - name: Network Configuration | Update hosts + ansible.builtin.copy: + content: | + 127.0.0.1 localhost + 127.0.1.1 {{ inventory_hostname }} + + # The following lines are desirable for IPv6 capable hosts + ::1 localhost ip6-localhost ip6-loopback + ff02::1 ip6-allnodes + ff02::2 ip6-allrouters + dest: /etc/hosts + mode: preserve + # https://github.com/onedr0p/cluster-template/discussions/635 + - name: Network Configuration | Remove immutable flag from /etc/resolv.conf + ansible.builtin.file: + attributes: -i + path: /etc/resolv.conf + - name: Network Configuration | Remove /etc/resolv.conf + ansible.builtin.file: + attributes: -i + path: /etc/resolv.conf + state: absent + - name: Network Configuration | Add custom /etc/resolv.conf + ansible.builtin.copy: + attributes: +i + mode: '0644' + dest: /etc/resolv.conf + content: | + search . + nameserver 192.168.1.1 + + - name: System Configuration + notify: Reboot + block: + - name: System Configuration | Disable apparmor + when: ansible_facts.services['apparmor.service'] is defined + ansible.builtin.systemd: + name: apparmor + state: stopped + masked: true + - name: System Configuration | Disable swap + ansible.posix.mount: + name: "{{ item }}" + fstype: swap + state: absent + loop: ["none", "swap"] + - name: System Configuration | Create Kernel modules + ansible.builtin.copy: + dest: "/etc/modules-load.d/{{ item }}.conf" + mode: "0644" + content: "{{ item }}" + loop: ["br_netfilter", "ceph", "ip_vs", "ip_vs_rr", "iptable_mangle", "iptable_raw", "nbd", "overlay", "rbd", "xt_socket"] + register: modules_status + - name: System Configuration | Reload Kernel modules # noqa: no-changed-when no-handler + when: modules_status.changed + ansible.builtin.systemd: + name: systemd-modules-load + state: restarted + - name: System Configuration | Sysctl + ansible.posix.sysctl: + name: "{{ item.key }}" + value: "{{ item.value }}" + sysctl_file: /etc/sysctl.d/99-kubernetes.conf + reload: true + with_dict: "{{ sysctl_config }}" + vars: + sysctl_config: + fs.inotify.max_queued_events: 65536 + fs.inotify.max_user_watches: 524288 + fs.inotify.max_user_instances: 8192 + net.core.rmem_max: 2500000 + net.core.wmem_max: 2500000 + + handlers: + - name: Reboot + ansible.builtin.reboot: + msg: Rebooting hosts + reboot_timeout: 3600 diff --git a/ansible/main/playbooks/cluster-reboot.yaml b/ansible/main/playbooks/cluster-reboot.yaml new file mode 100644 index 00000000..6fe1fd0d --- /dev/null +++ b/ansible/main/playbooks/cluster-reboot.yaml @@ -0,0 +1,15 @@ +--- +- name: Reboot + hosts: kubernetes + become: true + gather_facts: true + any_errors_fatal: true + pre_tasks: + - name: Pausing for 5 seconds... + ansible.builtin.pause: + seconds: 5 + tasks: + - name: Reboot + ansible.builtin.reboot: + msg: Rebooting hosts + reboot_timeout: 3600 diff --git a/ansible/main/playbooks/cluster-rollout-update.yaml b/ansible/main/playbooks/cluster-rollout-update.yaml new file mode 100644 index 00000000..acad8fd6 --- /dev/null +++ b/ansible/main/playbooks/cluster-rollout-update.yaml @@ -0,0 +1,70 @@ +--- +- name: Cluster rollout update + hosts: kubernetes + become: true + gather_facts: true + any_errors_fatal: true + serial: 1 + pre_tasks: + - name: Pausing for 5 seconds... + ansible.builtin.pause: + seconds: 5 + tasks: + - name: Details + ansible.builtin.command: "k3s kubectl get node {{ inventory_hostname }} -o json" + register: kubectl_get_node + delegate_to: "{{ groups['controllers'][0] }}" + failed_when: false + changed_when: false + + - name: Update + when: + # When status.conditions[x].type == Ready then check stats.conditions[x].status for True|False + - kubectl_get_node['stdout'] | from_json | json_query("status.conditions[?type == 'Ready'].status") + # If spec.unschedulable is defined then the node is cordoned + - not (kubectl_get_node['stdout'] | from_json).spec.unschedulable is defined + block: + - name: Cordon + kubernetes.core.k8s_drain: + name: "{{ inventory_hostname }}" + kubeconfig: /etc/rancher/k3s/k3s.yaml + state: cordon + delegate_to: "{{ groups['controllers'][0] }}" + + - name: Drain + kubernetes.core.k8s_drain: + name: "{{ inventory_hostname }}" + kubeconfig: /etc/rancher/k3s/k3s.yaml + state: drain + delete_options: + delete_emptydir_data: true + ignore_daemonsets: true + terminate_grace_period: 600 + wait_timeout: 900 + pod_selectors: + - app!=rook-ceph-osd # Rook Ceph + delegate_to: "{{ groups['controllers'][0] }}" + + - name: Update + ansible.builtin.apt: + upgrade: dist + update_cache: true + + - name: Check if reboot is required + ansible.builtin.stat: + path: /var/run/reboot-required + register: reboot_required + + - name: Reboot + when: reboot_required.stat.exists + ansible.builtin.reboot: + msg: Rebooting node + post_reboot_delay: 60 + reboot_timeout: 3600 + + - name: Uncordon + kubernetes.core.k8s_drain: + name: "{{ inventory_hostname }}" + kubeconfig: /etc/rancher/k3s/k3s.yaml + state: uncordon + delegate_to: "{{ groups['controllers'][0] }}" diff --git a/ansible/main/playbooks/tasks/cilium.yaml b/ansible/main/playbooks/tasks/cilium.yaml new file mode 100644 index 00000000..ca242bb0 --- /dev/null +++ b/ansible/main/playbooks/tasks/cilium.yaml @@ -0,0 +1,56 @@ +--- +- name: Cilium + block: + - name: Cilium | Check if Cilium HelmChart exists + kubernetes.core.k8s_info: + kubeconfig: /etc/rancher/k3s/k3s.yaml + name: cilium + kind: HelmChart + namespace: kube-system + register: cilium_helmchart + + - name: Cilium | Wait for Cilium to rollout + when: cilium_helmchart.resources | count > 0 + kubernetes.core.k8s_info: + kubeconfig: /etc/rancher/k3s/k3s.yaml + name: helm-install-cilium + kind: Job + namespace: kube-system + wait: true + wait_condition: + type: Complete + status: true + wait_timeout: 360 + + - name: Cilium | Patch the Cilium HelmChart to unmanage it + when: cilium_helmchart.resources | count > 0 + kubernetes.core.k8s_json_patch: + kubeconfig: /etc/rancher/k3s/k3s.yaml + name: cilium + kind: HelmChart + namespace: kube-system + patch: + - op: add + path: /metadata/annotations/helmcharts.helm.cattle.io~1unmanaged + value: "true" + + - name: Cilium | Delete the Cilium HelmChart CR + when: cilium_helmchart.resources | count > 0 + kubernetes.core.k8s: + kubeconfig: /etc/rancher/k3s/k3s.yaml + name: cilium + kind: HelmChart + namespace: kube-system + state: absent + + - name: Cilium | Force delete the Cilium HelmChart + when: cilium_helmchart.resources | count > 0 + kubernetes.core.k8s: + kubeconfig: /etc/rancher/k3s/k3s.yaml + name: cilium + kind: HelmChart + namespace: kube-system + state: patched + definition: + metadata: + finalizers: [] diff --git a/ansible/main/playbooks/tasks/cruft.yaml b/ansible/main/playbooks/tasks/cruft.yaml new file mode 100644 index 00000000..73697476 --- /dev/null +++ b/ansible/main/playbooks/tasks/cruft.yaml @@ -0,0 +1,31 @@ +--- +- name: Cruft + block: + - name: Cruft | Get list of custom manifests + ansible.builtin.find: + paths: "{{ k3s_server_manifests_dir }}" + file_type: file + use_regex: true + patterns: ["^custom-.*"] + register: custom_manifest + + - name: Cruft | Delete custom manifests + ansible.builtin.file: + path: "{{ item.path }}" + state: absent + loop: "{{ custom_manifest.files }}" + + - name: Cruft | Get list of custom addons + kubernetes.core.k8s_info: + kubeconfig: /etc/rancher/k3s/k3s.yaml + kind: Addon + register: addons_list + + - name: Cruft | Delete addons + kubernetes.core.k8s: + kubeconfig: /etc/rancher/k3s/k3s.yaml + name: "{{ item.metadata.name }}" + kind: Addon + namespace: kube-system + state: absent + loop: "{{ addons_list.resources | selectattr('metadata.name', 'match', '^custom-.*') | list }}" diff --git a/ansible/main/playbooks/tasks/kubeconfig.yaml b/ansible/main/playbooks/tasks/kubeconfig.yaml new file mode 100644 index 00000000..1a895102 --- /dev/null +++ b/ansible/main/playbooks/tasks/kubeconfig.yaml @@ -0,0 +1,35 @@ +--- +- name: Get absolute path to this Git repository # noqa: command-instead-of-module + ansible.builtin.command: git rev-parse --show-toplevel + delegate_to: localhost + become: false + run_once: true + register: repository_path + changed_when: false + check_mode: false + failed_when: repository_path.rc != 0 + +- name: Copy kubeconfig to the project directory + when: k3s_primary_control_node + ansible.builtin.fetch: + src: /etc/rancher/k3s/k3s.yaml + dest: "{{ repository_path.stdout }}/kubernetes/main/kubeconfig" + flat: true + +- name: Update kubeconfig with the correct load balancer address + delegate_to: localhost + become: false + run_once: true + ansible.builtin.replace: + path: "{{ repository_path.stdout }}/kubernetes/main/kubeconfig" + regexp: https://127.0.0.1:6443 + replace: "https://{{ k3s_registration_address }}:6443" + +- name: Update kubeconfig with the correct context + delegate_to: localhost + become: false + run_once: true + ansible.builtin.replace: + path: "{{ repository_path.stdout }}/kubernetes/main/kubeconfig" + regexp: "default" + replace: "main" diff --git a/ansible/main/playbooks/tasks/version-check.yaml b/ansible/main/playbooks/tasks/version-check.yaml new file mode 100644 index 00000000..56e56702 --- /dev/null +++ b/ansible/main/playbooks/tasks/version-check.yaml @@ -0,0 +1,17 @@ +--- +- name: Version Check + block: + - name: Get deployed k3s version + ansible.builtin.command: k3s --version + register: k3s_version + changed_when: false + failed_when: false + + - name: Extract k3s version + ansible.builtin.set_fact: + current_k3s_version: "{{ k3s_version.stdout | regex_replace('(?im)k3s version (?P[a-z0-9\\.\\+]+).*\n.*', '\\g') }}" + + - name: Check if upgrades are allowed + ansible.builtin.assert: + that: ["k3s_release_version is version(current_k3s_version, '>=')"] + fail_msg: "Unable to upgrade k3s because the deployed version is higher than the one specified in the configuration" diff --git a/ansible/main/playbooks/templates/custom-cilium-helmchart.yaml b/ansible/main/playbooks/templates/custom-cilium-helmchart.yaml new file mode 100644 index 00000000..83def39b --- /dev/null +++ b/ansible/main/playbooks/templates/custom-cilium-helmchart.yaml @@ -0,0 +1,82 @@ +--- +apiVersion: helm.cattle.io/v1 +kind: HelmChart +metadata: + name: cilium + namespace: kube-system +spec: + repo: https://helm.cilium.io/ + chart: cilium + # renovate: datasource=helm depName=cilium repository=https://helm.cilium.io + version: 1.15.4 + targetNamespace: kube-system + bootstrap: true + valuesContent: |- + autoDirectNodeRoutes: true + bgpControlPlane: + enabled: true + bpf: + masquerade: false + vlanBypass: [0] + cgroup: + automount: + enabled: false + hostRoot: /sys/fs/cgroup + cluster: + id: 1 + name: home-ops + cni: + exclusive: false + binPath: /var/lib/rancher/k3s/data/current/bin + confPath: /var/lib/rancher/k3s/agent/etc/cni/net.d + containerRuntime: + integration: containerd + socketPath: /var/run/k3s/containerd/containerd.sock + # NOTE: devices might need to be set if you have more than one active NIC on your hosts + # devices: eno+ eth+ + devices: + - lan + endpointRoutes: + enabled: true + hubble: + enabled: false + ipam: + mode: kubernetes + ipv4NativeRoutingCIDR: "10.40.0.0/16" + k8sServiceHost: 127.0.0.1 + k8sServicePort: 6444 + kubeProxyReplacement: true + kubeProxyReplacementHealthzBindAddr: 0.0.0.0:10256 + l2announcements: + enabled: true + # https://github.com/cilium/cilium/issues/26586 + leaseDuration: 300s + leaseRenewDeadline: 60s + leaseRetryPeriod: 10s + loadBalancer: + algorithm: maglev + mode: snat + localRedirectPolicy: true + operator: + replicas: 1 + rollOutPods: true + rollOutCiliumPods: true + routingMode: native + securityContext: + capabilities: + ciliumAgent: + - CHOWN + - KILL + - NET_ADMIN + - NET_RAW + - IPC_LOCK + - SYS_ADMIN + - SYS_RESOURCE + - DAC_OVERRIDE + - FOWNER + - SETGID + - SETUID + cleanCiliumState: + - NET_ADMIN + - SYS_ADMIN + - SYS_RESOURCE diff --git a/ansible/main/playbooks/templates/custom-kube-vip-ds.yaml b/ansible/main/playbooks/templates/custom-kube-vip-ds.yaml new file mode 100644 index 00000000..399e0672 --- /dev/null +++ b/ansible/main/playbooks/templates/custom-kube-vip-ds.yaml @@ -0,0 +1,75 @@ +--- +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: kube-vip + namespace: kube-system + labels: + app.kubernetes.io/name: kube-vip +spec: + selector: + matchLabels: + app.kubernetes.io/name: kube-vip + template: + metadata: + labels: + app.kubernetes.io/name: kube-vip + spec: + containers: + - name: kube-vip + image: ghcr.io/kube-vip/kube-vip:v0.7.1 + imagePullPolicy: IfNotPresent + args: ["manager"] + env: + - name: address + value: "192.168.1.40" + - name: vip_arp + value: "true" + - name: lb_enable + value: "true" + - name: port + value: "6443" + - name: vip_cidr + value: "32" + - name: cp_enable + value: "true" + - name: cp_namespace + value: kube-system + - name: vip_ddns + value: "false" + - name: svc_enable + value: "false" + - name: vip_leaderelection + value: "true" + - name: vip_leaseduration + value: "15" + - name: vip_renewdeadline + value: "10" + - name: vip_retryperiod + value: "2" + - name: prometheus_server + value: :2112 + securityContext: + capabilities: + add: ["NET_ADMIN", "NET_RAW", "SYS_TIME"] + hostAliases: + - hostnames: + - kubernetes + ip: 127.0.0.1 + hostNetwork: true + serviceAccountName: kube-vip + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: node-role.kubernetes.io/master + operator: Exists + - matchExpressions: + - key: node-role.kubernetes.io/control-plane + operator: Exists + tolerations: + - effect: NoSchedule + operator: Exists + - effect: NoExecute + operator: Exists diff --git a/ansible/main/playbooks/templates/custom-kube-vip-rbac.yaml b/ansible/main/playbooks/templates/custom-kube-vip-rbac.yaml new file mode 100644 index 00000000..b3cc6d4d --- /dev/null +++ b/ansible/main/playbooks/templates/custom-kube-vip-rbac.yaml @@ -0,0 +1,42 @@ +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: kube-vip + namespace: kube-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + annotations: + rbac.authorization.kubernetes.io/autoupdate: "true" + name: system:kube-vip-role +rules: + - apiGroups: [""] + resources: ["services/status"] + verbs: ["update"] + - apiGroups: [""] + resources: ["services", "endpoints"] + verbs: ["list","get","watch", "update"] + - apiGroups: [""] + resources: ["nodes"] + verbs: ["list","get","watch", "update", "patch"] + - apiGroups: ["coordination.k8s.io"] + resources: ["leases"] + verbs: ["list", "get", "watch", "update", "create"] + - apiGroups: ["discovery.k8s.io"] + resources: ["endpointslices"] + verbs: ["list","get","watch", "update"] +--- +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: system:kube-vip-binding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: system:kube-vip-role +subjects: +- kind: ServiceAccount + name: kube-vip + namespace: kube-system diff --git a/ansible/requirements.txt b/ansible/requirements.txt new file mode 100644 index 00000000..4d4f6da8 --- /dev/null +++ b/ansible/requirements.txt @@ -0,0 +1,4 @@ +ansible-lint==24.2.2 +ansible==9.4.0 +jmespath==1.0.1 +openshift==0.13.2 diff --git a/ansible/requirements.yaml b/ansible/requirements.yaml new file mode 100644 index 00000000..57bb572d --- /dev/null +++ b/ansible/requirements.yaml @@ -0,0 +1,14 @@ +--- +collections: + - name: ansible.posix + version: 1.5.4 + - name: ansible.utils + version: 4.1.0 + - name: community.general + version: 8.5.0 + - name: kubernetes.core + version: 3.0.1 +roles: + - name: xanmanning.k3s + src: https://github.com/PyratLabs/ansible-role-k3s + version: v3.4.4 diff --git a/ansible/storage/inventory/group_vars/controllers/main.yaml b/ansible/storage/inventory/group_vars/controllers/main.yaml new file mode 100644 index 00000000..79c6f9b1 --- /dev/null +++ b/ansible/storage/inventory/group_vars/controllers/main.yaml @@ -0,0 +1,26 @@ +--- +k3s_control_node: true +k3s_server: + cluster-cidr: "10.10.0.0/16" + service-cidr: "10.11.0.0/16" + disable: ["flannel", "local-storage", "metrics-server", "servicelb", "traefik"] + disable-cloud-controller: true + disable-kube-proxy: true + disable-network-policy: true + docker: false + embedded-registry: true + etcd-expose-metrics: true + flannel-backend: "none" + kube-apiserver-arg: + - "anonymous-auth=true" + kube-controller-manager-arg: + - "bind-address=0.0.0.0" + kube-scheduler-arg: + - "bind-address=0.0.0.0" + node-ip: "{{ ansible_host }}" + secrets-encryption: true + tls-san: + - "192.168.1.10" + - "home-storage" + - "home-storage.rx.cz" + write-kubeconfig-mode: "644" diff --git a/ansible/storage/inventory/group_vars/kubernetes/main.yaml b/ansible/storage/inventory/group_vars/kubernetes/main.yaml new file mode 100644 index 00000000..f75a7e2a --- /dev/null +++ b/ansible/storage/inventory/group_vars/kubernetes/main.yaml @@ -0,0 +1,23 @@ +--- +k3s_become: true +k3s_etcd_datastore: true +k3s_install_hard_links: true +k3s_registration_address: "192.168.1.10" +k3s_registries: + mirrors: + docker.io: + gcr.io: + ghcr.io: + k8s.gcr.io: + lscr.io: + mcr.microsoft.com: + public.ecr.aws: + quay.io: + registry.k8s.io: +# renovate: datasource=github-releases depName=k3s-io/k3s +k3s_release_version: v1.29.3+k3s1 +k3s_server_manifests_templates: + - custom-cilium-helmchart.yaml + - custom-kube-vip-ds.yaml + - custom-kube-vip-rbac.yaml +k3s_use_unsupported_config: true diff --git a/ansible/storage/inventory/hosts.yaml b/ansible/storage/inventory/hosts.yaml new file mode 100644 index 00000000..c8d6fc81 --- /dev/null +++ b/ansible/storage/inventory/hosts.yaml @@ -0,0 +1,8 @@ +--- +kubernetes: + children: + controllers: + hosts: + "h1": + ansible_user: "home-ops" + ansible_host: "192.168.1.11" diff --git a/ansible/storage/playbooks/cluster-installation.yaml b/ansible/storage/playbooks/cluster-installation.yaml new file mode 100644 index 00000000..507b7b29 --- /dev/null +++ b/ansible/storage/playbooks/cluster-installation.yaml @@ -0,0 +1,91 @@ +--- +- name: Cluster Installation + hosts: kubernetes + become: true + gather_facts: true + any_errors_fatal: true + pre_tasks: + - name: Pausing for 5 seconds... + ansible.builtin.pause: + seconds: 5 + tasks: + - name: Check if cluster is installed + check_mode: false + ansible.builtin.stat: + path: /etc/rancher/k3s/config.yaml + register: k3s_installed + + - name: Ignore manifests templates and urls if the cluster is already installed + when: k3s_installed.stat.exists + ansible.builtin.set_fact: + k3s_server_manifests_templates: [] + k3s_server_manifests_urls: [] + + - name: Prevent downgrades + when: k3s_installed.stat.exists + ansible.builtin.include_tasks: tasks/version-check.yaml + + - name: Ensure that the /opt/cni directory exists + ansible.builtin.file: + path: /opt/cni + mode: '755' + state: directory + - name: Ensure that the /opt/cni/bin is a link to /var/lib/rancher/k3s/data/current/bin + ansible.builtin.file: + src: /var/lib/rancher/k3s/data/current/bin + dest: /opt/cni/bin + follow: false + force: true + state: link + + - name: Ensure that the /etc/cni directory exists + ansible.builtin.file: + path: /etc/cni + mode: '755' + state: directory + - name: Ensure that the /var/lib/rancher/k3s/agent/etc/cni/net.d directory exists + ansible.builtin.file: + path: /var/lib/rancher/k3s/agent/etc/cni/net.d + mode: '755' + state: directory + - name: Ensure that the /etc/cni/net.d is a link to /var/lib/rancher/k3s/agent/etc/cni/net.d + ansible.builtin.file: + src: /var/lib/rancher/k3s/agent/etc/cni/net.d + dest: /etc/cni/net.d + force: true + state: link + + - name: Install Kubernetes + ansible.builtin.include_role: + name: xanmanning.k3s + public: true + vars: + k3s_state: installed + + - name: Kubeconfig + ansible.builtin.include_tasks: tasks/kubeconfig.yaml + + - name: Wait for custom manifests to rollout + when: + - k3s_primary_control_node + - (k3s_server_manifests_templates | length > 0 + or k3s_server_manifests_urls | length > 0) + kubernetes.core.k8s_info: + kubeconfig: /etc/rancher/k3s/k3s.yaml + kind: "{{ item.kind }}" + name: "{{ item.name }}" + namespace: "{{ item.namespace | default('') }}" + wait: true + wait_sleep: 10 + wait_timeout: 360 + loop: + - { name: cilium, kind: HelmChart, namespace: kube-system } + - { name: kube-vip, kind: DaemonSet, namespace: kube-system } + + - name: Cilium + when: k3s_primary_control_node + ansible.builtin.include_tasks: tasks/cilium.yaml + + - name: Cruft + when: k3s_primary_control_node + ansible.builtin.include_tasks: tasks/cruft.yaml diff --git a/ansible/storage/playbooks/cluster-nuke.yaml b/ansible/storage/playbooks/cluster-nuke.yaml new file mode 100644 index 00000000..415e98ed --- /dev/null +++ b/ansible/storage/playbooks/cluster-nuke.yaml @@ -0,0 +1,105 @@ +--- +- name: Cluster Nuke + hosts: kubernetes + become: true + gather_facts: true + any_errors_fatal: true + vars_prompt: + - name: nuke + prompt: |- + Are you sure you want to nuke this cluster? + Type 'YES I WANT TO DESTROY THIS CLUSTER' to proceed + default: "n" + private: false + pre_tasks: + - name: Check for confirmation + ansible.builtin.fail: + msg: Aborted nuking the cluster + when: nuke != 'YES I WANT TO DESTROY THIS CLUSTER' + + - name: Pausing for 5 seconds... + ansible.builtin.pause: + seconds: 5 + tasks: + - name: Stop Kubernetes # noqa: ignore-errors + ignore_errors: true + block: + - name: Stop Kubernetes + ansible.builtin.include_role: + name: xanmanning.k3s + public: true + vars: + k3s_state: stopped + + # https://github.com/k3s-io/docs/blob/main/docs/installation/network-options.md + - name: Networking + block: + - name: Networking | Delete Cilium links + ansible.builtin.command: + cmd: "ip link delete {{ item }}" + removes: "/sys/class/net/{{ item }}" + loop: ["cilium_host", "cilium_net", "cilium_vxlan"] + - name: Networking | Flush iptables + ansible.builtin.iptables: + table: "{{ item }}" + flush: true + loop: ["filter", "nat", "mangle", "raw"] + - name: Networking | Flush ip6tables + ansible.builtin.iptables: + table: "{{ item }}" + flush: true + ip_version: ipv6 + loop: ["filter", "nat", "mangle", "raw"] + - name: Networking | Delete CNI bin link + ansible.builtin.file: + path: /opt/cni/bin + state: absent + - name: Networking | Delete CNI conf link + ansible.builtin.file: + path: /etc/cni/net.d + state: absent + + - name: Check to see if k3s-killall.sh exits + ansible.builtin.stat: + path: /usr/local/bin/k3s-killall.sh + register: check_k3s_killall_script + + - name: Check to see if k3s-uninstall.sh exits + ansible.builtin.stat: + path: /usr/local/bin/k3s-uninstall.sh + register: check_k3s_uninstall_script + + - name: Run k3s-killall.sh + when: check_k3s_killall_script.stat.exists + ansible.builtin.command: + cmd: /usr/local/bin/k3s-killall.sh + register: k3s_killall + changed_when: k3s_killall.rc == 0 + + - name: Run k3s-uninstall.sh + when: check_k3s_uninstall_script.stat.exists + ansible.builtin.command: + cmd: /usr/local/bin/k3s-uninstall.sh + args: + removes: /usr/local/bin/k3s-uninstall.sh + register: k3s_uninstall + changed_when: k3s_uninstall.rc == 0 + + - name: Ensure hard links are removed + when: + - k3s_install_hard_links + - not ansible_check_mode + ansible.builtin.file: + path: "{{ k3s_install_dir }}/{{ item }}" + state: absent + loop: ["kubectl", "crictl", "ctr"] + + - name: Remove local storage path + ansible.builtin.file: + path: /var/openebs/local + state: absent + + - name: Reboot + ansible.builtin.reboot: + msg: Rebooting hosts + reboot_timeout: 3600 diff --git a/ansible/storage/playbooks/cluster-prepare.yaml b/ansible/storage/playbooks/cluster-prepare.yaml new file mode 100644 index 00000000..152220c9 --- /dev/null +++ b/ansible/storage/playbooks/cluster-prepare.yaml @@ -0,0 +1,113 @@ +--- +- name: Prepare System + hosts: kubernetes + become: true + gather_facts: true + any_errors_fatal: true + pre_tasks: + - name: Pausing for 5 seconds... + ansible.builtin.pause: + seconds: 5 + - name: Populate service facts + ansible.builtin.service_facts: + tasks: + - name: Locale + block: + - name: Locale | Set timezone + community.general.timezone: + name: "Europe/Prague" + + - name: Packages + block: + - name: Packages | Install + ansible.builtin.apt: + name: apt-transport-https,ca-certificates,conntrack,curl,dirmngr,gdisk,gnupg,hdparm,htop, + iptables,iputils-ping,ipvsadm,libseccomp2,lm-sensors,net-tools,nfs-common, + nvme-cli,open-iscsi,parted,psmisc,python3,python3-apt,python3-kubernetes,python3-yaml, + smartmontools,socat,software-properties-common,unzip,util-linux + install_recommends: false + + - name: Network Configuration + notify: Reboot + block: + - name: Network Configuration | Set hostname + ansible.builtin.hostname: + name: "{{ inventory_hostname }}" + - name: Network Configuration | Update hosts + ansible.builtin.copy: + content: | + 127.0.0.1 localhost + 127.0.1.1 {{ inventory_hostname }} + + # The following lines are desirable for IPv6 capable hosts + ::1 localhost ip6-localhost ip6-loopback + ff02::1 ip6-allnodes + ff02::2 ip6-allrouters + dest: /etc/hosts + mode: preserve + # https://github.com/onedr0p/cluster-template/discussions/635 + - name: Network Configuration | Remove immutable flag from /etc/resolv.conf + ansible.builtin.file: + attributes: -i + path: /etc/resolv.conf + - name: Network Configuration | Remove /etc/resolv.conf + ansible.builtin.file: + attributes: -i + path: /etc/resolv.conf + state: absent + - name: Network Configuration | Add custom /etc/resolv.conf + ansible.builtin.copy: + attributes: +i + mode: '0644' + dest: /etc/resolv.conf + content: | + search . + nameserver 192.168.1.1 + + - name: System Configuration + notify: Reboot + block: + - name: System Configuration | Disable apparmor + when: ansible_facts.services['apparmor.service'] is defined + ansible.builtin.systemd: + name: apparmor + state: stopped + masked: true + - name: System Configuration | Disable swap + ansible.posix.mount: + name: "{{ item }}" + fstype: swap + state: absent + loop: ["none", "swap"] + - name: System Configuration | Create Kernel modules + ansible.builtin.copy: + dest: "/etc/modules-load.d/{{ item }}.conf" + mode: "0644" + content: "{{ item }}" + loop: ["br_netfilter", "ceph", "ip_vs", "ip_vs_rr", "iptable_mangle", "iptable_raw", "nbd", "overlay", "rbd", "xt_socket"] + register: modules_status + - name: System Configuration | Reload Kernel modules # noqa: no-changed-when no-handler + when: modules_status.changed + ansible.builtin.systemd: + name: systemd-modules-load + state: restarted + - name: System Configuration | Sysctl + ansible.posix.sysctl: + name: "{{ item.key }}" + value: "{{ item.value }}" + sysctl_file: /etc/sysctl.d/99-kubernetes.conf + reload: true + with_dict: "{{ sysctl_config }}" + vars: + sysctl_config: + fs.inotify.max_queued_events: 65536 + fs.inotify.max_user_watches: 524288 + fs.inotify.max_user_instances: 8192 + net.core.rmem_max: 2500000 + net.core.wmem_max: 2500000 + + handlers: + - name: Reboot + ansible.builtin.reboot: + msg: Rebooting hosts + reboot_timeout: 3600 diff --git a/ansible/storage/playbooks/cluster-reboot.yaml b/ansible/storage/playbooks/cluster-reboot.yaml new file mode 100644 index 00000000..6fe1fd0d --- /dev/null +++ b/ansible/storage/playbooks/cluster-reboot.yaml @@ -0,0 +1,15 @@ +--- +- name: Reboot + hosts: kubernetes + become: true + gather_facts: true + any_errors_fatal: true + pre_tasks: + - name: Pausing for 5 seconds... + ansible.builtin.pause: + seconds: 5 + tasks: + - name: Reboot + ansible.builtin.reboot: + msg: Rebooting hosts + reboot_timeout: 3600 diff --git a/ansible/storage/playbooks/cluster-rollout-update.yaml b/ansible/storage/playbooks/cluster-rollout-update.yaml new file mode 100644 index 00000000..acad8fd6 --- /dev/null +++ b/ansible/storage/playbooks/cluster-rollout-update.yaml @@ -0,0 +1,70 @@ +--- +- name: Cluster rollout update + hosts: kubernetes + become: true + gather_facts: true + any_errors_fatal: true + serial: 1 + pre_tasks: + - name: Pausing for 5 seconds... + ansible.builtin.pause: + seconds: 5 + tasks: + - name: Details + ansible.builtin.command: "k3s kubectl get node {{ inventory_hostname }} -o json" + register: kubectl_get_node + delegate_to: "{{ groups['controllers'][0] }}" + failed_when: false + changed_when: false + + - name: Update + when: + # When status.conditions[x].type == Ready then check stats.conditions[x].status for True|False + - kubectl_get_node['stdout'] | from_json | json_query("status.conditions[?type == 'Ready'].status") + # If spec.unschedulable is defined then the node is cordoned + - not (kubectl_get_node['stdout'] | from_json).spec.unschedulable is defined + block: + - name: Cordon + kubernetes.core.k8s_drain: + name: "{{ inventory_hostname }}" + kubeconfig: /etc/rancher/k3s/k3s.yaml + state: cordon + delegate_to: "{{ groups['controllers'][0] }}" + + - name: Drain + kubernetes.core.k8s_drain: + name: "{{ inventory_hostname }}" + kubeconfig: /etc/rancher/k3s/k3s.yaml + state: drain + delete_options: + delete_emptydir_data: true + ignore_daemonsets: true + terminate_grace_period: 600 + wait_timeout: 900 + pod_selectors: + - app!=rook-ceph-osd # Rook Ceph + delegate_to: "{{ groups['controllers'][0] }}" + + - name: Update + ansible.builtin.apt: + upgrade: dist + update_cache: true + + - name: Check if reboot is required + ansible.builtin.stat: + path: /var/run/reboot-required + register: reboot_required + + - name: Reboot + when: reboot_required.stat.exists + ansible.builtin.reboot: + msg: Rebooting node + post_reboot_delay: 60 + reboot_timeout: 3600 + + - name: Uncordon + kubernetes.core.k8s_drain: + name: "{{ inventory_hostname }}" + kubeconfig: /etc/rancher/k3s/k3s.yaml + state: uncordon + delegate_to: "{{ groups['controllers'][0] }}" diff --git a/ansible/storage/playbooks/tasks/cilium.yaml b/ansible/storage/playbooks/tasks/cilium.yaml new file mode 100644 index 00000000..ca242bb0 --- /dev/null +++ b/ansible/storage/playbooks/tasks/cilium.yaml @@ -0,0 +1,56 @@ +--- +- name: Cilium + block: + - name: Cilium | Check if Cilium HelmChart exists + kubernetes.core.k8s_info: + kubeconfig: /etc/rancher/k3s/k3s.yaml + name: cilium + kind: HelmChart + namespace: kube-system + register: cilium_helmchart + + - name: Cilium | Wait for Cilium to rollout + when: cilium_helmchart.resources | count > 0 + kubernetes.core.k8s_info: + kubeconfig: /etc/rancher/k3s/k3s.yaml + name: helm-install-cilium + kind: Job + namespace: kube-system + wait: true + wait_condition: + type: Complete + status: true + wait_timeout: 360 + + - name: Cilium | Patch the Cilium HelmChart to unmanage it + when: cilium_helmchart.resources | count > 0 + kubernetes.core.k8s_json_patch: + kubeconfig: /etc/rancher/k3s/k3s.yaml + name: cilium + kind: HelmChart + namespace: kube-system + patch: + - op: add + path: /metadata/annotations/helmcharts.helm.cattle.io~1unmanaged + value: "true" + + - name: Cilium | Delete the Cilium HelmChart CR + when: cilium_helmchart.resources | count > 0 + kubernetes.core.k8s: + kubeconfig: /etc/rancher/k3s/k3s.yaml + name: cilium + kind: HelmChart + namespace: kube-system + state: absent + + - name: Cilium | Force delete the Cilium HelmChart + when: cilium_helmchart.resources | count > 0 + kubernetes.core.k8s: + kubeconfig: /etc/rancher/k3s/k3s.yaml + name: cilium + kind: HelmChart + namespace: kube-system + state: patched + definition: + metadata: + finalizers: [] diff --git a/ansible/storage/playbooks/tasks/cruft.yaml b/ansible/storage/playbooks/tasks/cruft.yaml new file mode 100644 index 00000000..73697476 --- /dev/null +++ b/ansible/storage/playbooks/tasks/cruft.yaml @@ -0,0 +1,31 @@ +--- +- name: Cruft + block: + - name: Cruft | Get list of custom manifests + ansible.builtin.find: + paths: "{{ k3s_server_manifests_dir }}" + file_type: file + use_regex: true + patterns: ["^custom-.*"] + register: custom_manifest + + - name: Cruft | Delete custom manifests + ansible.builtin.file: + path: "{{ item.path }}" + state: absent + loop: "{{ custom_manifest.files }}" + + - name: Cruft | Get list of custom addons + kubernetes.core.k8s_info: + kubeconfig: /etc/rancher/k3s/k3s.yaml + kind: Addon + register: addons_list + + - name: Cruft | Delete addons + kubernetes.core.k8s: + kubeconfig: /etc/rancher/k3s/k3s.yaml + name: "{{ item.metadata.name }}" + kind: Addon + namespace: kube-system + state: absent + loop: "{{ addons_list.resources | selectattr('metadata.name', 'match', '^custom-.*') | list }}" diff --git a/ansible/storage/playbooks/tasks/kubeconfig.yaml b/ansible/storage/playbooks/tasks/kubeconfig.yaml new file mode 100644 index 00000000..81421182 --- /dev/null +++ b/ansible/storage/playbooks/tasks/kubeconfig.yaml @@ -0,0 +1,35 @@ +--- +- name: Get absolute path to this Git repository # noqa: command-instead-of-module + ansible.builtin.command: git rev-parse --show-toplevel + delegate_to: localhost + become: false + run_once: true + register: repository_path + changed_when: false + check_mode: false + failed_when: repository_path.rc != 0 + +- name: Copy kubeconfig to the project directory + when: k3s_primary_control_node + ansible.builtin.fetch: + src: /etc/rancher/k3s/k3s.yaml + dest: "{{ repository_path.stdout }}/kubernetes/storage/kubeconfig" + flat: true + +- name: Update kubeconfig with the correct load balancer address + delegate_to: localhost + become: false + run_once: true + ansible.builtin.replace: + path: "{{ repository_path.stdout }}/kubernetes/storage/kubeconfig" + regexp: https://127.0.0.1:6443 + replace: "https://{{ k3s_registration_address }}:6443" + +- name: Update kubeconfig with the correct context + delegate_to: localhost + become: false + run_once: true + ansible.builtin.replace: + path: "{{ repository_path.stdout }}/kubernetes/storage/kubeconfig" + regexp: "default" + replace: "storage" diff --git a/ansible/storage/playbooks/tasks/version-check.yaml b/ansible/storage/playbooks/tasks/version-check.yaml new file mode 100644 index 00000000..56e56702 --- /dev/null +++ b/ansible/storage/playbooks/tasks/version-check.yaml @@ -0,0 +1,17 @@ +--- +- name: Version Check + block: + - name: Get deployed k3s version + ansible.builtin.command: k3s --version + register: k3s_version + changed_when: false + failed_when: false + + - name: Extract k3s version + ansible.builtin.set_fact: + current_k3s_version: "{{ k3s_version.stdout | regex_replace('(?im)k3s version (?P[a-z0-9\\.\\+]+).*\n.*', '\\g') }}" + + - name: Check if upgrades are allowed + ansible.builtin.assert: + that: ["k3s_release_version is version(current_k3s_version, '>=')"] + fail_msg: "Unable to upgrade k3s because the deployed version is higher than the one specified in the configuration" diff --git a/ansible/storage/playbooks/templates/custom-cilium-helmchart.yaml b/ansible/storage/playbooks/templates/custom-cilium-helmchart.yaml new file mode 100644 index 00000000..f2fa3777 --- /dev/null +++ b/ansible/storage/playbooks/templates/custom-cilium-helmchart.yaml @@ -0,0 +1,82 @@ +--- +apiVersion: helm.cattle.io/v1 +kind: HelmChart +metadata: + name: cilium + namespace: kube-system +spec: + repo: https://helm.cilium.io/ + chart: cilium + # renovate: datasource=helm depName=cilium repository=https://helm.cilium.io + version: 1.15.4 + targetNamespace: kube-system + bootstrap: true + valuesContent: |- + autoDirectNodeRoutes: true + bgpControlPlane: + enabled: true + bpf: + masquerade: false + vlanBypass: [0] + cgroup: + automount: + enabled: false + hostRoot: /sys/fs/cgroup + cluster: + id: 1 + name: home-storage + cni: + exclusive: false + binPath: /var/lib/rancher/k3s/data/current/bin + confPath: /var/lib/rancher/k3s/agent/etc/cni/net.d + containerRuntime: + integration: containerd + socketPath: /var/run/k3s/containerd/containerd.sock + # NOTE: devices might need to be set if you have more than one active NIC on your hosts + # devices: eno+ eth+ + devices: + - lan + endpointRoutes: + enabled: true + hubble: + enabled: false + ipam: + mode: kubernetes + ipv4NativeRoutingCIDR: "10.10.0.0/16" + k8sServiceHost: 127.0.0.1 + k8sServicePort: 6444 + kubeProxyReplacement: true + kubeProxyReplacementHealthzBindAddr: 0.0.0.0:10256 + l2announcements: + enabled: true + # https://github.com/cilium/cilium/issues/26586 + leaseDuration: 300s + leaseRenewDeadline: 60s + leaseRetryPeriod: 10s + loadBalancer: + algorithm: maglev + mode: snat + localRedirectPolicy: true + operator: + replicas: 1 + rollOutPods: true + rollOutCiliumPods: true + routingMode: native + securityContext: + capabilities: + ciliumAgent: + - CHOWN + - KILL + - NET_ADMIN + - NET_RAW + - IPC_LOCK + - SYS_ADMIN + - SYS_RESOURCE + - DAC_OVERRIDE + - FOWNER + - SETGID + - SETUID + cleanCiliumState: + - NET_ADMIN + - SYS_ADMIN + - SYS_RESOURCE diff --git a/ansible/storage/playbooks/templates/custom-kube-vip-ds.yaml b/ansible/storage/playbooks/templates/custom-kube-vip-ds.yaml new file mode 100644 index 00000000..829f4462 --- /dev/null +++ b/ansible/storage/playbooks/templates/custom-kube-vip-ds.yaml @@ -0,0 +1,75 @@ +--- +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: kube-vip + namespace: kube-system + labels: + app.kubernetes.io/name: kube-vip +spec: + selector: + matchLabels: + app.kubernetes.io/name: kube-vip + template: + metadata: + labels: + app.kubernetes.io/name: kube-vip + spec: + containers: + - name: kube-vip + image: ghcr.io/kube-vip/kube-vip:v0.7.1 + imagePullPolicy: IfNotPresent + args: ["manager"] + env: + - name: address + value: "192.168.1.10" + - name: vip_arp + value: "true" + - name: lb_enable + value: "true" + - name: port + value: "6443" + - name: vip_cidr + value: "32" + - name: cp_enable + value: "true" + - name: cp_namespace + value: kube-system + - name: vip_ddns + value: "false" + - name: svc_enable + value: "false" + - name: vip_leaderelection + value: "true" + - name: vip_leaseduration + value: "15" + - name: vip_renewdeadline + value: "10" + - name: vip_retryperiod + value: "2" + - name: prometheus_server + value: :2112 + securityContext: + capabilities: + add: ["NET_ADMIN", "NET_RAW", "SYS_TIME"] + hostAliases: + - hostnames: + - kubernetes + ip: 127.0.0.1 + hostNetwork: true + serviceAccountName: kube-vip + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: node-role.kubernetes.io/master + operator: Exists + - matchExpressions: + - key: node-role.kubernetes.io/control-plane + operator: Exists + tolerations: + - effect: NoSchedule + operator: Exists + - effect: NoExecute + operator: Exists diff --git a/ansible/storage/playbooks/templates/custom-kube-vip-rbac.yaml b/ansible/storage/playbooks/templates/custom-kube-vip-rbac.yaml new file mode 100644 index 00000000..b3cc6d4d --- /dev/null +++ b/ansible/storage/playbooks/templates/custom-kube-vip-rbac.yaml @@ -0,0 +1,42 @@ +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: kube-vip + namespace: kube-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + annotations: + rbac.authorization.kubernetes.io/autoupdate: "true" + name: system:kube-vip-role +rules: + - apiGroups: [""] + resources: ["services/status"] + verbs: ["update"] + - apiGroups: [""] + resources: ["services", "endpoints"] + verbs: ["list","get","watch", "update"] + - apiGroups: [""] + resources: ["nodes"] + verbs: ["list","get","watch", "update", "patch"] + - apiGroups: ["coordination.k8s.io"] + resources: ["leases"] + verbs: ["list", "get", "watch", "update", "create"] + - apiGroups: ["discovery.k8s.io"] + resources: ["endpointslices"] + verbs: ["list","get","watch", "update"] +--- +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: system:kube-vip-binding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: system:kube-vip-role +subjects: +- kind: ServiceAccount + name: kube-vip + namespace: kube-system diff --git a/docs/assets/images/home-ops-kubernetes-logo.png b/docs/assets/images/home-ops-kubernetes-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..05162e5dbd2db0ac4a1f070af49defb611d11e9b GIT binary patch literal 18691 zcmW(+18^i=7Y#SIZ95y=wrzW2Z*1GPy>YTJHnyE?Z0n!zuc?`?nyQ}ex&7|F=bm$3 zq>_Rp0xT{p2nYy*w3L_%@Hhs14?zC_e!>sNz5owDOk^d+K)(Nb74(!RgMdi2ON$As zd9Gjfc=+nAc%6LuUFAk81VDg-UGzjkh^wGd$Tpd;HPNp*%ddIfAIIK%i}OU9UUywn zc3od($LHpyu7oC`^17o^t+gJJc8s-EsaHrS8#$Ul^@Al5zb*RYKgYXRGK2i+FPKq! z@q<7K_Bq*fndYD2R{Ul3<7dX7goM+peqIc`?;EzP8xqohGQ$wCq*v*}+r8I?tt}6F z3uv>bMu5-HFk%QO4A}~hD)Ca>7BNW3QxR)OdyGv53|&Z3F2~E7>?@M)VrEfd)sR@; zEFnl?WoWQ!PC=Cp|89`5bZ_(SavBAECUaADOKw2uBS6q&1wHTApm#+${<51 zgns?ls8~CZR+J<P9p00VlRb4WXQ@87{)s*mRj}W{qTWu%(!iw;00C0 zDu{N%4`@N%L|PybD1RlPL~UVr!7PHU;3A08SP#}E8Kz)oKz7iM)NkA>$c6rtV>$}3x>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b*!E?>sR}u zT)gHCd0$(nLnNV7&Pgh1Pl3HCU$PudClc`bH>c9gPu<4Sx;oe5S@> zd$-GzyL(Zce09cH{q$CQHb*+OllkD%X-x2?uKe zo{ZDkdp#sI7%*Nn85-9u^s{QdA4`N|EeZCYj?*30DNX(3$(}Lb?@;~kinLE;*z9xGFH5utGFHwAd*ZnE$1**8f zj}`qxRL|{wc)@f}O&WQXjUeF{Y%6(6l`jJOrcxXc@SFrm$8=cY<%yc^iJ7c1ix;@% z4RAWDMyZj^_n`VEQ8_14GTqbCe~zZR0|T+kR9 zv|WC@=h69jV88E=ygESu4nI;2f{W^pQT-~=nWx_IGZ+Vq+@bBNJOun)B|qPC-Vq2u zXj79u=$D{w zp7~+VU`$XHby0o_d|6aFrYg2$EXZ2|0dtaAB+p6yZCFCiYH~ z`}$~65Cj5-NL&*@^AO6gS>>MDtEx^Ab(+pobx*U{;{J%!I`KVb~NLFSgQAn@Kun7GnV%JgvVN)ROR<= z*ZPGkt~NeW7_3za1$BZzDqI%@`MFnOp)Fq%(Y=%5y_3tT`q!XOt7yRy2NWQI0PNdY zkBBBz{!JkH)+1A!jbx%wkOTs7>=*Uej?;F(9IP|ySd(D-OQilD;N zidSM`hDfFyp8I;MDt{#+&-=w8A7aYKi-IQ*fVUp0M<9XnuPEODdS{4as*tYo+YS1N zz;_jrQ=KAovT$7x2tec4=Y!Ct!v9p&ZvZ_rL^ApCrnpO$M-}-R(6jeCAr2@&L*Ynh z*wF+kRf_%x5%~---&B3O?uI(O(DZ+2RrL{&ZyK_JNesuy?(g$e#qB1 zG9lQwy_wWmp%4US1J%GRgiu~^US9VUaq~BCyt=4HL9PL + {"time": "$time_iso8601", "remote_addr": "$proxy_protocol_addr", "x_forwarded_for": "$proxy_add_x_forwarded_for", + "request_id": "$req_id", "remote_user": "$remote_user", "bytes_sent": $bytes_sent, "request_time": $request_time, + "status": $status, "vhost": "$host", "request_proto": "$server_protocol", "path": "$uri", "request_query": "$args", + "request_length": $request_length, "duration": $request_time, "method": "$request_method", "http_referrer": "$http_referer", + "http_user_agent": "$http_user_agent"} + proxy-body-size: 0 + proxy-buffer-size: 16k + ssl-protocols: TLSv1.3 TLSv1.2 + metrics: + enabled: true + serviceMonitor: + enabled: true + namespaceSelector: + any: true + extraArgs: + default-ssl-certificate: "network/${SECRET_DOMAIN/./-}-staging-tls" + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: kubernetes.io/hostname + whenUnsatisfiable: DoNotSchedule + labelSelector: + matchLabels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/instance: ingress-nginx-external + app.kubernetes.io/component: controller + resources: + requests: + cpu: 100m + limits: + memory: 500Mi + defaultBackend: + enabled: false diff --git a/kubernetes/main/apps/network/ingress-nginx/external/kustomization.yaml b/kubernetes/main/apps/network/ingress-nginx/external/kustomization.yaml new file mode 100644 index 00000000..5dd7baca --- /dev/null +++ b/kubernetes/main/apps/network/ingress-nginx/external/kustomization.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./helmrelease.yaml diff --git a/kubernetes/main/apps/network/ingress-nginx/internal/helmrelease.yaml b/kubernetes/main/apps/network/ingress-nginx/internal/helmrelease.yaml new file mode 100644 index 00000000..ac0a4b15 --- /dev/null +++ b/kubernetes/main/apps/network/ingress-nginx/internal/helmrelease.yaml @@ -0,0 +1,84 @@ +--- +apiVersion: helm.toolkit.fluxcd.io/v2beta2 +kind: HelmRelease +metadata: + name: ingress-nginx-internal + namespace: network +spec: + interval: 30m + chart: + spec: + chart: ingress-nginx + version: 4.10.0 + sourceRef: + kind: HelmRepository + name: ingress-nginx + namespace: flux-system + install: + remediation: + retries: 3 + upgrade: + cleanupOnFail: true + remediation: + retries: 3 + values: + fullnameOverride: ingress-nginx-internal + controller: + replicaCount: 1 + service: + annotations: + io.cilium/lb-ipam-ips: "192.168.1.47" + externalTrafficPolicy: Cluster + ingressClassResource: + name: internal + default: true + controllerValue: k8s.io/internal + admissionWebhooks: + objectSelector: + matchExpressions: + - key: ingress-class + operator: In + values: ["internal"] + config: + client-body-buffer-size: 100M + client-body-timeout: 120 + client-header-timeout: 120 + enable-brotli: "true" + enable-real-ip: "true" + hsts-max-age: 31449600 + keep-alive-requests: 10000 + keep-alive: 120 + log-format-escape-json: "true" + log-format-upstream: > + {"time": "$time_iso8601", "remote_addr": "$proxy_protocol_addr", "x_forwarded_for": "$proxy_add_x_forwarded_for", + "request_id": "$req_id", "remote_user": "$remote_user", "bytes_sent": $bytes_sent, "request_time": $request_time, + "status": $status, "vhost": "$host", "request_proto": "$server_protocol", "path": "$uri", "request_query": "$args", + "request_length": $request_length, "duration": $request_time, "method": "$request_method", "http_referrer": "$http_referer", + "http_user_agent": "$http_user_agent"} + proxy-body-size: 0 + proxy-buffer-size: 16k + ssl-protocols: TLSv1.3 TLSv1.2 + metrics: + enabled: true + serviceMonitor: + enabled: true + namespaceSelector: + any: true + extraArgs: + default-ssl-certificate: "network/${SECRET_DOMAIN/./-}-staging-tls" + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: kubernetes.io/hostname + whenUnsatisfiable: DoNotSchedule + labelSelector: + matchLabels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/instance: ingress-nginx-internal + app.kubernetes.io/component: controller + resources: + requests: + cpu: 100m + limits: + memory: 500Mi + defaultBackend: + enabled: false diff --git a/kubernetes/main/apps/network/ingress-nginx/internal/kustomization.yaml b/kubernetes/main/apps/network/ingress-nginx/internal/kustomization.yaml new file mode 100644 index 00000000..5dd7baca --- /dev/null +++ b/kubernetes/main/apps/network/ingress-nginx/internal/kustomization.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./helmrelease.yaml diff --git a/kubernetes/main/apps/network/ingress-nginx/ks.yaml b/kubernetes/main/apps/network/ingress-nginx/ks.yaml new file mode 100644 index 00000000..8b031ca7 --- /dev/null +++ b/kubernetes/main/apps/network/ingress-nginx/ks.yaml @@ -0,0 +1,66 @@ +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app ingress-nginx-certificates + namespace: flux-system +spec: + targetNamespace: network + commonMetadata: + labels: + app.kubernetes.io/name: *app + dependsOn: + - name: cert-manager-issuers + path: ./kubernetes/apps/network/ingress-nginx/certificates + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: true + interval: 30m + retryInterval: 1m + timeout: 5m +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app ingress-nginx-internal + namespace: flux-system +spec: + targetNamespace: network + commonMetadata: + labels: + app.kubernetes.io/name: *app + dependsOn: + - name: ingress-nginx-certificates + path: ./kubernetes/apps/network/ingress-nginx/internal + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: false + interval: 30m + retryInterval: 1m + timeout: 5m +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app ingress-nginx-external + namespace: flux-system +spec: + targetNamespace: network + commonMetadata: + labels: + app.kubernetes.io/name: *app + dependsOn: + - name: ingress-nginx-certificates + path: ./kubernetes/apps/network/ingress-nginx/external + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: false + interval: 30m + retryInterval: 1m + timeout: 5m diff --git a/kubernetes/main/apps/network/k8s-gateway/app/helmrelease.yaml b/kubernetes/main/apps/network/k8s-gateway/app/helmrelease.yaml new file mode 100644 index 00000000..14120e6a --- /dev/null +++ b/kubernetes/main/apps/network/k8s-gateway/app/helmrelease.yaml @@ -0,0 +1,32 @@ +--- +apiVersion: helm.toolkit.fluxcd.io/v2beta2 +kind: HelmRelease +metadata: + name: k8s-gateway +spec: + interval: 30m + chart: + spec: + chart: k8s-gateway + version: 2.4.0 + sourceRef: + kind: HelmRepository + name: k8s-gateway + namespace: flux-system + install: + remediation: + retries: 3 + upgrade: + cleanupOnFail: true + remediation: + retries: 3 + values: + fullnameOverride: k8s-gateway + domain: "${SECRET_DOMAIN}" + ttl: 1 + service: + type: LoadBalancer + port: 53 + annotations: + io.cilium/lb-ipam-ips: "192.168.1.49" + externalTrafficPolicy: Cluster diff --git a/kubernetes/main/apps/network/k8s-gateway/app/kustomization.yaml b/kubernetes/main/apps/network/k8s-gateway/app/kustomization.yaml new file mode 100644 index 00000000..5dd7baca --- /dev/null +++ b/kubernetes/main/apps/network/k8s-gateway/app/kustomization.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./helmrelease.yaml diff --git a/kubernetes/main/apps/network/k8s-gateway/ks.yaml b/kubernetes/main/apps/network/k8s-gateway/ks.yaml new file mode 100644 index 00000000..c77a3a31 --- /dev/null +++ b/kubernetes/main/apps/network/k8s-gateway/ks.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app k8s-gateway + namespace: flux-system +spec: + targetNamespace: network + commonMetadata: + labels: + app.kubernetes.io/name: *app + path: ./kubernetes/apps/network/k8s-gateway/app + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: false + interval: 30m + retryInterval: 1m + timeout: 5m diff --git a/kubernetes/main/apps/network/kustomization.yaml b/kubernetes/main/apps/network/kustomization.yaml new file mode 100644 index 00000000..e6f8ddc1 --- /dev/null +++ b/kubernetes/main/apps/network/kustomization.yaml @@ -0,0 +1,10 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./namespace.yaml + - ./cloudflared/ks.yaml + - ./echo-server/ks.yaml + - ./external-dns/ks.yaml + - ./ingress-nginx/ks.yaml + - ./k8s-gateway/ks.yaml diff --git a/kubernetes/main/apps/network/namespace.yaml b/kubernetes/main/apps/network/namespace.yaml new file mode 100644 index 00000000..4d78d7b1 --- /dev/null +++ b/kubernetes/main/apps/network/namespace.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: network + labels: + kustomize.toolkit.fluxcd.io/prune: disabled diff --git a/kubernetes/main/apps/openebs-system/kustomization.yaml b/kubernetes/main/apps/openebs-system/kustomization.yaml new file mode 100644 index 00000000..9cd8d4e4 --- /dev/null +++ b/kubernetes/main/apps/openebs-system/kustomization.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./namespace.yaml + - ./openebs/ks.yaml diff --git a/kubernetes/main/apps/openebs-system/namespace.yaml b/kubernetes/main/apps/openebs-system/namespace.yaml new file mode 100644 index 00000000..f173c6c9 --- /dev/null +++ b/kubernetes/main/apps/openebs-system/namespace.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: openebs-system + labels: + kustomize.toolkit.fluxcd.io/prune: disabled diff --git a/kubernetes/main/apps/openebs-system/openebs/app/helmrelease.yaml b/kubernetes/main/apps/openebs-system/openebs/app/helmrelease.yaml new file mode 100644 index 00000000..e7c1b45c --- /dev/null +++ b/kubernetes/main/apps/openebs-system/openebs/app/helmrelease.yaml @@ -0,0 +1,36 @@ +--- +apiVersion: helm.toolkit.fluxcd.io/v2beta2 +kind: HelmRelease +metadata: + name: openebs +spec: + interval: 30m + chart: + spec: + chart: openebs + version: 3.10.0 + sourceRef: + kind: HelmRepository + name: openebs + namespace: flux-system + install: + remediation: + retries: 3 + upgrade: + cleanupOnFail: true + remediation: + retries: 3 + values: + ndm: + enabled: false + ndmOperator: + enabled: false + localprovisioner: + enabled: true + deviceClass: + enabled: false + hostpathClass: + enabled: true + name: openebs-hostpath + isDefaultClass: false + basePath: /var/openebs/local diff --git a/kubernetes/main/apps/openebs-system/openebs/app/kustomization.yaml b/kubernetes/main/apps/openebs-system/openebs/app/kustomization.yaml new file mode 100644 index 00000000..5dd7baca --- /dev/null +++ b/kubernetes/main/apps/openebs-system/openebs/app/kustomization.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./helmrelease.yaml diff --git a/kubernetes/main/apps/openebs-system/openebs/ks.yaml b/kubernetes/main/apps/openebs-system/openebs/ks.yaml new file mode 100644 index 00000000..fde2e354 --- /dev/null +++ b/kubernetes/main/apps/openebs-system/openebs/ks.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app openebs + namespace: flux-system +spec: + targetNamespace: openebs-system + commonMetadata: + labels: + app.kubernetes.io/name: *app + path: ./kubernetes/apps/openebs-system/openebs/app + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: false + interval: 30m + retryInterval: 1m + timeout: 5m diff --git a/kubernetes/main/apps/system-upgrade/k3s/app/kustomization.yaml b/kubernetes/main/apps/system-upgrade/k3s/app/kustomization.yaml new file mode 100644 index 00000000..c159f45b --- /dev/null +++ b/kubernetes/main/apps/system-upgrade/k3s/app/kustomization.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./plan.yaml diff --git a/kubernetes/main/apps/system-upgrade/k3s/app/plan.yaml b/kubernetes/main/apps/system-upgrade/k3s/app/plan.yaml new file mode 100644 index 00000000..38784cd5 --- /dev/null +++ b/kubernetes/main/apps/system-upgrade/k3s/app/plan.yaml @@ -0,0 +1,50 @@ +--- +apiVersion: upgrade.cattle.io/v1 +kind: Plan +metadata: + name: controllers +spec: + version: "${KUBE_VERSION}" + upgrade: + image: rancher/k3s-upgrade + serviceAccountName: system-upgrade + concurrency: 1 + cordon: true + nodeSelector: + matchExpressions: + - key: node-role.kubernetes.io/control-plane + operator: Exists + tolerations: + - effect: NoSchedule + operator: Exists + - effect: NoExecute + operator: Exists + - key: node-role.kubernetes.io/control-plane + effect: NoSchedule + operator: Exists + - key: node-role.kubernetes.io/master + effect: NoSchedule + operator: Exists + - key: node-role.kubernetes.io/etcd + effect: NoExecute + operator: Exists + - key: CriticalAddonsOnly + operator: Exists +--- +apiVersion: upgrade.cattle.io/v1 +kind: Plan +metadata: + name: workers +spec: + version: "${KUBE_VERSION}" + serviceAccountName: system-upgrade + concurrency: 1 + nodeSelector: + matchExpressions: + - key: node-role.kubernetes.io/control-plane + operator: DoesNotExist + prepare: + image: rancher/k3s-upgrade + args: ["prepare", "controllers"] + upgrade: + image: rancher/k3s-upgrade diff --git a/kubernetes/main/apps/system-upgrade/k3s/ks.yaml b/kubernetes/main/apps/system-upgrade/k3s/ks.yaml new file mode 100644 index 00000000..53c062ad --- /dev/null +++ b/kubernetes/main/apps/system-upgrade/k3s/ks.yaml @@ -0,0 +1,26 @@ +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app system-upgrade-k3s + namespace: flux-system +spec: + targetNamespace: system-upgrade + commonMetadata: + labels: + app.kubernetes.io/name: *app + dependsOn: + - name: system-upgrade-controller + path: ./kubernetes/apps/system-upgrade/k3s/app + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: false + interval: 30m + retryInterval: 1m + timeout: 5m + postBuild: + substitute: + # renovate: datasource=github-releases depName=k3s-io/k3s + KUBE_VERSION: v1.29.3+k3s1 diff --git a/kubernetes/main/apps/system-upgrade/kustomization.yaml b/kubernetes/main/apps/system-upgrade/kustomization.yaml new file mode 100644 index 00000000..e0b2bf29 --- /dev/null +++ b/kubernetes/main/apps/system-upgrade/kustomization.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./namespace.yaml + - ./system-upgrade-controller/ks.yaml + - ./k3s/ks.yaml diff --git a/kubernetes/main/apps/system-upgrade/namespace.yaml b/kubernetes/main/apps/system-upgrade/namespace.yaml new file mode 100644 index 00000000..5ea024dd --- /dev/null +++ b/kubernetes/main/apps/system-upgrade/namespace.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: system-upgrade + labels: + kustomize.toolkit.fluxcd.io/prune: disabled diff --git a/kubernetes/main/apps/system-upgrade/system-upgrade-controller/app/helmrelease.yaml b/kubernetes/main/apps/system-upgrade/system-upgrade-controller/app/helmrelease.yaml new file mode 100644 index 00000000..a28b8ed8 --- /dev/null +++ b/kubernetes/main/apps/system-upgrade/system-upgrade-controller/app/helmrelease.yaml @@ -0,0 +1,101 @@ +--- +apiVersion: helm.toolkit.fluxcd.io/v2beta2 +kind: HelmRelease +metadata: + name: &app system-upgrade-controller +spec: + interval: 30m + chart: + spec: + chart: app-template + version: 3.1.0 + sourceRef: + kind: HelmRepository + name: bjw-s + namespace: flux-system + install: + remediation: + retries: 3 + upgrade: + cleanupOnFail: true + remediation: + retries: 3 + values: + controllers: + system-upgrade-controller: + strategy: RollingUpdate + containers: + app: + image: + repository: docker.io/rancher/system-upgrade-controller + tag: v0.13.4 + env: + SYSTEM_UPGRADE_CONTROLLER_DEBUG: false + SYSTEM_UPGRADE_CONTROLLER_THREADS: 2 + SYSTEM_UPGRADE_JOB_ACTIVE_DEADLINE_SECONDS: 900 + SYSTEM_UPGRADE_JOB_BACKOFF_LIMIT: 99 + SYSTEM_UPGRADE_JOB_IMAGE_PULL_POLICY: IfNotPresent + SYSTEM_UPGRADE_JOB_KUBECTL_IMAGE: registry.k8s.io/kubectl:v1.30.0 + SYSTEM_UPGRADE_JOB_PRIVILEGED: true + SYSTEM_UPGRADE_JOB_TTL_SECONDS_AFTER_FINISH: 900 + SYSTEM_UPGRADE_PLAN_POLLING_INTERVAL: 15m + SYSTEM_UPGRADE_CONTROLLER_NAME: *app + SYSTEM_UPGRADE_CONTROLLER_NAMESPACE: + valueFrom: + fieldRef: + fieldPath: metadata.namespace + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: { drop: ["ALL"] } + defaultPodOptions: + securityContext: + runAsNonRoot: true + runAsUser: 65534 + runAsGroup: 65534 + seccompProfile: { type: RuntimeDefault } + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: node-role.kubernetes.io/control-plane + operator: Exists + tolerations: + - key: CriticalAddonsOnly + operator: Exists + - key: node-role.kubernetes.io/control-plane + operator: Exists + effect: NoSchedule + - key: node-role.kubernetes.io/master + operator: Exists + effect: NoSchedule + serviceAccount: + create: true + name: system-upgrade + persistence: + tmp: + type: emptyDir + globalMounts: + - path: /tmp + etc-ssl: + type: hostPath + hostPath: /etc/ssl + hostPathType: DirectoryOrCreate + globalMounts: + - path: /etc/ssl + readOnly: true + etc-pki: + type: hostPath + hostPath: /etc/pki + hostPathType: DirectoryOrCreate + globalMounts: + - path: /etc/pki + readOnly: true + etc-ca-certificates: + type: hostPath + hostPath: /etc/ca-certificates + hostPathType: DirectoryOrCreate + globalMounts: + - path: /etc/ca-certificates + readOnly: true diff --git a/kubernetes/main/apps/system-upgrade/system-upgrade-controller/app/kustomization.yaml b/kubernetes/main/apps/system-upgrade/system-upgrade-controller/app/kustomization.yaml new file mode 100644 index 00000000..49f35511 --- /dev/null +++ b/kubernetes/main/apps/system-upgrade/system-upgrade-controller/app/kustomization.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + # renovate: datasource=github-releases depName=rancher/system-upgrade-controller + - https://github.com/rancher/system-upgrade-controller/releases/download/v0.13.4/crd.yaml + - helmrelease.yaml + - rbac.yaml diff --git a/kubernetes/main/apps/system-upgrade/system-upgrade-controller/app/rbac.yaml b/kubernetes/main/apps/system-upgrade/system-upgrade-controller/app/rbac.yaml new file mode 100644 index 00000000..123677c2 --- /dev/null +++ b/kubernetes/main/apps/system-upgrade/system-upgrade-controller/app/rbac.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: system-upgrade +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cluster-admin +subjects: + - kind: ServiceAccount + name: system-upgrade + namespace: system-upgrade diff --git a/kubernetes/main/apps/system-upgrade/system-upgrade-controller/ks.yaml b/kubernetes/main/apps/system-upgrade/system-upgrade-controller/ks.yaml new file mode 100644 index 00000000..55c93987 --- /dev/null +++ b/kubernetes/main/apps/system-upgrade/system-upgrade-controller/ks.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app system-upgrade-controller + namespace: flux-system +spec: + targetNamespace: system-upgrade + commonMetadata: + labels: + app.kubernetes.io/name: *app + path: ./kubernetes/apps/system-upgrade/system-upgrade-controller/app + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: true + interval: 30m + retryInterval: 1m + timeout: 5m diff --git a/kubernetes/main/bootstrap/flux/kustomization.yaml b/kubernetes/main/bootstrap/flux/kustomization.yaml new file mode 100644 index 00000000..02af98f0 --- /dev/null +++ b/kubernetes/main/bootstrap/flux/kustomization.yaml @@ -0,0 +1,61 @@ +# IMPORTANT: This file is not tracked by flux and should never be. Its +# purpose is to only install the Flux components and CRDs into your cluster. +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - github.com/fluxcd/flux2/manifests/install?ref=v2.2.3 +patches: + # Remove the default network policies + - patch: |- + $patch: delete + apiVersion: networking.k8s.io/v1 + kind: NetworkPolicy + metadata: + name: not-used + target: + group: networking.k8s.io + kind: NetworkPolicy + # Resources renamed to match those installed by oci://ghcr.io/fluxcd/flux-manifests + - target: + kind: ResourceQuota + name: critical-pods + patch: | + - op: replace + path: /metadata/name + value: critical-pods-flux-system + - target: + kind: ClusterRoleBinding + name: cluster-reconciler + patch: | + - op: replace + path: /metadata/name + value: cluster-reconciler-flux-system + - target: + kind: ClusterRoleBinding + name: crd-controller + patch: | + - op: replace + path: /metadata/name + value: crd-controller-flux-system + - target: + kind: ClusterRole + name: crd-controller + patch: | + - op: replace + path: /metadata/name + value: crd-controller-flux-system + - target: + kind: ClusterRole + name: flux-edit + patch: | + - op: replace + path: /metadata/name + value: flux-edit-flux-system + - target: + kind: ClusterRole + name: flux-view + patch: | + - op: replace + path: /metadata/name + value: flux-view-flux-system diff --git a/kubernetes/main/flux/apps.yaml b/kubernetes/main/flux/apps.yaml new file mode 100644 index 00000000..55cca451 --- /dev/null +++ b/kubernetes/main/flux/apps.yaml @@ -0,0 +1,56 @@ +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: cluster-apps + namespace: flux-system +spec: + interval: 30m + path: ./kubernetes/apps + prune: true + sourceRef: + kind: GitRepository + name: home-ops + decryption: + provider: sops + secretRef: + name: sops-age + postBuild: + substituteFrom: + - kind: ConfigMap + name: cluster-settings + - kind: Secret + name: cluster-secrets + - kind: ConfigMap + name: cluster-settings-user + optional: true + - kind: Secret + name: cluster-secrets-user + optional: true + patches: + - patch: |- + apiVersion: kustomize.toolkit.fluxcd.io/v1 + kind: Kustomization + metadata: + name: not-used + spec: + decryption: + provider: sops + secretRef: + name: sops-age + postBuild: + substituteFrom: + - kind: ConfigMap + name: cluster-settings + - kind: Secret + name: cluster-secrets + - kind: ConfigMap + name: cluster-settings-user + optional: true + - kind: Secret + name: cluster-secrets-user + optional: true + target: + group: kustomize.toolkit.fluxcd.io + kind: Kustomization + labelSelector: substitution.flux.home.arpa/disabled notin (true) diff --git a/kubernetes/main/flux/config/cluster.yaml b/kubernetes/main/flux/config/cluster.yaml new file mode 100644 index 00000000..153c3366 --- /dev/null +++ b/kubernetes/main/flux/config/cluster.yaml @@ -0,0 +1,44 @@ +--- +# yaml-language-server: $schema=https://github.com/fluxcd-community/flux2-schemas/raw/main/gitrepository-source-v1.json +apiVersion: source.toolkit.fluxcd.io/v1 +kind: GitRepository +metadata: + name: home-ops + namespace: flux-system +spec: + interval: 30m + url: "ssh://git@github.com/prehor/home-ops.git" + secretRef: + name: github-deploy-key + ref: + branch: "main" + ignore: | + # exclude all + /* + # include kubernetes directory + !/kubernetes +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/main/kustomization-kustomize-v1.json +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: cluster + namespace: flux-system +spec: + interval: 30m + path: ./kubernetes/flux + prune: true + wait: false + sourceRef: + kind: GitRepository + name: home-ops + decryption: + provider: sops + secretRef: + name: sops-age + postBuild: + substituteFrom: + - kind: ConfigMap + name: cluster-settings + - kind: Secret + name: cluster-secrets diff --git a/kubernetes/main/flux/config/flux.yaml b/kubernetes/main/flux/config/flux.yaml new file mode 100644 index 00000000..b9ad109d --- /dev/null +++ b/kubernetes/main/flux/config/flux.yaml @@ -0,0 +1,88 @@ +--- +# yaml-language-server: $schema=https://github.com/fluxcd-community/flux2-schemas/raw/main/ocirepository-source-v1beta2.json +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: OCIRepository +metadata: + name: flux-manifests + namespace: flux-system +spec: + interval: 10m + url: oci://ghcr.io/fluxcd/flux-manifests + ref: + tag: v2.2.3 +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/main/kustomization-kustomize-v1.json +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: flux + namespace: flux-system +spec: + interval: 10m + path: ./ + prune: true + wait: true + sourceRef: + kind: OCIRepository + name: flux-manifests + patches: + # Remove the network policies that does not work with k3s + - patch: | + $patch: delete + apiVersion: networking.k8s.io/v1 + kind: NetworkPolicy + metadata: + name: not-used + target: + group: networking.k8s.io + kind: NetworkPolicy + # Increase the number of reconciliations that can be performed in parallel and bump the resources limits + # https://fluxcd.io/flux/cheatsheets/bootstrap/#increase-the-number-of-workers + - patch: | + - op: add + path: /spec/template/spec/containers/0/args/- + value: --concurrent=8 + - op: add + path: /spec/template/spec/containers/0/args/- + value: --kube-api-qps=500 + - op: add + path: /spec/template/spec/containers/0/args/- + value: --kube-api-burst=1000 + - op: add + path: /spec/template/spec/containers/0/args/- + value: --requeue-dependency=5s + target: + kind: Deployment + name: (kustomize-controller|helm-controller|source-controller) + - patch: | + apiVersion: apps/v1 + kind: Deployment + metadata: + name: not-used + spec: + template: + spec: + containers: + - name: manager + resources: + limits: + cpu: 2000m + memory: 2Gi + target: + kind: Deployment + name: (kustomize-controller|helm-controller|source-controller) + # Enable Helm near OOM detection + # https://fluxcd.io/flux/cheatsheets/bootstrap/#enable-helm-near-oom-detection + - patch: | + - op: add + path: /spec/template/spec/containers/0/args/- + value: --feature-gates=OOMWatch=true + - op: add + path: /spec/template/spec/containers/0/args/- + value: --oom-watch-memory-threshold=95 + - op: add + path: /spec/template/spec/containers/0/args/- + value: --oom-watch-interval=500ms + target: + kind: Deployment + name: helm-controller diff --git a/kubernetes/main/flux/config/kustomization.yaml b/kubernetes/main/flux/config/kustomization.yaml new file mode 100644 index 00000000..ef231746 --- /dev/null +++ b/kubernetes/main/flux/config/kustomization.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./flux.yaml + - ./cluster.yaml diff --git a/kubernetes/main/flux/repositories/git/kustomization.yaml b/kubernetes/main/flux/repositories/git/kustomization.yaml new file mode 100644 index 00000000..fe0f332a --- /dev/null +++ b/kubernetes/main/flux/repositories/git/kustomization.yaml @@ -0,0 +1,4 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: [] diff --git a/kubernetes/main/flux/repositories/helm/bjw-s.yaml b/kubernetes/main/flux/repositories/helm/bjw-s.yaml new file mode 100644 index 00000000..df0c6474 --- /dev/null +++ b/kubernetes/main/flux/repositories/helm/bjw-s.yaml @@ -0,0 +1,10 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: HelmRepository +metadata: + name: bjw-s + namespace: flux-system +spec: + type: oci + interval: 5m + url: oci://ghcr.io/bjw-s/helm diff --git a/kubernetes/main/flux/repositories/helm/cilium.yaml b/kubernetes/main/flux/repositories/helm/cilium.yaml new file mode 100644 index 00000000..51c65d69 --- /dev/null +++ b/kubernetes/main/flux/repositories/helm/cilium.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: HelmRepository +metadata: + name: cilium + namespace: flux-system +spec: + interval: 1h + url: https://helm.cilium.io diff --git a/kubernetes/main/flux/repositories/helm/external-dns.yaml b/kubernetes/main/flux/repositories/helm/external-dns.yaml new file mode 100644 index 00000000..b76b9662 --- /dev/null +++ b/kubernetes/main/flux/repositories/helm/external-dns.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: HelmRepository +metadata: + name: external-dns + namespace: flux-system +spec: + interval: 1h + url: https://kubernetes-sigs.github.io/external-dns diff --git a/kubernetes/main/flux/repositories/helm/ingress-nginx.yaml b/kubernetes/main/flux/repositories/helm/ingress-nginx.yaml new file mode 100644 index 00000000..4dcf5eea --- /dev/null +++ b/kubernetes/main/flux/repositories/helm/ingress-nginx.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: HelmRepository +metadata: + name: ingress-nginx + namespace: flux-system +spec: + interval: 1h + url: https://kubernetes.github.io/ingress-nginx diff --git a/kubernetes/main/flux/repositories/helm/jetstack.yaml b/kubernetes/main/flux/repositories/helm/jetstack.yaml new file mode 100644 index 00000000..1b4982d6 --- /dev/null +++ b/kubernetes/main/flux/repositories/helm/jetstack.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: HelmRepository +metadata: + name: jetstack + namespace: flux-system +spec: + interval: 1h + url: https://charts.jetstack.io diff --git a/kubernetes/main/flux/repositories/helm/k8s-gateway.yaml b/kubernetes/main/flux/repositories/helm/k8s-gateway.yaml new file mode 100644 index 00000000..51185b6e --- /dev/null +++ b/kubernetes/main/flux/repositories/helm/k8s-gateway.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: HelmRepository +metadata: + name: k8s-gateway + namespace: flux-system +spec: + interval: 1h + url: https://ori-edge.github.io/k8s_gateway diff --git a/kubernetes/main/flux/repositories/helm/kustomization.yaml b/kubernetes/main/flux/repositories/helm/kustomization.yaml new file mode 100644 index 00000000..d9b76950 --- /dev/null +++ b/kubernetes/main/flux/repositories/helm/kustomization.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./bjw-s.yaml + - ./cilium.yaml + - ./external-dns.yaml + - ./ingress-nginx.yaml + - ./k8s-gateway.yaml + - ./jetstack.yaml + - ./metrics-server.yaml + - ./openebs.yaml + - ./stakater.yaml diff --git a/kubernetes/main/flux/repositories/helm/metrics-server.yaml b/kubernetes/main/flux/repositories/helm/metrics-server.yaml new file mode 100644 index 00000000..57e7aa0c --- /dev/null +++ b/kubernetes/main/flux/repositories/helm/metrics-server.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: HelmRepository +metadata: + name: metrics-server + namespace: flux-system +spec: + interval: 1h + url: https://kubernetes-sigs.github.io/metrics-server diff --git a/kubernetes/main/flux/repositories/helm/openebs.yaml b/kubernetes/main/flux/repositories/helm/openebs.yaml new file mode 100644 index 00000000..d0f105e6 --- /dev/null +++ b/kubernetes/main/flux/repositories/helm/openebs.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: HelmRepository +metadata: + name: openebs + namespace: flux-system +spec: + interval: 1h + url: https://openebs.github.io/charts diff --git a/kubernetes/main/flux/repositories/helm/stakater.yaml b/kubernetes/main/flux/repositories/helm/stakater.yaml new file mode 100644 index 00000000..1846e8ae --- /dev/null +++ b/kubernetes/main/flux/repositories/helm/stakater.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: HelmRepository +metadata: + name: stakater + namespace: flux-system +spec: + interval: 1h + url: https://stakater.github.io/stakater-charts diff --git a/kubernetes/main/flux/repositories/kustomization.yaml b/kubernetes/main/flux/repositories/kustomization.yaml new file mode 100644 index 00000000..d158d426 --- /dev/null +++ b/kubernetes/main/flux/repositories/kustomization.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./git + - ./helm + - ./oci diff --git a/kubernetes/main/flux/repositories/oci/kustomization.yaml b/kubernetes/main/flux/repositories/oci/kustomization.yaml new file mode 100644 index 00000000..fe0f332a --- /dev/null +++ b/kubernetes/main/flux/repositories/oci/kustomization.yaml @@ -0,0 +1,4 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: [] diff --git a/kubernetes/main/flux/vars/cluster-secrets.sops.yaml b/kubernetes/main/flux/vars/cluster-secrets.sops.yaml new file mode 100644 index 00000000..bc1d4cae --- /dev/null +++ b/kubernetes/main/flux/vars/cluster-secrets.sops.yaml @@ -0,0 +1,30 @@ +apiVersion: v1 +kind: Secret +metadata: + name: cluster-secrets + namespace: flux-system +stringData: + SECRET_CLUSTER_NAME: ENC[AES256_GCM,data:3i/FUVaesvE=,iv:1q3r8FC/oeCX46hi9ROyrGVhUkwk81c1tQZQHmVXd+k=,tag:ctkNp30RUQmh+HG2w169iQ==,type:str] + SECRET_DOMAIN: ENC[AES256_GCM,data:0r9nF8Y=,iv:pTfIeRsxhWcJczBoWaLud8gIfxhlNZ/S7pfUBjct99M=,tag:pcjJXMulP5A3p/TOJK6lxQ==,type:str] + SECRET_ACME_EMAIL: ENC[AES256_GCM,data:ocMoiAA04XI=,iv:Oqn7NoiaEzjwkRiWrFTptYxMIty2a6ZEi+nf7YordYE=,tag:QDqmOHhV2ZPOlG4+icRi4g==,type:str] + SECRET_CLOUDFLARE_TUNNEL_ID: ENC[AES256_GCM,data:mX8r6K+3U7TU5bAw9HccDff6dibFaYfRePLab+mKcqLtRB8k,iv:wJUyMBIzv8qCAcRxWPFL8sEwuuaz9UKTHB/C216Zn2I=,tag:xlGVwhit/wgEwz3Dl+jWcg==,type:str] +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1ve9kzacrwq7l9l0emvs326uk6t576d75r596e083r2tq6xu28qcsacy3s7 + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBZRDE0Uk5KaW5uRkNHaGpv + VkgyV0N2RDNZS2Q4bXd2TVMxZWw4VStRc1hrCm5hNnA0ZEZTV2QyeEx1Zm5IbmZy + am9TTk92V2RMWnlHcFZpZVcyb3FQRDQKLS0tIFQ3aVBhajVlZDJSWEtCcXhzc2Q3 + ME5zYlpMbVk3NHljVEdJNk1ocG91c28KNfYzJ15YFgpNvmM4mWC7FD4jTu/IwnHx + SWN3WbZK2qc4oTrNBKTA8DQ+7MF4VbbBmq7FXVNYGVns9xDrgVO9DQ== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2024-04-21T17:52:58Z" + mac: ENC[AES256_GCM,data:5EFSRRPIGzpll93vlGVBqHAEPm+vaUJI/re3l2IhrTqMUzX1BjcbkcdDSjEG2rdL06YLcFsUBhVBvBATuNThBRaRKO6YRpKyug5FaII/wbQqnqAPDD0xncLHaq0Bme34iIQ6jdbOisvuaOVBQYXZAyJUIy9RC8IL5cEdP79xAAg=,iv:QGV4eSuBl3rhcdwz3iyYPA3SQFGYvXxoaHvRvJxoKDY=,tag:SB00tN7Qlp0KsDHg72Y2gw==,type:str] + pgp: [] + encrypted_regex: ^(data|stringData)$ + version: 3.8.1 diff --git a/kubernetes/main/flux/vars/cluster-settings.yaml b/kubernetes/main/flux/vars/cluster-settings.yaml new file mode 100644 index 00000000..4083ce78 --- /dev/null +++ b/kubernetes/main/flux/vars/cluster-settings.yaml @@ -0,0 +1,10 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: cluster-settings + namespace: flux-system +data: + TIMEZONE: "Europe/Prague" + CLUSTER_CIDR: "10.40.0.0/16" + NODE_CIDR: "192.168.1.0/24" diff --git a/kubernetes/main/flux/vars/kustomization.yaml b/kubernetes/main/flux/vars/kustomization.yaml new file mode 100644 index 00000000..8db2fe91 --- /dev/null +++ b/kubernetes/main/flux/vars/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./cluster-settings.yaml + - ./cluster-secrets.sops.yaml diff --git a/kubernetes/storage/apps/cert-manager/cert-manager/app/helmrelease.yaml b/kubernetes/storage/apps/cert-manager/cert-manager/app/helmrelease.yaml new file mode 100644 index 00000000..423eb1f1 --- /dev/null +++ b/kubernetes/storage/apps/cert-manager/cert-manager/app/helmrelease.yaml @@ -0,0 +1,35 @@ +--- +apiVersion: helm.toolkit.fluxcd.io/v2beta2 +kind: HelmRelease +metadata: + name: cert-manager +spec: + interval: 30m + chart: + spec: + chart: cert-manager + version: v1.14.4 + sourceRef: + kind: HelmRepository + name: jetstack + namespace: flux-system + install: + remediation: + retries: 3 + upgrade: + cleanupOnFail: true + remediation: + retries: 3 + values: + installCRDs: true + dns01RecursiveNameservers: 1.1.1.1:53,9.9.9.9:53 + dns01RecursiveNameserversOnly: true + podDnsPolicy: None + podDnsConfig: + nameservers: + - "1.1.1.1" + - "9.9.9.9" + prometheus: + enabled: true + servicemonitor: + enabled: true diff --git a/kubernetes/storage/apps/cert-manager/cert-manager/app/kustomization.yaml b/kubernetes/storage/apps/cert-manager/cert-manager/app/kustomization.yaml new file mode 100644 index 00000000..5dd7baca --- /dev/null +++ b/kubernetes/storage/apps/cert-manager/cert-manager/app/kustomization.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./helmrelease.yaml diff --git a/kubernetes/storage/apps/cert-manager/cert-manager/issuers/issuers.yaml b/kubernetes/storage/apps/cert-manager/cert-manager/issuers/issuers.yaml new file mode 100644 index 00000000..1cf7148a --- /dev/null +++ b/kubernetes/storage/apps/cert-manager/cert-manager/issuers/issuers.yaml @@ -0,0 +1,39 @@ +apiVersion: cert-manager.io/v1 +kind: ClusterIssuer +metadata: + name: letsencrypt-production +spec: + acme: + server: https://acme-v02.api.letsencrypt.org/directory + email: "${SECRET_ACME_EMAIL}" + privateKeySecretRef: + name: letsencrypt-production + solvers: + - dns01: + cloudflare: + apiTokenSecretRef: + name: cert-manager-secret + key: api-token + selector: + dnsZones: + - "${SECRET_DOMAIN}" +--- +apiVersion: cert-manager.io/v1 +kind: ClusterIssuer +metadata: + name: letsencrypt-staging +spec: + acme: + server: https://acme-staging-v02.api.letsencrypt.org/directory + email: "${SECRET_ACME_EMAIL}" + privateKeySecretRef: + name: letsencrypt-staging + solvers: + - dns01: + cloudflare: + apiTokenSecretRef: + name: cert-manager-secret + key: api-token + selector: + dnsZones: + - "${SECRET_DOMAIN}" diff --git a/kubernetes/storage/apps/cert-manager/cert-manager/issuers/kustomization.yaml b/kubernetes/storage/apps/cert-manager/cert-manager/issuers/kustomization.yaml new file mode 100644 index 00000000..17754be6 --- /dev/null +++ b/kubernetes/storage/apps/cert-manager/cert-manager/issuers/kustomization.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./secret.sops.yaml + - ./issuers.yaml diff --git a/kubernetes/storage/apps/cert-manager/cert-manager/issuers/secret.sops.yaml b/kubernetes/storage/apps/cert-manager/cert-manager/issuers/secret.sops.yaml new file mode 100644 index 00000000..e75dfd74 --- /dev/null +++ b/kubernetes/storage/apps/cert-manager/cert-manager/issuers/secret.sops.yaml @@ -0,0 +1,26 @@ +apiVersion: v1 +kind: Secret +metadata: + name: cert-manager-secret +stringData: + api-token: ENC[AES256_GCM,data:serVGqB2lBG2+zw3fGhL7taW4OvHWQ7kfve+HoYOOrh8wp4fr9xeBQ==,iv:m1ZH5voFeGFcTbst1+o5qe666U0/YlGIczdOPz3y38o=,tag:4Y7VY6FqKtiqhVIFFd1b4A==,type:str] +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1ve9kzacrwq7l9l0emvs326uk6t576d75r596e083r2tq6xu28qcsacy3s7 + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB2NDNpK2Fweis4S0c2SGd5 + V3RCTDFsYnVqR2tYUDYwZHNHZ3MrK2tZWlJ3CnNvR2JSNlJyYlFJbmluOE1reWU4 + TFhVTnBtZk5ja3JLWHpFdG1YYkZGUjAKLS0tIDk2Z3hHTXh6Q2pib25BankxZ20z + U2JQdElyWmtCM084NFVPMnhrc0NZaFUK170qtXPKICoG9/RjPvpHR2eY50NCi39U + DWjSha3QtQTkw5JLhqvZyM/fb3vRN/Pz+FYaYqUuRfH7mloDQUwYtQ== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2024-04-21T18:04:55Z" + mac: ENC[AES256_GCM,data:jH7+8KqKjd/bbNDWkUwFnUxxhnRy7L8p41Z+zFbtE17DES6SiiZePwu9ozZNNMTTMTS9vsFlET/DeI6mwubFnnX4FlBN6yZu0cUiZg9W9Y0NeXXSq7Q9seab2de+wBS/1/PY4uC7N9m+KC9xB0/+4387eL5JECh8LQrtG+YAB0A=,iv:Td4RYi7QitthrFEcRRh2PNaDRy9RhoSlGSr+mDYX/uI=,tag:8KDwKKSU632ZE3UTiPQlWQ==,type:str] + pgp: [] + encrypted_regex: ^(data|stringData)$ + version: 3.8.1 diff --git a/kubernetes/storage/apps/cert-manager/cert-manager/ks.yaml b/kubernetes/storage/apps/cert-manager/cert-manager/ks.yaml new file mode 100644 index 00000000..2dd1ad10 --- /dev/null +++ b/kubernetes/storage/apps/cert-manager/cert-manager/ks.yaml @@ -0,0 +1,42 @@ +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app cert-manager + namespace: flux-system +spec: + targetNamespace: cert-manager + commonMetadata: + labels: + app.kubernetes.io/name: *app + path: ./kubernetes/apps/cert-manager/cert-manager/app + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: true + interval: 30m + retryInterval: 1m + timeout: 5m +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app cert-manager-issuers + namespace: flux-system +spec: + targetNamespace: cert-manager + commonMetadata: + labels: + app.kubernetes.io/name: *app + dependsOn: + - name: cert-manager + path: ./kubernetes/apps/cert-manager/cert-manager/issuers + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: true + interval: 30m + retryInterval: 1m + timeout: 5m diff --git a/kubernetes/storage/apps/cert-manager/kustomization.yaml b/kubernetes/storage/apps/cert-manager/kustomization.yaml new file mode 100644 index 00000000..a0a3e5ed --- /dev/null +++ b/kubernetes/storage/apps/cert-manager/kustomization.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./namespace.yaml + - ./cert-manager/ks.yaml diff --git a/kubernetes/storage/apps/cert-manager/namespace.yaml b/kubernetes/storage/apps/cert-manager/namespace.yaml new file mode 100644 index 00000000..ed788350 --- /dev/null +++ b/kubernetes/storage/apps/cert-manager/namespace.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: cert-manager + labels: + kustomize.toolkit.fluxcd.io/prune: disabled diff --git a/kubernetes/storage/apps/flux-system/kustomization.yaml b/kubernetes/storage/apps/flux-system/kustomization.yaml new file mode 100644 index 00000000..10587f8c --- /dev/null +++ b/kubernetes/storage/apps/flux-system/kustomization.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./namespace.yaml + - ./webhooks/ks.yaml diff --git a/kubernetes/storage/apps/flux-system/namespace.yaml b/kubernetes/storage/apps/flux-system/namespace.yaml new file mode 100644 index 00000000..b48db452 --- /dev/null +++ b/kubernetes/storage/apps/flux-system/namespace.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: flux-system + labels: + kustomize.toolkit.fluxcd.io/prune: disabled diff --git a/kubernetes/storage/apps/flux-system/webhooks/app/github/ingress.yaml b/kubernetes/storage/apps/flux-system/webhooks/app/github/ingress.yaml new file mode 100644 index 00000000..e460f331 --- /dev/null +++ b/kubernetes/storage/apps/flux-system/webhooks/app/github/ingress.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: flux-webhook + annotations: + external-dns.alpha.kubernetes.io/target: "${SECRET_CLUSTER_NAME}.${SECRET_DOMAIN}" +spec: + ingressClassName: external + rules: + - host: "flux-webhook.${SECRET_DOMAIN}" + http: + paths: + - path: /hook/ + pathType: Prefix + backend: + service: + name: webhook-receiver + port: + number: 80 diff --git a/kubernetes/storage/apps/flux-system/webhooks/app/github/kustomization.yaml b/kubernetes/storage/apps/flux-system/webhooks/app/github/kustomization.yaml new file mode 100644 index 00000000..786e654a --- /dev/null +++ b/kubernetes/storage/apps/flux-system/webhooks/app/github/kustomization.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./secret.sops.yaml + - ./ingress.yaml + - ./receiver.yaml diff --git a/kubernetes/storage/apps/flux-system/webhooks/app/github/receiver.yaml b/kubernetes/storage/apps/flux-system/webhooks/app/github/receiver.yaml new file mode 100644 index 00000000..f90ed42b --- /dev/null +++ b/kubernetes/storage/apps/flux-system/webhooks/app/github/receiver.yaml @@ -0,0 +1,25 @@ +--- +apiVersion: notification.toolkit.fluxcd.io/v1 +kind: Receiver +metadata: + name: github-receiver +spec: + type: github + events: + - ping + - push + secretRef: + name: github-webhook-token-secret + resources: + - apiVersion: source.toolkit.fluxcd.io/v1 + kind: GitRepository + name: home-ops + namespace: flux-system + - apiVersion: kustomize.toolkit.fluxcd.io/v1 + kind: Kustomization + name: cluster + namespace: flux-system + - apiVersion: kustomize.toolkit.fluxcd.io/v1 + kind: Kustomization + name: cluster-apps + namespace: flux-system diff --git a/kubernetes/storage/apps/flux-system/webhooks/app/github/secret.sops.yaml b/kubernetes/storage/apps/flux-system/webhooks/app/github/secret.sops.yaml new file mode 100644 index 00000000..3ca0f3d5 --- /dev/null +++ b/kubernetes/storage/apps/flux-system/webhooks/app/github/secret.sops.yaml @@ -0,0 +1,26 @@ +apiVersion: v1 +kind: Secret +metadata: + name: github-webhook-token-secret +stringData: + token: ENC[AES256_GCM,data:qNCt8cOXMOL/sKI9WlL+Hl2mA+iK8GfeSn0j//YSFes=,iv:jOnk/Q43h9Iejx1O9hATZTA4bGKgUeyaX/Og7ba1n/w=,tag:s7FnTjl2die3hYosxrKTAw==,type:str] +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1ve9kzacrwq7l9l0emvs326uk6t576d75r596e083r2tq6xu28qcsacy3s7 + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBVZ3pScjlRTVVLc2lMaFFM + ZFliVEIvdmFYKzN0YVRSZHVXWWFjMTFvMjA0CmkwMEhTdEprNTRJZnd6UCtlZHFO + ZGFPZnJ5cU05eDhkTVpNU1I1Lzc3dk0KLS0tIGNXRTdvcGw1dDB0VEdWNENKU0xG + Znk2Z2U5VEFEdkpLUnVnd1dFZTd0MXMKlH74WgmXebZ3qfOq2Kj4/UZVHH+KCjoq + OzE4DApzQKCXVSPpxZskkfl+6aqoc5gfLzhjdS1n5lEV7XY/39NxXw== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2024-04-21T18:04:55Z" + mac: ENC[AES256_GCM,data:iwCNhzuj/A46dTbrDeAnpAhrY1yphCKaHEPeFfDgRrjeKr2poahtdRZvT7qtACCz4NRI9bMPn0p5I9pMGPjKjPcAeIr82o2HYvXlLcZGNZtxU2STxqjoSBPlG8+le1OOF7HNLcrhIsFF4f9Jtte5ZPfJvWuWtfx4Yq9pfq/kZ2k=,iv:XFGkNXckXx0b1RWxDFDZzmkTAxCHng/iARzsh4mpbFc=,tag:IJEga2aeMkNnSzyjefL/+A==,type:str] + pgp: [] + encrypted_regex: ^(data|stringData)$ + version: 3.8.1 diff --git a/kubernetes/storage/apps/flux-system/webhooks/app/kustomization.yaml b/kubernetes/storage/apps/flux-system/webhooks/app/kustomization.yaml new file mode 100644 index 00000000..ccd8b3eb --- /dev/null +++ b/kubernetes/storage/apps/flux-system/webhooks/app/kustomization.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./github diff --git a/kubernetes/storage/apps/flux-system/webhooks/ks.yaml b/kubernetes/storage/apps/flux-system/webhooks/ks.yaml new file mode 100644 index 00000000..54089932 --- /dev/null +++ b/kubernetes/storage/apps/flux-system/webhooks/ks.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app flux-webhooks + namespace: flux-system +spec: + targetNamespace: flux-system + commonMetadata: + labels: + app.kubernetes.io/name: *app + path: ./kubernetes/apps/flux-system/webhooks/app + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: true + interval: 30m + retryInterval: 1m + timeout: 5m diff --git a/kubernetes/storage/apps/kube-system/cilium/app/helmrelease.yaml b/kubernetes/storage/apps/kube-system/cilium/app/helmrelease.yaml new file mode 100644 index 00000000..0748a368 --- /dev/null +++ b/kubernetes/storage/apps/kube-system/cilium/app/helmrelease.yaml @@ -0,0 +1,136 @@ +--- +apiVersion: helm.toolkit.fluxcd.io/v2beta2 +kind: HelmRelease +metadata: + name: cilium +spec: + interval: 30m + chart: + spec: + chart: cilium + version: 1.15.4 + sourceRef: + kind: HelmRepository + name: cilium + namespace: flux-system + install: + remediation: + retries: 3 + upgrade: + cleanupOnFail: true + remediation: + retries: 3 + values: + autoDirectNodeRoutes: true + bgpControlPlane: + enabled: true + bpf: + masquerade: false + vlanBypass: [0] + cgroup: + automount: + enabled: false + hostRoot: /sys/fs/cgroup + cluster: + id: 1 + name: home-storage + cni: + exclusive: false + binPath: /var/lib/rancher/k3s/data/current/bin + confPath: /var/lib/rancher/k3s/agent/etc/cni/net.d + containerRuntime: + integration: containerd + socketPath: /var/run/k3s/containerd/containerd.sock + # NOTE: devices might need to be set if you have more than one active NIC on your hosts + # devices: eno+ eth+ + devices: + - lan + endpointRoutes: + enabled: true + hubble: + enabled: true + metrics: + enabled: + - dns:query + - drop + - tcp + - flow + - port-distribution + - icmp + - http + serviceMonitor: + enabled: true + dashboards: + enabled: true + annotations: + grafana_folder: Cilium + relay: + enabled: true + rollOutPods: true + prometheus: + serviceMonitor: + enabled: true + ui: + enabled: true + rollOutPods: true + ingress: + enabled: true + className: internal + hosts: ["hubble.${SECRET_DOMAIN}"] + ipam: + mode: kubernetes + ipv4NativeRoutingCIDR: "${CLUSTER_CIDR}" + k8sServiceHost: 127.0.0.1 + k8sServicePort: 6444 + kubeProxyReplacement: true + kubeProxyReplacementHealthzBindAddr: 0.0.0.0:10256 + l2announcements: + enabled: true + # https://github.com/cilium/cilium/issues/26586 + leaseDuration: 300s + leaseRenewDeadline: 60s + leaseRetryPeriod: 10s + loadBalancer: + algorithm: maglev + mode: snat + localRedirectPolicy: true + operator: + replicas: 1 + rollOutPods: true + prometheus: + enabled: true + serviceMonitor: + enabled: true + dashboards: + enabled: true + annotations: + grafana_folder: Cilium + prometheus: + enabled: true + serviceMonitor: + enabled: true + trustCRDsExist: true + dashboards: + enabled: true + annotations: + grafana_folder: Cilium + rollOutCiliumPods: true + routingMode: native + securityContext: + capabilities: + ciliumAgent: + - CHOWN + - KILL + - NET_ADMIN + - NET_RAW + - IPC_LOCK + - SYS_ADMIN + - SYS_RESOURCE + - DAC_OVERRIDE + - FOWNER + - SETGID + - SETUID + cleanCiliumState: + - NET_ADMIN + - SYS_ADMIN + - SYS_RESOURCE diff --git a/kubernetes/storage/apps/kube-system/cilium/app/kustomization.yaml b/kubernetes/storage/apps/kube-system/cilium/app/kustomization.yaml new file mode 100644 index 00000000..5dd7baca --- /dev/null +++ b/kubernetes/storage/apps/kube-system/cilium/app/kustomization.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./helmrelease.yaml diff --git a/kubernetes/storage/apps/kube-system/cilium/config/cilium-l2.yaml b/kubernetes/storage/apps/kube-system/cilium/config/cilium-l2.yaml new file mode 100644 index 00000000..520c9c1a --- /dev/null +++ b/kubernetes/storage/apps/kube-system/cilium/config/cilium-l2.yaml @@ -0,0 +1,26 @@ +--- +# https://docs.cilium.io/en/latest/network/l2-announcements +apiVersion: cilium.io/v2alpha1 +kind: CiliumL2AnnouncementPolicy +metadata: + name: l2-policy +spec: + loadBalancerIPs: true + # NOTE: interfaces might need to be set if you have more than one active NIC on your hosts + # interfaces: + # - ^eno[0-9]+ + # - ^eth[0-9]+ + interfaces: + - ^lan$ + nodeSelector: + matchLabels: + kubernetes.io/os: linux +--- +apiVersion: cilium.io/v2alpha1 +kind: CiliumLoadBalancerIPPool +metadata: + name: l2-pool +spec: + allowFirstLastIPs: "Yes" + blocks: + - cidr: "${NODE_CIDR}" diff --git a/kubernetes/storage/apps/kube-system/cilium/config/kustomization.yaml b/kubernetes/storage/apps/kube-system/cilium/config/kustomization.yaml new file mode 100644 index 00000000..f6899653 --- /dev/null +++ b/kubernetes/storage/apps/kube-system/cilium/config/kustomization.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./cilium-l2.yaml diff --git a/kubernetes/storage/apps/kube-system/cilium/ks.yaml b/kubernetes/storage/apps/kube-system/cilium/ks.yaml new file mode 100644 index 00000000..e263e084 --- /dev/null +++ b/kubernetes/storage/apps/kube-system/cilium/ks.yaml @@ -0,0 +1,42 @@ +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app cilium + namespace: flux-system +spec: + targetNamespace: kube-system + commonMetadata: + labels: + app.kubernetes.io/name: *app + path: ./kubernetes/apps/kube-system/cilium/app + prune: false # never should be deleted + sourceRef: + kind: GitRepository + name: home-ops + wait: true + interval: 30m + retryInterval: 1m + timeout: 5m +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app cilium-config + namespace: flux-system +spec: + targetNamespace: kube-system + commonMetadata: + labels: + app.kubernetes.io/name: *app + dependsOn: + - name: cilium + path: ./kubernetes/apps/kube-system/cilium/config + prune: false # never should be deleted + sourceRef: + kind: GitRepository + name: home-ops + wait: false + interval: 30m + retryInterval: 1m + timeout: 5m diff --git a/kubernetes/storage/apps/kube-system/kube-vip/app/daemonset.yaml b/kubernetes/storage/apps/kube-system/kube-vip/app/daemonset.yaml new file mode 100644 index 00000000..829f4462 --- /dev/null +++ b/kubernetes/storage/apps/kube-system/kube-vip/app/daemonset.yaml @@ -0,0 +1,75 @@ +--- +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: kube-vip + namespace: kube-system + labels: + app.kubernetes.io/name: kube-vip +spec: + selector: + matchLabels: + app.kubernetes.io/name: kube-vip + template: + metadata: + labels: + app.kubernetes.io/name: kube-vip + spec: + containers: + - name: kube-vip + image: ghcr.io/kube-vip/kube-vip:v0.7.1 + imagePullPolicy: IfNotPresent + args: ["manager"] + env: + - name: address + value: "192.168.1.10" + - name: vip_arp + value: "true" + - name: lb_enable + value: "true" + - name: port + value: "6443" + - name: vip_cidr + value: "32" + - name: cp_enable + value: "true" + - name: cp_namespace + value: kube-system + - name: vip_ddns + value: "false" + - name: svc_enable + value: "false" + - name: vip_leaderelection + value: "true" + - name: vip_leaseduration + value: "15" + - name: vip_renewdeadline + value: "10" + - name: vip_retryperiod + value: "2" + - name: prometheus_server + value: :2112 + securityContext: + capabilities: + add: ["NET_ADMIN", "NET_RAW", "SYS_TIME"] + hostAliases: + - hostnames: + - kubernetes + ip: 127.0.0.1 + hostNetwork: true + serviceAccountName: kube-vip + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: node-role.kubernetes.io/master + operator: Exists + - matchExpressions: + - key: node-role.kubernetes.io/control-plane + operator: Exists + tolerations: + - effect: NoSchedule + operator: Exists + - effect: NoExecute + operator: Exists diff --git a/kubernetes/storage/apps/kube-system/kube-vip/app/kustomization.yaml b/kubernetes/storage/apps/kube-system/kube-vip/app/kustomization.yaml new file mode 100644 index 00000000..cbede828 --- /dev/null +++ b/kubernetes/storage/apps/kube-system/kube-vip/app/kustomization.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./rbac.yaml + - ./daemonset.yaml diff --git a/kubernetes/storage/apps/kube-system/kube-vip/app/rbac.yaml b/kubernetes/storage/apps/kube-system/kube-vip/app/rbac.yaml new file mode 100644 index 00000000..b3cc6d4d --- /dev/null +++ b/kubernetes/storage/apps/kube-system/kube-vip/app/rbac.yaml @@ -0,0 +1,42 @@ +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: kube-vip + namespace: kube-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + annotations: + rbac.authorization.kubernetes.io/autoupdate: "true" + name: system:kube-vip-role +rules: + - apiGroups: [""] + resources: ["services/status"] + verbs: ["update"] + - apiGroups: [""] + resources: ["services", "endpoints"] + verbs: ["list","get","watch", "update"] + - apiGroups: [""] + resources: ["nodes"] + verbs: ["list","get","watch", "update", "patch"] + - apiGroups: ["coordination.k8s.io"] + resources: ["leases"] + verbs: ["list", "get", "watch", "update", "create"] + - apiGroups: ["discovery.k8s.io"] + resources: ["endpointslices"] + verbs: ["list","get","watch", "update"] +--- +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: system:kube-vip-binding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: system:kube-vip-role +subjects: +- kind: ServiceAccount + name: kube-vip + namespace: kube-system diff --git a/kubernetes/storage/apps/kube-system/kube-vip/ks.yaml b/kubernetes/storage/apps/kube-system/kube-vip/ks.yaml new file mode 100644 index 00000000..3885f23d --- /dev/null +++ b/kubernetes/storage/apps/kube-system/kube-vip/ks.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app kube-vip + namespace: flux-system +spec: + targetNamespace: kube-system + commonMetadata: + labels: + app.kubernetes.io/name: *app + path: ./kubernetes/apps/kube-system/kube-vip/app + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: false + interval: 30m + retryInterval: 1m + timeout: 5m diff --git a/kubernetes/storage/apps/kube-system/kustomization.yaml b/kubernetes/storage/apps/kube-system/kustomization.yaml new file mode 100644 index 00000000..b8764db8 --- /dev/null +++ b/kubernetes/storage/apps/kube-system/kustomization.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./namespace.yaml + - ./cilium/ks.yaml + - ./metrics-server/ks.yaml + - ./reloader/ks.yaml + - ./kube-vip/ks.yaml diff --git a/kubernetes/storage/apps/kube-system/metrics-server/app/helmrelease.yaml b/kubernetes/storage/apps/kube-system/metrics-server/app/helmrelease.yaml new file mode 100644 index 00000000..3b8b23e1 --- /dev/null +++ b/kubernetes/storage/apps/kube-system/metrics-server/app/helmrelease.yaml @@ -0,0 +1,32 @@ +--- +apiVersion: helm.toolkit.fluxcd.io/v2beta2 +kind: HelmRelease +metadata: + name: metrics-server +spec: + interval: 30m + chart: + spec: + chart: metrics-server + version: 3.12.1 + sourceRef: + kind: HelmRepository + name: metrics-server + namespace: flux-system + install: + remediation: + retries: 3 + upgrade: + cleanupOnFail: true + remediation: + retries: 3 + values: + args: + - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname + - --kubelet-use-node-status-port + - --metric-resolution=15s + - --kubelet-insecure-tls + metrics: + enabled: true + serviceMonitor: + enabled: true diff --git a/kubernetes/storage/apps/kube-system/metrics-server/app/kustomization.yaml b/kubernetes/storage/apps/kube-system/metrics-server/app/kustomization.yaml new file mode 100644 index 00000000..5dd7baca --- /dev/null +++ b/kubernetes/storage/apps/kube-system/metrics-server/app/kustomization.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./helmrelease.yaml diff --git a/kubernetes/storage/apps/kube-system/metrics-server/ks.yaml b/kubernetes/storage/apps/kube-system/metrics-server/ks.yaml new file mode 100644 index 00000000..2447571a --- /dev/null +++ b/kubernetes/storage/apps/kube-system/metrics-server/ks.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app metrics-server + namespace: flux-system +spec: + targetNamespace: kube-system + commonMetadata: + labels: + app.kubernetes.io/name: *app + path: ./kubernetes/apps/kube-system/metrics-server/app + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: false + interval: 30m + retryInterval: 1m + timeout: 5m diff --git a/kubernetes/storage/apps/kube-system/namespace.yaml b/kubernetes/storage/apps/kube-system/namespace.yaml new file mode 100644 index 00000000..5eeb2c91 --- /dev/null +++ b/kubernetes/storage/apps/kube-system/namespace.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: kube-system + labels: + kustomize.toolkit.fluxcd.io/prune: disabled diff --git a/kubernetes/storage/apps/kube-system/reloader/app/helmrelease.yaml b/kubernetes/storage/apps/kube-system/reloader/app/helmrelease.yaml new file mode 100644 index 00000000..ca75bb5b --- /dev/null +++ b/kubernetes/storage/apps/kube-system/reloader/app/helmrelease.yaml @@ -0,0 +1,29 @@ +--- +apiVersion: helm.toolkit.fluxcd.io/v2beta2 +kind: HelmRelease +metadata: + name: reloader +spec: + interval: 30m + chart: + spec: + chart: reloader + version: 1.0.80 + sourceRef: + kind: HelmRepository + name: stakater + namespace: flux-system + install: + remediation: + retries: 3 + upgrade: + cleanupOnFail: true + remediation: + retries: 3 + values: + fullnameOverride: reloader + reloader: + readOnlyRootFileSystem: true + podMonitor: + enabled: true + namespace: "{{ .Release.Namespace }}" diff --git a/kubernetes/storage/apps/kube-system/reloader/app/kustomization.yaml b/kubernetes/storage/apps/kube-system/reloader/app/kustomization.yaml new file mode 100644 index 00000000..5dd7baca --- /dev/null +++ b/kubernetes/storage/apps/kube-system/reloader/app/kustomization.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./helmrelease.yaml diff --git a/kubernetes/storage/apps/kube-system/reloader/ks.yaml b/kubernetes/storage/apps/kube-system/reloader/ks.yaml new file mode 100644 index 00000000..86e65e67 --- /dev/null +++ b/kubernetes/storage/apps/kube-system/reloader/ks.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app reloader + namespace: flux-system +spec: + targetNamespace: kube-system + commonMetadata: + labels: + app.kubernetes.io/name: *app + path: ./kubernetes/apps/kube-system/reloader/app + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: false + interval: 30m + retryInterval: 1m + timeout: 5m diff --git a/kubernetes/storage/apps/network/echo-server/app/helmrelease.yaml b/kubernetes/storage/apps/network/echo-server/app/helmrelease.yaml new file mode 100644 index 00000000..e9c3a688 --- /dev/null +++ b/kubernetes/storage/apps/network/echo-server/app/helmrelease.yaml @@ -0,0 +1,91 @@ +--- +apiVersion: helm.toolkit.fluxcd.io/v2beta2 +kind: HelmRelease +metadata: + name: echo-server +spec: + interval: 30m + chart: + spec: + chart: app-template + version: 3.1.0 + sourceRef: + kind: HelmRepository + name: bjw-s + namespace: flux-system + install: + remediation: + retries: 3 + upgrade: + cleanupOnFail: true + remediation: + retries: 3 + values: + controllers: + echo-server: + strategy: RollingUpdate + containers: + app: + image: + repository: ghcr.io/mendhak/http-https-echo + tag: 33 + env: + HTTP_PORT: &port 8080 + LOG_WITHOUT_NEWLINE: true + LOG_IGNORE_PATH: /healthz + PROMETHEUS_ENABLED: true + probes: + liveness: &probes + enabled: true + custom: true + spec: + httpGet: + path: /healthz + port: *port + initialDelaySeconds: 0 + periodSeconds: 10 + timeoutSeconds: 1 + failureThreshold: 3 + readiness: *probes + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: { drop: ["ALL"] } + resources: + requests: + cpu: 10m + limits: + memory: 64Mi + defaultPodOptions: + securityContext: + runAsNonRoot: true + runAsUser: 65534 + runAsGroup: 65534 + seccompProfile: { type: RuntimeDefault } + service: + app: + controller: echo-server + ports: + http: + port: *port + serviceMonitor: + app: + serviceName: echo-server + endpoints: + - port: http + scheme: http + path: /metrics + interval: 1m + scrapeTimeout: 10s + ingress: + app: + className: external + annotations: + external-dns.alpha.kubernetes.io/target: "${SECRET_CLUSTER_NAME}.${SECRET_DOMAIN}" + hosts: + - host: "{{ .Release.Name }}.${SECRET_DOMAIN}" + paths: + - path: / + service: + identifier: app + port: http diff --git a/kubernetes/storage/apps/network/echo-server/app/kustomization.yaml b/kubernetes/storage/apps/network/echo-server/app/kustomization.yaml new file mode 100644 index 00000000..5dd7baca --- /dev/null +++ b/kubernetes/storage/apps/network/echo-server/app/kustomization.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./helmrelease.yaml diff --git a/kubernetes/storage/apps/network/echo-server/ks.yaml b/kubernetes/storage/apps/network/echo-server/ks.yaml new file mode 100644 index 00000000..d783b4c5 --- /dev/null +++ b/kubernetes/storage/apps/network/echo-server/ks.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app echo-server + namespace: flux-system +spec: + targetNamespace: network + commonMetadata: + labels: + app.kubernetes.io/name: *app + path: ./kubernetes/apps/network/echo-server/app + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: false + interval: 30m + retryInterval: 1m + timeout: 5m diff --git a/kubernetes/storage/apps/network/ingress-nginx/certificates/kustomization.yaml b/kubernetes/storage/apps/network/ingress-nginx/certificates/kustomization.yaml new file mode 100644 index 00000000..e7892580 --- /dev/null +++ b/kubernetes/storage/apps/network/ingress-nginx/certificates/kustomization.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./staging.yaml diff --git a/kubernetes/storage/apps/network/ingress-nginx/certificates/production.yaml b/kubernetes/storage/apps/network/ingress-nginx/certificates/production.yaml new file mode 100644 index 00000000..b5afdf41 --- /dev/null +++ b/kubernetes/storage/apps/network/ingress-nginx/certificates/production.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: "${SECRET_DOMAIN/./-}-production" +spec: + secretName: "${SECRET_DOMAIN/./-}-production-tls" + issuerRef: + name: letsencrypt-production + kind: ClusterIssuer + commonName: "${SECRET_DOMAIN}" + dnsNames: + - "${SECRET_DOMAIN}" + - "*.${SECRET_DOMAIN}" diff --git a/kubernetes/storage/apps/network/ingress-nginx/certificates/staging.yaml b/kubernetes/storage/apps/network/ingress-nginx/certificates/staging.yaml new file mode 100644 index 00000000..9c869425 --- /dev/null +++ b/kubernetes/storage/apps/network/ingress-nginx/certificates/staging.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: "${SECRET_DOMAIN/./-}-staging" +spec: + secretName: "${SECRET_DOMAIN/./-}-staging-tls" + issuerRef: + name: letsencrypt-staging + kind: ClusterIssuer + commonName: "${SECRET_DOMAIN}" + dnsNames: + - "${SECRET_DOMAIN}" + - "*.${SECRET_DOMAIN}" diff --git a/kubernetes/storage/apps/network/ingress-nginx/internal/helmrelease.yaml b/kubernetes/storage/apps/network/ingress-nginx/internal/helmrelease.yaml new file mode 100644 index 00000000..b5788768 --- /dev/null +++ b/kubernetes/storage/apps/network/ingress-nginx/internal/helmrelease.yaml @@ -0,0 +1,84 @@ +--- +apiVersion: helm.toolkit.fluxcd.io/v2beta2 +kind: HelmRelease +metadata: + name: ingress-nginx-internal + namespace: network +spec: + interval: 30m + chart: + spec: + chart: ingress-nginx + version: 4.10.0 + sourceRef: + kind: HelmRepository + name: ingress-nginx + namespace: flux-system + install: + remediation: + retries: 3 + upgrade: + cleanupOnFail: true + remediation: + retries: 3 + values: + fullnameOverride: ingress-nginx-internal + controller: + replicaCount: 1 + service: + annotations: + io.cilium/lb-ipam-ips: "192.168.1.17" + externalTrafficPolicy: Cluster + ingressClassResource: + name: internal + default: true + controllerValue: k8s.io/internal + admissionWebhooks: + objectSelector: + matchExpressions: + - key: ingress-class + operator: In + values: ["internal"] + config: + client-body-buffer-size: 100M + client-body-timeout: 120 + client-header-timeout: 120 + enable-brotli: "true" + enable-real-ip: "true" + hsts-max-age: 31449600 + keep-alive-requests: 10000 + keep-alive: 120 + log-format-escape-json: "true" + log-format-upstream: > + {"time": "$time_iso8601", "remote_addr": "$proxy_protocol_addr", "x_forwarded_for": "$proxy_add_x_forwarded_for", + "request_id": "$req_id", "remote_user": "$remote_user", "bytes_sent": $bytes_sent, "request_time": $request_time, + "status": $status, "vhost": "$host", "request_proto": "$server_protocol", "path": "$uri", "request_query": "$args", + "request_length": $request_length, "duration": $request_time, "method": "$request_method", "http_referrer": "$http_referer", + "http_user_agent": "$http_user_agent"} + proxy-body-size: 0 + proxy-buffer-size: 16k + ssl-protocols: TLSv1.3 TLSv1.2 + metrics: + enabled: true + serviceMonitor: + enabled: true + namespaceSelector: + any: true + extraArgs: + default-ssl-certificate: "network/${SECRET_DOMAIN/./-}-staging-tls" + topologySpreadConstraints: + - maxSkew: 1 + topologyKey: kubernetes.io/hostname + whenUnsatisfiable: DoNotSchedule + labelSelector: + matchLabels: + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/instance: ingress-nginx-internal + app.kubernetes.io/component: controller + resources: + requests: + cpu: 100m + limits: + memory: 500Mi + defaultBackend: + enabled: false diff --git a/kubernetes/storage/apps/network/ingress-nginx/internal/kustomization.yaml b/kubernetes/storage/apps/network/ingress-nginx/internal/kustomization.yaml new file mode 100644 index 00000000..5dd7baca --- /dev/null +++ b/kubernetes/storage/apps/network/ingress-nginx/internal/kustomization.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./helmrelease.yaml diff --git a/kubernetes/storage/apps/network/ingress-nginx/ks.yaml b/kubernetes/storage/apps/network/ingress-nginx/ks.yaml new file mode 100644 index 00000000..575ad6f8 --- /dev/null +++ b/kubernetes/storage/apps/network/ingress-nginx/ks.yaml @@ -0,0 +1,44 @@ +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app ingress-nginx-certificates + namespace: flux-system +spec: + targetNamespace: network + commonMetadata: + labels: + app.kubernetes.io/name: *app + dependsOn: + - name: cert-manager-issuers + path: ./kubernetes/apps/network/ingress-nginx/certificates + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: true + interval: 30m + retryInterval: 1m + timeout: 5m +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app ingress-nginx-internal + namespace: flux-system +spec: + targetNamespace: network + commonMetadata: + labels: + app.kubernetes.io/name: *app + dependsOn: + - name: ingress-nginx-certificates + path: ./kubernetes/apps/network/ingress-nginx/internal + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: false + interval: 30m + retryInterval: 1m + timeout: 5m diff --git a/kubernetes/storage/apps/network/k8s-gateway/app/helmrelease.yaml b/kubernetes/storage/apps/network/k8s-gateway/app/helmrelease.yaml new file mode 100644 index 00000000..2741c18f --- /dev/null +++ b/kubernetes/storage/apps/network/k8s-gateway/app/helmrelease.yaml @@ -0,0 +1,32 @@ +--- +apiVersion: helm.toolkit.fluxcd.io/v2beta2 +kind: HelmRelease +metadata: + name: k8s-gateway +spec: + interval: 30m + chart: + spec: + chart: k8s-gateway + version: 2.4.0 + sourceRef: + kind: HelmRepository + name: k8s-gateway + namespace: flux-system + install: + remediation: + retries: 3 + upgrade: + cleanupOnFail: true + remediation: + retries: 3 + values: + fullnameOverride: k8s-gateway + domain: "${SECRET_DOMAIN}" + ttl: 1 + service: + type: LoadBalancer + port: 53 + annotations: + io.cilium/lb-ipam-ips: "192.168.1.19" + externalTrafficPolicy: Cluster diff --git a/kubernetes/storage/apps/network/k8s-gateway/app/kustomization.yaml b/kubernetes/storage/apps/network/k8s-gateway/app/kustomization.yaml new file mode 100644 index 00000000..5dd7baca --- /dev/null +++ b/kubernetes/storage/apps/network/k8s-gateway/app/kustomization.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./helmrelease.yaml diff --git a/kubernetes/storage/apps/network/k8s-gateway/ks.yaml b/kubernetes/storage/apps/network/k8s-gateway/ks.yaml new file mode 100644 index 00000000..c77a3a31 --- /dev/null +++ b/kubernetes/storage/apps/network/k8s-gateway/ks.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app k8s-gateway + namespace: flux-system +spec: + targetNamespace: network + commonMetadata: + labels: + app.kubernetes.io/name: *app + path: ./kubernetes/apps/network/k8s-gateway/app + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: false + interval: 30m + retryInterval: 1m + timeout: 5m diff --git a/kubernetes/storage/apps/network/kustomization.yaml b/kubernetes/storage/apps/network/kustomization.yaml new file mode 100644 index 00000000..63efe5ba --- /dev/null +++ b/kubernetes/storage/apps/network/kustomization.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./namespace.yaml + - ./echo-server/ks.yaml + - ./ingress-nginx/ks.yaml + - ./k8s-gateway/ks.yaml diff --git a/kubernetes/storage/apps/network/namespace.yaml b/kubernetes/storage/apps/network/namespace.yaml new file mode 100644 index 00000000..4d78d7b1 --- /dev/null +++ b/kubernetes/storage/apps/network/namespace.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: network + labels: + kustomize.toolkit.fluxcd.io/prune: disabled diff --git a/kubernetes/storage/apps/openebs-system/kustomization.yaml b/kubernetes/storage/apps/openebs-system/kustomization.yaml new file mode 100644 index 00000000..9cd8d4e4 --- /dev/null +++ b/kubernetes/storage/apps/openebs-system/kustomization.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./namespace.yaml + - ./openebs/ks.yaml diff --git a/kubernetes/storage/apps/openebs-system/namespace.yaml b/kubernetes/storage/apps/openebs-system/namespace.yaml new file mode 100644 index 00000000..f173c6c9 --- /dev/null +++ b/kubernetes/storage/apps/openebs-system/namespace.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: openebs-system + labels: + kustomize.toolkit.fluxcd.io/prune: disabled diff --git a/kubernetes/storage/apps/openebs-system/openebs/app/helmrelease.yaml b/kubernetes/storage/apps/openebs-system/openebs/app/helmrelease.yaml new file mode 100644 index 00000000..e7c1b45c --- /dev/null +++ b/kubernetes/storage/apps/openebs-system/openebs/app/helmrelease.yaml @@ -0,0 +1,36 @@ +--- +apiVersion: helm.toolkit.fluxcd.io/v2beta2 +kind: HelmRelease +metadata: + name: openebs +spec: + interval: 30m + chart: + spec: + chart: openebs + version: 3.10.0 + sourceRef: + kind: HelmRepository + name: openebs + namespace: flux-system + install: + remediation: + retries: 3 + upgrade: + cleanupOnFail: true + remediation: + retries: 3 + values: + ndm: + enabled: false + ndmOperator: + enabled: false + localprovisioner: + enabled: true + deviceClass: + enabled: false + hostpathClass: + enabled: true + name: openebs-hostpath + isDefaultClass: false + basePath: /var/openebs/local diff --git a/kubernetes/storage/apps/openebs-system/openebs/app/kustomization.yaml b/kubernetes/storage/apps/openebs-system/openebs/app/kustomization.yaml new file mode 100644 index 00000000..5dd7baca --- /dev/null +++ b/kubernetes/storage/apps/openebs-system/openebs/app/kustomization.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./helmrelease.yaml diff --git a/kubernetes/storage/apps/openebs-system/openebs/ks.yaml b/kubernetes/storage/apps/openebs-system/openebs/ks.yaml new file mode 100644 index 00000000..fde2e354 --- /dev/null +++ b/kubernetes/storage/apps/openebs-system/openebs/ks.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app openebs + namespace: flux-system +spec: + targetNamespace: openebs-system + commonMetadata: + labels: + app.kubernetes.io/name: *app + path: ./kubernetes/apps/openebs-system/openebs/app + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: false + interval: 30m + retryInterval: 1m + timeout: 5m diff --git a/kubernetes/storage/apps/system-upgrade/k3s/app/kustomization.yaml b/kubernetes/storage/apps/system-upgrade/k3s/app/kustomization.yaml new file mode 100644 index 00000000..c159f45b --- /dev/null +++ b/kubernetes/storage/apps/system-upgrade/k3s/app/kustomization.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./plan.yaml diff --git a/kubernetes/storage/apps/system-upgrade/k3s/app/plan.yaml b/kubernetes/storage/apps/system-upgrade/k3s/app/plan.yaml new file mode 100644 index 00000000..38784cd5 --- /dev/null +++ b/kubernetes/storage/apps/system-upgrade/k3s/app/plan.yaml @@ -0,0 +1,50 @@ +--- +apiVersion: upgrade.cattle.io/v1 +kind: Plan +metadata: + name: controllers +spec: + version: "${KUBE_VERSION}" + upgrade: + image: rancher/k3s-upgrade + serviceAccountName: system-upgrade + concurrency: 1 + cordon: true + nodeSelector: + matchExpressions: + - key: node-role.kubernetes.io/control-plane + operator: Exists + tolerations: + - effect: NoSchedule + operator: Exists + - effect: NoExecute + operator: Exists + - key: node-role.kubernetes.io/control-plane + effect: NoSchedule + operator: Exists + - key: node-role.kubernetes.io/master + effect: NoSchedule + operator: Exists + - key: node-role.kubernetes.io/etcd + effect: NoExecute + operator: Exists + - key: CriticalAddonsOnly + operator: Exists +--- +apiVersion: upgrade.cattle.io/v1 +kind: Plan +metadata: + name: workers +spec: + version: "${KUBE_VERSION}" + serviceAccountName: system-upgrade + concurrency: 1 + nodeSelector: + matchExpressions: + - key: node-role.kubernetes.io/control-plane + operator: DoesNotExist + prepare: + image: rancher/k3s-upgrade + args: ["prepare", "controllers"] + upgrade: + image: rancher/k3s-upgrade diff --git a/kubernetes/storage/apps/system-upgrade/k3s/ks.yaml b/kubernetes/storage/apps/system-upgrade/k3s/ks.yaml new file mode 100644 index 00000000..53c062ad --- /dev/null +++ b/kubernetes/storage/apps/system-upgrade/k3s/ks.yaml @@ -0,0 +1,26 @@ +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app system-upgrade-k3s + namespace: flux-system +spec: + targetNamespace: system-upgrade + commonMetadata: + labels: + app.kubernetes.io/name: *app + dependsOn: + - name: system-upgrade-controller + path: ./kubernetes/apps/system-upgrade/k3s/app + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: false + interval: 30m + retryInterval: 1m + timeout: 5m + postBuild: + substitute: + # renovate: datasource=github-releases depName=k3s-io/k3s + KUBE_VERSION: v1.29.3+k3s1 diff --git a/kubernetes/storage/apps/system-upgrade/kustomization.yaml b/kubernetes/storage/apps/system-upgrade/kustomization.yaml new file mode 100644 index 00000000..e0b2bf29 --- /dev/null +++ b/kubernetes/storage/apps/system-upgrade/kustomization.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./namespace.yaml + - ./system-upgrade-controller/ks.yaml + - ./k3s/ks.yaml diff --git a/kubernetes/storage/apps/system-upgrade/namespace.yaml b/kubernetes/storage/apps/system-upgrade/namespace.yaml new file mode 100644 index 00000000..5ea024dd --- /dev/null +++ b/kubernetes/storage/apps/system-upgrade/namespace.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: system-upgrade + labels: + kustomize.toolkit.fluxcd.io/prune: disabled diff --git a/kubernetes/storage/apps/system-upgrade/system-upgrade-controller/app/helmrelease.yaml b/kubernetes/storage/apps/system-upgrade/system-upgrade-controller/app/helmrelease.yaml new file mode 100644 index 00000000..a28b8ed8 --- /dev/null +++ b/kubernetes/storage/apps/system-upgrade/system-upgrade-controller/app/helmrelease.yaml @@ -0,0 +1,101 @@ +--- +apiVersion: helm.toolkit.fluxcd.io/v2beta2 +kind: HelmRelease +metadata: + name: &app system-upgrade-controller +spec: + interval: 30m + chart: + spec: + chart: app-template + version: 3.1.0 + sourceRef: + kind: HelmRepository + name: bjw-s + namespace: flux-system + install: + remediation: + retries: 3 + upgrade: + cleanupOnFail: true + remediation: + retries: 3 + values: + controllers: + system-upgrade-controller: + strategy: RollingUpdate + containers: + app: + image: + repository: docker.io/rancher/system-upgrade-controller + tag: v0.13.4 + env: + SYSTEM_UPGRADE_CONTROLLER_DEBUG: false + SYSTEM_UPGRADE_CONTROLLER_THREADS: 2 + SYSTEM_UPGRADE_JOB_ACTIVE_DEADLINE_SECONDS: 900 + SYSTEM_UPGRADE_JOB_BACKOFF_LIMIT: 99 + SYSTEM_UPGRADE_JOB_IMAGE_PULL_POLICY: IfNotPresent + SYSTEM_UPGRADE_JOB_KUBECTL_IMAGE: registry.k8s.io/kubectl:v1.30.0 + SYSTEM_UPGRADE_JOB_PRIVILEGED: true + SYSTEM_UPGRADE_JOB_TTL_SECONDS_AFTER_FINISH: 900 + SYSTEM_UPGRADE_PLAN_POLLING_INTERVAL: 15m + SYSTEM_UPGRADE_CONTROLLER_NAME: *app + SYSTEM_UPGRADE_CONTROLLER_NAMESPACE: + valueFrom: + fieldRef: + fieldPath: metadata.namespace + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: { drop: ["ALL"] } + defaultPodOptions: + securityContext: + runAsNonRoot: true + runAsUser: 65534 + runAsGroup: 65534 + seccompProfile: { type: RuntimeDefault } + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: node-role.kubernetes.io/control-plane + operator: Exists + tolerations: + - key: CriticalAddonsOnly + operator: Exists + - key: node-role.kubernetes.io/control-plane + operator: Exists + effect: NoSchedule + - key: node-role.kubernetes.io/master + operator: Exists + effect: NoSchedule + serviceAccount: + create: true + name: system-upgrade + persistence: + tmp: + type: emptyDir + globalMounts: + - path: /tmp + etc-ssl: + type: hostPath + hostPath: /etc/ssl + hostPathType: DirectoryOrCreate + globalMounts: + - path: /etc/ssl + readOnly: true + etc-pki: + type: hostPath + hostPath: /etc/pki + hostPathType: DirectoryOrCreate + globalMounts: + - path: /etc/pki + readOnly: true + etc-ca-certificates: + type: hostPath + hostPath: /etc/ca-certificates + hostPathType: DirectoryOrCreate + globalMounts: + - path: /etc/ca-certificates + readOnly: true diff --git a/kubernetes/storage/apps/system-upgrade/system-upgrade-controller/app/kustomization.yaml b/kubernetes/storage/apps/system-upgrade/system-upgrade-controller/app/kustomization.yaml new file mode 100644 index 00000000..49f35511 --- /dev/null +++ b/kubernetes/storage/apps/system-upgrade/system-upgrade-controller/app/kustomization.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + # renovate: datasource=github-releases depName=rancher/system-upgrade-controller + - https://github.com/rancher/system-upgrade-controller/releases/download/v0.13.4/crd.yaml + - helmrelease.yaml + - rbac.yaml diff --git a/kubernetes/storage/apps/system-upgrade/system-upgrade-controller/app/rbac.yaml b/kubernetes/storage/apps/system-upgrade/system-upgrade-controller/app/rbac.yaml new file mode 100644 index 00000000..123677c2 --- /dev/null +++ b/kubernetes/storage/apps/system-upgrade/system-upgrade-controller/app/rbac.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: system-upgrade +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cluster-admin +subjects: + - kind: ServiceAccount + name: system-upgrade + namespace: system-upgrade diff --git a/kubernetes/storage/apps/system-upgrade/system-upgrade-controller/ks.yaml b/kubernetes/storage/apps/system-upgrade/system-upgrade-controller/ks.yaml new file mode 100644 index 00000000..55c93987 --- /dev/null +++ b/kubernetes/storage/apps/system-upgrade/system-upgrade-controller/ks.yaml @@ -0,0 +1,20 @@ +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: &app system-upgrade-controller + namespace: flux-system +spec: + targetNamespace: system-upgrade + commonMetadata: + labels: + app.kubernetes.io/name: *app + path: ./kubernetes/apps/system-upgrade/system-upgrade-controller/app + prune: true + sourceRef: + kind: GitRepository + name: home-ops + wait: true + interval: 30m + retryInterval: 1m + timeout: 5m diff --git a/kubernetes/storage/bootstrap/flux/kustomization.yaml b/kubernetes/storage/bootstrap/flux/kustomization.yaml new file mode 100644 index 00000000..02af98f0 --- /dev/null +++ b/kubernetes/storage/bootstrap/flux/kustomization.yaml @@ -0,0 +1,61 @@ +# IMPORTANT: This file is not tracked by flux and should never be. Its +# purpose is to only install the Flux components and CRDs into your cluster. +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - github.com/fluxcd/flux2/manifests/install?ref=v2.2.3 +patches: + # Remove the default network policies + - patch: |- + $patch: delete + apiVersion: networking.k8s.io/v1 + kind: NetworkPolicy + metadata: + name: not-used + target: + group: networking.k8s.io + kind: NetworkPolicy + # Resources renamed to match those installed by oci://ghcr.io/fluxcd/flux-manifests + - target: + kind: ResourceQuota + name: critical-pods + patch: | + - op: replace + path: /metadata/name + value: critical-pods-flux-system + - target: + kind: ClusterRoleBinding + name: cluster-reconciler + patch: | + - op: replace + path: /metadata/name + value: cluster-reconciler-flux-system + - target: + kind: ClusterRoleBinding + name: crd-controller + patch: | + - op: replace + path: /metadata/name + value: crd-controller-flux-system + - target: + kind: ClusterRole + name: crd-controller + patch: | + - op: replace + path: /metadata/name + value: crd-controller-flux-system + - target: + kind: ClusterRole + name: flux-edit + patch: | + - op: replace + path: /metadata/name + value: flux-edit-flux-system + - target: + kind: ClusterRole + name: flux-view + patch: | + - op: replace + path: /metadata/name + value: flux-view-flux-system diff --git a/kubernetes/storage/flux/apps.yaml b/kubernetes/storage/flux/apps.yaml new file mode 100644 index 00000000..55cca451 --- /dev/null +++ b/kubernetes/storage/flux/apps.yaml @@ -0,0 +1,56 @@ +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: cluster-apps + namespace: flux-system +spec: + interval: 30m + path: ./kubernetes/apps + prune: true + sourceRef: + kind: GitRepository + name: home-ops + decryption: + provider: sops + secretRef: + name: sops-age + postBuild: + substituteFrom: + - kind: ConfigMap + name: cluster-settings + - kind: Secret + name: cluster-secrets + - kind: ConfigMap + name: cluster-settings-user + optional: true + - kind: Secret + name: cluster-secrets-user + optional: true + patches: + - patch: |- + apiVersion: kustomize.toolkit.fluxcd.io/v1 + kind: Kustomization + metadata: + name: not-used + spec: + decryption: + provider: sops + secretRef: + name: sops-age + postBuild: + substituteFrom: + - kind: ConfigMap + name: cluster-settings + - kind: Secret + name: cluster-secrets + - kind: ConfigMap + name: cluster-settings-user + optional: true + - kind: Secret + name: cluster-secrets-user + optional: true + target: + group: kustomize.toolkit.fluxcd.io + kind: Kustomization + labelSelector: substitution.flux.home.arpa/disabled notin (true) diff --git a/kubernetes/storage/flux/config/cluster.yaml b/kubernetes/storage/flux/config/cluster.yaml new file mode 100644 index 00000000..153c3366 --- /dev/null +++ b/kubernetes/storage/flux/config/cluster.yaml @@ -0,0 +1,44 @@ +--- +# yaml-language-server: $schema=https://github.com/fluxcd-community/flux2-schemas/raw/main/gitrepository-source-v1.json +apiVersion: source.toolkit.fluxcd.io/v1 +kind: GitRepository +metadata: + name: home-ops + namespace: flux-system +spec: + interval: 30m + url: "ssh://git@github.com/prehor/home-ops.git" + secretRef: + name: github-deploy-key + ref: + branch: "main" + ignore: | + # exclude all + /* + # include kubernetes directory + !/kubernetes +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/main/kustomization-kustomize-v1.json +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: cluster + namespace: flux-system +spec: + interval: 30m + path: ./kubernetes/flux + prune: true + wait: false + sourceRef: + kind: GitRepository + name: home-ops + decryption: + provider: sops + secretRef: + name: sops-age + postBuild: + substituteFrom: + - kind: ConfigMap + name: cluster-settings + - kind: Secret + name: cluster-secrets diff --git a/kubernetes/storage/flux/config/flux.yaml b/kubernetes/storage/flux/config/flux.yaml new file mode 100644 index 00000000..b9ad109d --- /dev/null +++ b/kubernetes/storage/flux/config/flux.yaml @@ -0,0 +1,88 @@ +--- +# yaml-language-server: $schema=https://github.com/fluxcd-community/flux2-schemas/raw/main/ocirepository-source-v1beta2.json +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: OCIRepository +metadata: + name: flux-manifests + namespace: flux-system +spec: + interval: 10m + url: oci://ghcr.io/fluxcd/flux-manifests + ref: + tag: v2.2.3 +--- +# yaml-language-server: $schema=https://raw.githubusercontent.com/fluxcd-community/flux2-schemas/main/kustomization-kustomize-v1.json +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: flux + namespace: flux-system +spec: + interval: 10m + path: ./ + prune: true + wait: true + sourceRef: + kind: OCIRepository + name: flux-manifests + patches: + # Remove the network policies that does not work with k3s + - patch: | + $patch: delete + apiVersion: networking.k8s.io/v1 + kind: NetworkPolicy + metadata: + name: not-used + target: + group: networking.k8s.io + kind: NetworkPolicy + # Increase the number of reconciliations that can be performed in parallel and bump the resources limits + # https://fluxcd.io/flux/cheatsheets/bootstrap/#increase-the-number-of-workers + - patch: | + - op: add + path: /spec/template/spec/containers/0/args/- + value: --concurrent=8 + - op: add + path: /spec/template/spec/containers/0/args/- + value: --kube-api-qps=500 + - op: add + path: /spec/template/spec/containers/0/args/- + value: --kube-api-burst=1000 + - op: add + path: /spec/template/spec/containers/0/args/- + value: --requeue-dependency=5s + target: + kind: Deployment + name: (kustomize-controller|helm-controller|source-controller) + - patch: | + apiVersion: apps/v1 + kind: Deployment + metadata: + name: not-used + spec: + template: + spec: + containers: + - name: manager + resources: + limits: + cpu: 2000m + memory: 2Gi + target: + kind: Deployment + name: (kustomize-controller|helm-controller|source-controller) + # Enable Helm near OOM detection + # https://fluxcd.io/flux/cheatsheets/bootstrap/#enable-helm-near-oom-detection + - patch: | + - op: add + path: /spec/template/spec/containers/0/args/- + value: --feature-gates=OOMWatch=true + - op: add + path: /spec/template/spec/containers/0/args/- + value: --oom-watch-memory-threshold=95 + - op: add + path: /spec/template/spec/containers/0/args/- + value: --oom-watch-interval=500ms + target: + kind: Deployment + name: helm-controller diff --git a/kubernetes/storage/flux/config/kustomization.yaml b/kubernetes/storage/flux/config/kustomization.yaml new file mode 100644 index 00000000..ef231746 --- /dev/null +++ b/kubernetes/storage/flux/config/kustomization.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./flux.yaml + - ./cluster.yaml diff --git a/kubernetes/storage/flux/repositories/git/kustomization.yaml b/kubernetes/storage/flux/repositories/git/kustomization.yaml new file mode 100644 index 00000000..fe0f332a --- /dev/null +++ b/kubernetes/storage/flux/repositories/git/kustomization.yaml @@ -0,0 +1,4 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: [] diff --git a/kubernetes/storage/flux/repositories/helm/bjw-s.yaml b/kubernetes/storage/flux/repositories/helm/bjw-s.yaml new file mode 100644 index 00000000..df0c6474 --- /dev/null +++ b/kubernetes/storage/flux/repositories/helm/bjw-s.yaml @@ -0,0 +1,10 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: HelmRepository +metadata: + name: bjw-s + namespace: flux-system +spec: + type: oci + interval: 5m + url: oci://ghcr.io/bjw-s/helm diff --git a/kubernetes/storage/flux/repositories/helm/cilium.yaml b/kubernetes/storage/flux/repositories/helm/cilium.yaml new file mode 100644 index 00000000..51c65d69 --- /dev/null +++ b/kubernetes/storage/flux/repositories/helm/cilium.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: HelmRepository +metadata: + name: cilium + namespace: flux-system +spec: + interval: 1h + url: https://helm.cilium.io diff --git a/kubernetes/storage/flux/repositories/helm/external-dns.yaml b/kubernetes/storage/flux/repositories/helm/external-dns.yaml new file mode 100644 index 00000000..b76b9662 --- /dev/null +++ b/kubernetes/storage/flux/repositories/helm/external-dns.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: HelmRepository +metadata: + name: external-dns + namespace: flux-system +spec: + interval: 1h + url: https://kubernetes-sigs.github.io/external-dns diff --git a/kubernetes/storage/flux/repositories/helm/ingress-nginx.yaml b/kubernetes/storage/flux/repositories/helm/ingress-nginx.yaml new file mode 100644 index 00000000..4dcf5eea --- /dev/null +++ b/kubernetes/storage/flux/repositories/helm/ingress-nginx.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: HelmRepository +metadata: + name: ingress-nginx + namespace: flux-system +spec: + interval: 1h + url: https://kubernetes.github.io/ingress-nginx diff --git a/kubernetes/storage/flux/repositories/helm/jetstack.yaml b/kubernetes/storage/flux/repositories/helm/jetstack.yaml new file mode 100644 index 00000000..1b4982d6 --- /dev/null +++ b/kubernetes/storage/flux/repositories/helm/jetstack.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: HelmRepository +metadata: + name: jetstack + namespace: flux-system +spec: + interval: 1h + url: https://charts.jetstack.io diff --git a/kubernetes/storage/flux/repositories/helm/k8s-gateway.yaml b/kubernetes/storage/flux/repositories/helm/k8s-gateway.yaml new file mode 100644 index 00000000..51185b6e --- /dev/null +++ b/kubernetes/storage/flux/repositories/helm/k8s-gateway.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: HelmRepository +metadata: + name: k8s-gateway + namespace: flux-system +spec: + interval: 1h + url: https://ori-edge.github.io/k8s_gateway diff --git a/kubernetes/storage/flux/repositories/helm/kustomization.yaml b/kubernetes/storage/flux/repositories/helm/kustomization.yaml new file mode 100644 index 00000000..d9b76950 --- /dev/null +++ b/kubernetes/storage/flux/repositories/helm/kustomization.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./bjw-s.yaml + - ./cilium.yaml + - ./external-dns.yaml + - ./ingress-nginx.yaml + - ./k8s-gateway.yaml + - ./jetstack.yaml + - ./metrics-server.yaml + - ./openebs.yaml + - ./stakater.yaml diff --git a/kubernetes/storage/flux/repositories/helm/metrics-server.yaml b/kubernetes/storage/flux/repositories/helm/metrics-server.yaml new file mode 100644 index 00000000..57e7aa0c --- /dev/null +++ b/kubernetes/storage/flux/repositories/helm/metrics-server.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: HelmRepository +metadata: + name: metrics-server + namespace: flux-system +spec: + interval: 1h + url: https://kubernetes-sigs.github.io/metrics-server diff --git a/kubernetes/storage/flux/repositories/helm/openebs.yaml b/kubernetes/storage/flux/repositories/helm/openebs.yaml new file mode 100644 index 00000000..d0f105e6 --- /dev/null +++ b/kubernetes/storage/flux/repositories/helm/openebs.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: HelmRepository +metadata: + name: openebs + namespace: flux-system +spec: + interval: 1h + url: https://openebs.github.io/charts diff --git a/kubernetes/storage/flux/repositories/helm/stakater.yaml b/kubernetes/storage/flux/repositories/helm/stakater.yaml new file mode 100644 index 00000000..1846e8ae --- /dev/null +++ b/kubernetes/storage/flux/repositories/helm/stakater.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: HelmRepository +metadata: + name: stakater + namespace: flux-system +spec: + interval: 1h + url: https://stakater.github.io/stakater-charts diff --git a/kubernetes/storage/flux/repositories/kustomization.yaml b/kubernetes/storage/flux/repositories/kustomization.yaml new file mode 100644 index 00000000..d158d426 --- /dev/null +++ b/kubernetes/storage/flux/repositories/kustomization.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./git + - ./helm + - ./oci diff --git a/kubernetes/storage/flux/repositories/oci/kustomization.yaml b/kubernetes/storage/flux/repositories/oci/kustomization.yaml new file mode 100644 index 00000000..fe0f332a --- /dev/null +++ b/kubernetes/storage/flux/repositories/oci/kustomization.yaml @@ -0,0 +1,4 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: [] diff --git a/kubernetes/storage/flux/vars/cluster-secrets.sops.yaml b/kubernetes/storage/flux/vars/cluster-secrets.sops.yaml new file mode 100644 index 00000000..ae5150cf --- /dev/null +++ b/kubernetes/storage/flux/vars/cluster-secrets.sops.yaml @@ -0,0 +1,30 @@ +apiVersion: v1 +kind: Secret +metadata: + name: cluster-secrets + namespace: flux-system +stringData: + SECRET_CLUSTER_NAME: ENC[AES256_GCM,data:NDj+yquZpt6bYb1d,iv:vaC4tRNgzoPVZaXkol2vPH6gNpsXQTm9fWAmuWOhve8=,tag:ZrA5BYF1AFOI9zJ2FZkWkw==,type:str] + SECRET_DOMAIN: ENC[AES256_GCM,data:OZEIzVX+AozGHM/X3w==,iv:EieC8Xo6RV59JxCrisie4HkD+Z8KvfOGReiHYuPozMw=,tag:ToxxSaMMVrXgkSpMrUOzGw==,type:str] + SECRET_ACME_EMAIL: ENC[AES256_GCM,data:dx7jXat1y9g=,iv:8YgKWAJoynF30NXjD3r7dnUs5upHoeIhvlJ6yJnAXHU=,tag:NVORv/PEjhf6ViwxKvPRTQ==,type:str] + SECRET_CLOUDFLARE_TUNNEL_ID: ENC[AES256_GCM,data:ypCuh2C+0R5rFRsIdiFxi8giFMukj8nKbCKJCAJ2HuGwOXbS,iv:yyEdTwS9HfRJvfXDpq41GG1b3wcPeGjw72srphMEp/w=,tag:amnRWPKfv/qYCwJgOPCxpw==,type:str] +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1ve9kzacrwq7l9l0emvs326uk6t576d75r596e083r2tq6xu28qcsacy3s7 + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBLMG9RQ0hpRS9RbzU5YVhn + MmlZb3Q1R3lsN01Ja2J4Z3A2UStKQWZrQUMwCnQxZ2o3elpqdEc1RnhGY0VEM2sv + aWs3T1FjcnNMQm9rT2JKaVZCMG94aDQKLS0tIEZWdzJRSEZhSnFxVjVmQlVmd1RR + a3B3eURqMEhYOXZzZDBRSUVMU2NMcjgK8mSJC86ODpP1kwv4+/gqvr/vAV3WFhRY + m8vGz0qw50HrYQStXoLE++x2CQnGm3Fi4DvUmtD3GPoFCYzjL49LNQ== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2024-04-21T18:04:55Z" + mac: ENC[AES256_GCM,data:f1kQPudoVjKjbuN3JE6T/xMWjUtfREDbI0KuG/fYPSKWHXWj6KY/fe32AL0E9KKO02pwJeY6b//sZh5R/XYyCHZ7KKllE0R21+SQ2wKadjfYgOcFXSCbhJDVCK14saZsnaGrPZ8IQ5ELPz4EPTa/GU2vFdm9yQJSRESMQ5ue+NQ=,iv:Jf8p+Vj19bFrIwTmaZmzQk9VkZTgvidiF4eXIH9+PXM=,tag:P6ok00rY2YvOwGmelnB6Jw==,type:str] + pgp: [] + encrypted_regex: ^(data|stringData)$ + version: 3.8.1 diff --git a/kubernetes/storage/flux/vars/cluster-settings.yaml b/kubernetes/storage/flux/vars/cluster-settings.yaml new file mode 100644 index 00000000..b9b0b8bb --- /dev/null +++ b/kubernetes/storage/flux/vars/cluster-settings.yaml @@ -0,0 +1,10 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: cluster-settings + namespace: flux-system +data: + TIMEZONE: "Europe/Prague" + CLUSTER_CIDR: "10.10.0.0/16" + NODE_CIDR: "192.168.1.0/24" diff --git a/kubernetes/storage/flux/vars/kustomization.yaml b/kubernetes/storage/flux/vars/kustomization.yaml new file mode 100644 index 00000000..8db2fe91 --- /dev/null +++ b/kubernetes/storage/flux/vars/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ./cluster-settings.yaml + - ./cluster-secrets.sops.yaml