diff --git a/cluster/apps/default/echo-server/helm-release.yaml b/cluster/apps/default/echo-server/helm-release.yaml index eeece5d5..987a6789 100644 --- a/cluster/apps/default/echo-server/helm-release.yaml +++ b/cluster/apps/default/echo-server/helm-release.yaml @@ -17,11 +17,16 @@ spec: interval: 5m install: createNamespace: true + remediation: + retries: 3 + upgrade: + remediation: + retries: 3 values: global: nameOverride: *app controller: - replicas: 2 + replicas: 1 strategy: RollingUpdate image: repository: docker.io/jmalloc/echo-server @@ -84,15 +89,6 @@ spec: - hosts: - *host secretName: "echo-server-tls" - # # FIXME: Uncomment this block to ensure multiple - # # replicas of the pod are scheduled on different nodes - # topologySpreadConstraints: - # - maxSkew: 1 - # topologyKey: kubernetes.io/hostname - # whenUnsatisfiable: DoNotSchedule - # labelSelector: - # matchLabels: - # app.kubernetes.io/name: *app resources: requests: cpu: 50m diff --git a/cluster/apps/default/kustomization.yaml b/cluster/apps/default/kustomization.yaml index 4c098db6..5bdcb771 100644 --- a/cluster/apps/default/kustomization.yaml +++ b/cluster/apps/default/kustomization.yaml @@ -2,5 +2,6 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: + - namespace.yaml - echo-server - hajimari diff --git a/cluster/apps/default/namespace.yaml b/cluster/apps/default/namespace.yaml new file mode 100644 index 00000000..f659b055 --- /dev/null +++ b/cluster/apps/default/namespace.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: default + labels: + kustomize.toolkit.fluxcd.io/prune: disabled diff --git a/cluster/core/kube-system/kustomization.yaml b/cluster/apps/flux-system/kustomization.yaml similarity index 80% rename from cluster/core/kube-system/kustomization.yaml rename to cluster/apps/flux-system/kustomization.yaml index 639fc97c..809cbe53 100644 --- a/cluster/core/kube-system/kustomization.yaml +++ b/cluster/apps/flux-system/kustomization.yaml @@ -2,4 +2,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - - kube-vip + - namespace.yaml diff --git a/cluster/apps/flux-system/namespace.yaml b/cluster/apps/flux-system/namespace.yaml new file mode 100644 index 00000000..b48db452 --- /dev/null +++ b/cluster/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/cluster/core/kube-system/kube-vip/kustomization.yaml b/cluster/apps/kube-system/kube-vip/kustomization.yaml similarity index 62% rename from cluster/core/kube-system/kube-vip/kustomization.yaml rename to cluster/apps/kube-system/kube-vip/kustomization.yaml index a6c942f2..dc25d2e0 100644 --- a/cluster/core/kube-system/kube-vip/kustomization.yaml +++ b/cluster/apps/kube-system/kube-vip/kustomization.yaml @@ -4,3 +4,6 @@ kind: Kustomization resources: - rbac.yaml - daemon-set.yaml +labels: + - pairs: + kustomize.toolkit.fluxcd.io/prune: disabled diff --git a/cluster/core/kube-system/kube-vip/rbac.yaml b/cluster/apps/kube-system/kube-vip/rbac.yaml similarity index 100% rename from cluster/core/kube-system/kube-vip/rbac.yaml rename to cluster/apps/kube-system/kube-vip/rbac.yaml diff --git a/cluster/apps/kube-system/kustomization.yaml b/cluster/apps/kube-system/kustomization.yaml index 80a2f314..44511d4e 100644 --- a/cluster/apps/kube-system/kustomization.yaml +++ b/cluster/apps/kube-system/kustomization.yaml @@ -2,6 +2,8 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: + - namespace.yaml + - kube-vip # - kured - metrics-server - reflector diff --git a/cluster/apps/kube-system/namespace.yaml b/cluster/apps/kube-system/namespace.yaml new file mode 100644 index 00000000..5eeb2c91 --- /dev/null +++ b/cluster/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/cluster/apps/kustomization.yaml b/cluster/apps/kustomization.yaml index cebd1b14..8d4e84ec 100644 --- a/cluster/apps/kustomization.yaml +++ b/cluster/apps/kustomization.yaml @@ -2,7 +2,9 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - # - system-upgrade - default + - flux-system - kube-system + - metallb-system - networking + # - system-upgrade diff --git a/cluster/apps/networking/error-pages/helm-release.yaml b/cluster/apps/networking/error-pages/helm-release.yaml index 2618a7cd..941e4c1f 100644 --- a/cluster/apps/networking/error-pages/helm-release.yaml +++ b/cluster/apps/networking/error-pages/helm-release.yaml @@ -15,9 +15,6 @@ spec: name: k8s-at-home namespace: flux-system interval: 5m - dependsOn: - - name: traefik - namespace: networking install: createNamespace: true remediation: @@ -25,6 +22,9 @@ spec: upgrade: remediation: retries: 3 + dependsOn: + - name: traefik + namespace: networking values: image: repository: ghcr.io/tarampampam/error-pages diff --git a/cluster/apps/networking/external-dns/helm-release.yaml b/cluster/apps/networking/external-dns/helm-release.yaml index 99716609..8435dd6b 100644 --- a/cluster/apps/networking/external-dns/helm-release.yaml +++ b/cluster/apps/networking/external-dns/helm-release.yaml @@ -17,6 +17,11 @@ spec: interval: 5m install: createNamespace: true + remediation: + retries: 3 + upgrade: + remediation: + retries: 3 values: interval: 5m logLevel: debug diff --git a/cluster/apps/networking/k8s-gateway/helm-release.yaml b/cluster/apps/networking/k8s-gateway/helm-release.yaml index 1b309296..f46a9dd0 100644 --- a/cluster/apps/networking/k8s-gateway/helm-release.yaml +++ b/cluster/apps/networking/k8s-gateway/helm-release.yaml @@ -15,6 +15,16 @@ spec: name: k8s-gateway namespace: flux-system interval: 5m + install: + createNamespace: true + remediation: + retries: 3 + upgrade: + remediation: + retries: 3 + dependsOn: + - name: metallb + namespace: networking values: fullnameOverride: k8s-gateway domain: ${SECRET_DOMAIN} @@ -25,17 +35,3 @@ spec: annotations: metallb.universe.tf/loadBalancerIPs: "${METALLB_K8S_GATEWAY_ADDR}" externalTrafficPolicy: Local - # Increase replicaCount and set an anti-affinity if you wish to scale this - # replicaCount: 1 - # affinity: - # podAntiAffinity: - # preferredDuringSchedulingIgnoredDuringExecution: - # - weight: 100 - # podAffinityTerm: - # labelSelector: - # matchExpressions: - # - key: app.kubernetes.io/name - # operator: In - # values: - # - k8s-gateway - # topologyKey: kubernetes.io/hostname diff --git a/cluster/apps/networking/kustomization.yaml b/cluster/apps/networking/kustomization.yaml index 2a593b3d..9f64cf7f 100644 --- a/cluster/apps/networking/kustomization.yaml +++ b/cluster/apps/networking/kustomization.yaml @@ -2,6 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: + - namespace.yaml - error-pages - cloudflare-ddns - external-dns diff --git a/cluster/core/metallb-system/helm-release.yaml b/cluster/apps/networking/metallb/helm-release.yaml similarity index 95% rename from cluster/core/metallb-system/helm-release.yaml rename to cluster/apps/networking/metallb/helm-release.yaml index af65b48d..a6fc7e79 100644 --- a/cluster/core/metallb-system/helm-release.yaml +++ b/cluster/apps/networking/metallb/helm-release.yaml @@ -3,7 +3,7 @@ apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease metadata: name: metallb - namespace: metallb-system + namespace: networking spec: interval: 5m chart: diff --git a/cluster/core/metallb-system/kustomization.yaml b/cluster/apps/networking/metallb/kustomization.yaml similarity index 100% rename from cluster/core/metallb-system/kustomization.yaml rename to cluster/apps/networking/metallb/kustomization.yaml diff --git a/cluster/core/namespaces/networking.yaml b/cluster/apps/networking/namespace.yaml similarity index 52% rename from cluster/core/namespaces/networking.yaml rename to cluster/apps/networking/namespace.yaml index fa9575ea..b9e4a416 100644 --- a/cluster/core/namespaces/networking.yaml +++ b/cluster/apps/networking/namespace.yaml @@ -3,3 +3,5 @@ apiVersion: v1 kind: Namespace metadata: name: networking + labels: + kustomize.toolkit.fluxcd.io/prune: disabled diff --git a/cluster/apps/networking/traefik/helm-release.yaml b/cluster/apps/networking/traefik/helm-release.yaml index 92610b04..d9f8198f 100644 --- a/cluster/apps/networking/traefik/helm-release.yaml +++ b/cluster/apps/networking/traefik/helm-release.yaml @@ -15,9 +15,6 @@ spec: name: traefik namespace: flux-system interval: 5m - dependsOn: - - name: cert-manager - namespace: cert-manager install: createNamespace: true remediation: @@ -25,6 +22,11 @@ spec: upgrade: remediation: retries: 3 + dependsOn: + - name: cert-manager + namespace: cert-manager + - name: metallb + namespace: networking values: deployment: kind: Deployment diff --git a/cluster/apps/system-upgrade/kustomization.yaml b/cluster/apps/system-upgrade/kustomization.yaml index 6e6a74c0..65b36143 100644 --- a/cluster/apps/system-upgrade/kustomization.yaml +++ b/cluster/apps/system-upgrade/kustomization.yaml @@ -2,4 +2,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: + - namespace.yaml - system-upgrade-controller diff --git a/cluster/core/namespaces/system-upgrade.yaml b/cluster/apps/system-upgrade/namespace.yaml similarity index 53% rename from cluster/core/namespaces/system-upgrade.yaml rename to cluster/apps/system-upgrade/namespace.yaml index faec62d7..5ea024dd 100644 --- a/cluster/core/namespaces/system-upgrade.yaml +++ b/cluster/apps/system-upgrade/namespace.yaml @@ -3,3 +3,5 @@ apiVersion: v1 kind: Namespace metadata: name: system-upgrade + labels: + kustomize.toolkit.fluxcd.io/prune: disabled diff --git a/cluster/apps/system-upgrade/system-upgrade-controller/kustomization.yaml b/cluster/apps/system-upgrade/system-upgrade-controller/kustomization.yaml index 2951f5d2..79114b7b 100644 --- a/cluster/apps/system-upgrade/system-upgrade-controller/kustomization.yaml +++ b/cluster/apps/system-upgrade/system-upgrade-controller/kustomization.yaml @@ -8,5 +8,14 @@ images: - name: rancher/system-upgrade-controller newName: docker.io/rancher/system-upgrade-controller newTag: v0.9.1 +commonLabels: + app.kubernetes.io/name: system-upgrade-controller + app.kubernetes.io/instance: system-upgrade-controller patchesStrategicMerge: - - ./system-upgrade-patches.yaml + # Delete namespace resource + - | + $patch: delete + apiVersion: v1 + kind: Namespace + metadata: + name: system-upgrade diff --git a/cluster/apps/system-upgrade/system-upgrade-controller/system-upgrade-patches.yaml b/cluster/apps/system-upgrade/system-upgrade-controller/system-upgrade-patches.yaml deleted file mode 100644 index 2161d7b0..00000000 --- a/cluster/apps/system-upgrade/system-upgrade-controller/system-upgrade-patches.yaml +++ /dev/null @@ -1,9 +0,0 @@ ---- -# Namespace should already exist -# Delete the system-upgrade namespace -# from the kustomization -$patch: delete -apiVersion: v1 -kind: Namespace -metadata: - name: system-upgrade diff --git a/cluster/core/cert-manager/kustomization.yaml b/cluster/core/cert-manager/kustomization.yaml index 1e4c2b78..bbb126c5 100644 --- a/cluster/core/cert-manager/kustomization.yaml +++ b/cluster/core/cert-manager/kustomization.yaml @@ -1,6 +1,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: + - namespace.yaml - helm-release.yaml - letsencrypt-production.yaml - letsencrypt-staging.yaml diff --git a/cluster/core/namespaces/cert-manager.yaml b/cluster/core/cert-manager/namespace.yaml similarity index 53% rename from cluster/core/namespaces/cert-manager.yaml rename to cluster/core/cert-manager/namespace.yaml index 6bc19f4c..ed788350 100644 --- a/cluster/core/namespaces/cert-manager.yaml +++ b/cluster/core/cert-manager/namespace.yaml @@ -3,3 +3,5 @@ apiVersion: v1 kind: Namespace metadata: name: cert-manager + labels: + kustomize.toolkit.fluxcd.io/prune: disabled diff --git a/cluster/core/kustomization.yaml b/cluster/core/kustomization.yaml index 654b1332..f77becc1 100644 --- a/cluster/core/kustomization.yaml +++ b/cluster/core/kustomization.yaml @@ -2,7 +2,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - - namespaces - cert-manager - - kube-system - - metallb-system diff --git a/cluster/core/namespaces/kustomization.yaml b/cluster/core/namespaces/kustomization.yaml deleted file mode 100644 index 71aa049b..00000000 --- a/cluster/core/namespaces/kustomization.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - cert-manager.yaml - - metallb-system.yaml - - networking.yaml - - system-upgrade.yaml diff --git a/cluster/core/namespaces/metallb-system.yaml b/cluster/core/namespaces/metallb-system.yaml deleted file mode 100644 index 928cb910..00000000 --- a/cluster/core/namespaces/metallb-system.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -apiVersion: v1 -kind: Namespace -metadata: - name: metallb-system diff --git a/configure b/configure index d2defafa..a0d04523 100755 --- a/configure +++ b/configure @@ -46,7 +46,7 @@ main() { envsubst < "${PROJECT_DIR}/tmpl/cluster/flux-cluster.yaml" \ > "${PROJECT_DIR}/cluster/flux/flux-system/flux-cluster.yaml" envsubst < "${PROJECT_DIR}/tmpl/cluster/kube-vip-daemonset.yaml" \ - > "${PROJECT_DIR}/cluster/core/kube-system/kube-vip/daemon-set.yaml" + > "${PROJECT_DIR}/cluster/apps/kube-system/kube-vip/daemon-set.yaml" # generate cluster secrets envsubst < "${PROJECT_DIR}/tmpl/cluster/cluster-secrets.sops.yaml" \ > "${PROJECT_DIR}/cluster/config/cluster-secrets.sops.yaml" @@ -288,15 +288,15 @@ setup_github_webhook() { export BOOTSTRAP_FLUX_GITHUB_WEBHOOK_SECRET="${WEBHOOK_SECRET}" _log "INFO" "Using GitHub Token '${WEBHOOK_SECRET}' for Flux" - cp -rf "${PROJECT_DIR}/tmpl/cluster/flux-system" "${PROJECT_DIR}/cluster/apps/" + cp -rf "${PROJECT_DIR}/tmpl/cluster/flux-system/webhooks" "${PROJECT_DIR}/cluster/apps/flux-system" envsubst < "${PROJECT_DIR}/tmpl/cluster/flux-system/webhooks/github/secret.sops.yaml" \ > "${PROJECT_DIR}/cluster/apps/flux-system/webhooks/github/secret.sops.yaml" sops --encrypt --in-place "${PROJECT_DIR}/cluster/apps/flux-system/webhooks/github/secret.sops.yaml" - if [[ $(yq eval --no-doc 'contains({"resources": ["flux-system"]})' "${PROJECT_DIR}/cluster/apps/kustomization.yaml") == false ]]; then - yq --inplace '.resources += [ "flux-system" ]' "${PROJECT_DIR}/cluster/apps/kustomization.yaml" + if [[ $(yq eval --no-doc 'contains({"resources": ["webhooks"]})' "${PROJECT_DIR}/cluster/apps/flux-system/kustomization.yaml") == false ]]; then + yq --inplace '.resources += [ "webhooks" ]' "${PROJECT_DIR}/cluster/apps/flux-system/kustomization.yaml" fi fi }