From 5dcfc42aaf77423a19f1c40dadc01ab02e0c48a9 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Wed, 10 Apr 2024 13:08:05 +0300 Subject: [PATCH] Provision production cluster Signed-off-by: Stefan Prodan --- clusters/production/apps/kustomization.yaml | 9 ++ clusters/production/apps/podinfo-values.yaml | 17 +++ .../infra-configs/kustomization.yaml | 4 + .../infra-controllers/kustomization.yaml | 4 + .../production/tenants/kustomization.yaml | 4 + hub/production.yaml | 114 ++++++++++++++++++ 6 files changed, 152 insertions(+) create mode 100644 clusters/production/apps/kustomization.yaml create mode 100644 clusters/production/apps/podinfo-values.yaml create mode 100644 clusters/production/infra-configs/kustomization.yaml create mode 100644 clusters/production/infra-controllers/kustomization.yaml create mode 100644 clusters/production/tenants/kustomization.yaml create mode 100644 hub/production.yaml diff --git a/clusters/production/apps/kustomization.yaml b/clusters/production/apps/kustomization.yaml new file mode 100644 index 0000000..a5ffe02 --- /dev/null +++ b/clusters/production/apps/kustomization.yaml @@ -0,0 +1,9 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../../../deploy/apps +patches: + - path: podinfo-values.yaml + target: + kind: HelmRelease + name: podinfo diff --git a/clusters/production/apps/podinfo-values.yaml b/clusters/production/apps/podinfo-values.yaml new file mode 100644 index 0000000..bf56292 --- /dev/null +++ b/clusters/production/apps/podinfo-values.yaml @@ -0,0 +1,17 @@ +apiVersion: helm.toolkit.fluxcd.io/v2beta2 +kind: HelmRelease +metadata: + name: podinfo +spec: + chart: + spec: + version: ">=1.0.0-alpha" + test: + enable: false + values: + ingress: + hosts: + - host: podinfo.production + paths: + - path: / + pathType: ImplementationSpecific diff --git a/clusters/production/infra-configs/kustomization.yaml b/clusters/production/infra-configs/kustomization.yaml new file mode 100644 index 0000000..9762e98 --- /dev/null +++ b/clusters/production/infra-configs/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../../../deploy/infra-configs diff --git a/clusters/production/infra-controllers/kustomization.yaml b/clusters/production/infra-controllers/kustomization.yaml new file mode 100644 index 0000000..cb95b5d --- /dev/null +++ b/clusters/production/infra-controllers/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../../../deploy/infra-controllers diff --git a/clusters/production/tenants/kustomization.yaml b/clusters/production/tenants/kustomization.yaml new file mode 100644 index 0000000..d59125c --- /dev/null +++ b/clusters/production/tenants/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../../../deploy/tenants diff --git a/hub/production.yaml b/hub/production.yaml new file mode 100644 index 0000000..e1090e9 --- /dev/null +++ b/hub/production.yaml @@ -0,0 +1,114 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: production +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: tenants + namespace: production +spec: + interval: 1h + retryInterval: 3m + timeout: 5m + prune: true + wait: true + path: ./clusters/production/tenants + sourceRef: + kind: GitRepository + name: flux-system + namespace: flux-system + kubeConfig: + secretRef: + name: cluster-kubeconfig + postBuild: + substitute: + CLUSTER_NAME: production +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: infra-controllers + namespace: production +spec: + dependsOn: + - name: tenants + targetNamespace: production + interval: 1h + retryInterval: 3m + timeout: 5m + prune: true + wait: true + path: ./clusters/production/infra-controllers + sourceRef: + kind: GitRepository + name: flux-system + namespace: flux-system + patches: + - target: + kind: HelmRelease + patch: | + - op: add + path: /spec/kubeConfig + value: + secretRef: + name: cluster-kubeconfig + - op: add + path: /spec/serviceAccountName + value: flux-cluster-admin +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: infra-configs + namespace: production +spec: + dependsOn: + - name: infra-controllers + targetNamespace: production + interval: 1h + retryInterval: 3m + timeout: 5m + prune: true + wait: true + path: ./clusters/production/infra-configs + sourceRef: + kind: GitRepository + name: flux-system + namespace: flux-system + kubeConfig: + secretRef: + name: cluster-kubeconfig +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: apps + namespace: production +spec: + dependsOn: + - name: infra-configs + targetNamespace: production + interval: 1h + retryInterval: 3m + timeout: 5m + prune: true + wait: true + path: ./clusters/production/apps + sourceRef: + kind: GitRepository + name: flux-system + namespace: flux-system + patches: + - target: + kind: HelmRelease + patch: | + - op: add + path: /spec/kubeConfig + value: + secretRef: + name: cluster-kubeconfig + - op: add + path: /spec/serviceAccountName + value: flux-restricted