From 4f6a475f23f3d4c0ed30ce3d43eace384ffcc9e1 Mon Sep 17 00:00:00 2001 From: "thibault.raquet" Date: Tue, 25 Jun 2024 15:03:16 +0200 Subject: [PATCH] add external secrets --- ...-agent.yaml.inactive => gitlab-agent.yaml} | 44 +++++++++---------- ...unner.yaml.inactive => gitlab-runner.yaml} | 44 +++++++++---------- ...c-custom.yaml.inactive => ldc-custom.yaml} | 34 +++++++------- .../resources/cert-manager.yaml | 22 ++++++++++ .../resources/cluster-secret-store.yaml | 4 +- .../resources/flux-resources.yaml | 22 ++++++++++ .../resources/gitlab-agent.yaml | 2 +- .../resources/gitlab-runner.yaml | 2 +- .../external-secrets/resources/mariadb.yaml | 28 ++++++++++++ .../resources/prometheus-stack.yaml | 27 ++++++++++++ 10 files changed, 164 insertions(+), 65 deletions(-) rename flux/production/kustomizations/{gitlab-agent.yaml.inactive => gitlab-agent.yaml} (95%) rename flux/production/kustomizations/{gitlab-runner.yaml.inactive => gitlab-runner.yaml} (95%) rename flux/production/kustomizations/{ldc-custom.yaml.inactive => ldc-custom.yaml} (95%) create mode 100644 infrastructure/hashicorp-vault/external-secrets/resources/cert-manager.yaml create mode 100644 infrastructure/hashicorp-vault/external-secrets/resources/flux-resources.yaml create mode 100644 infrastructure/hashicorp-vault/external-secrets/resources/mariadb.yaml create mode 100644 infrastructure/hashicorp-vault/external-secrets/resources/prometheus-stack.yaml diff --git a/flux/production/kustomizations/gitlab-agent.yaml.inactive b/flux/production/kustomizations/gitlab-agent.yaml similarity index 95% rename from flux/production/kustomizations/gitlab-agent.yaml.inactive rename to flux/production/kustomizations/gitlab-agent.yaml index f56ff2f..5f46189 100644 --- a/flux/production/kustomizations/gitlab-agent.yaml.inactive +++ b/flux/production/kustomizations/gitlab-agent.yaml @@ -1,22 +1,22 @@ ---- -apiVersion: kustomize.toolkit.fluxcd.io/v1 -kind: Kustomization -metadata: - name: gitlab-agent - namespace: flux-system -spec: - interval: 30s - path: ./infrastructure/gitlab-agent - prune: false - dependsOn: - - name: flux-resources - namespace: flux-system - sourceRef: - kind: GitRepository - name: cluster-k8s - healthChecks: - - apiVersion: source.toolkit.fluxcd.io/v1 - kind: HelmRepository - name: gitlab-agent - namespace: common-services - timeout: 5m +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: gitlab-agent + namespace: flux-system +spec: + interval: 30s + path: ./infrastructure/gitlab-agent + prune: false + dependsOn: + - name: flux-resources + namespace: flux-system + sourceRef: + kind: GitRepository + name: cluster-k8s + healthChecks: + - apiVersion: source.toolkit.fluxcd.io/v1 + kind: HelmRepository + name: gitlab-agent + namespace: common-services + timeout: 5m diff --git a/flux/production/kustomizations/gitlab-runner.yaml.inactive b/flux/production/kustomizations/gitlab-runner.yaml similarity index 95% rename from flux/production/kustomizations/gitlab-runner.yaml.inactive rename to flux/production/kustomizations/gitlab-runner.yaml index ea58b35..01b94ab 100644 --- a/flux/production/kustomizations/gitlab-runner.yaml.inactive +++ b/flux/production/kustomizations/gitlab-runner.yaml @@ -1,22 +1,22 @@ ---- -apiVersion: kustomize.toolkit.fluxcd.io/v1 -kind: Kustomization -metadata: - name: gitlab-runner - namespace: flux-system -spec: - interval: 30s - path: ./infrastructure/gitlab-runner - prune: false - dependsOn: - - name: flux-resources - namespace: flux-system - sourceRef: - kind: GitRepository - name: cluster-k8s - healthChecks: - - apiVersion: source.toolkit.fluxcd.io/v1 - kind: HelmRepository - name: gitlab-runner - namespace: common-services - timeout: 5m +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: gitlab-runner + namespace: flux-system +spec: + interval: 30s + path: ./infrastructure/gitlab-runner + prune: false + dependsOn: + - name: flux-resources + namespace: flux-system + sourceRef: + kind: GitRepository + name: cluster-k8s + healthChecks: + - apiVersion: source.toolkit.fluxcd.io/v1 + kind: HelmRepository + name: gitlab-runner + namespace: common-services + timeout: 5m diff --git a/flux/production/kustomizations/ldc-custom.yaml.inactive b/flux/production/kustomizations/ldc-custom.yaml similarity index 95% rename from flux/production/kustomizations/ldc-custom.yaml.inactive rename to flux/production/kustomizations/ldc-custom.yaml index 99d2405..0b00b11 100644 --- a/flux/production/kustomizations/ldc-custom.yaml.inactive +++ b/flux/production/kustomizations/ldc-custom.yaml @@ -1,17 +1,17 @@ ---- -apiVersion: kustomize.toolkit.fluxcd.io/v1 -kind: Kustomization -metadata: - name: ldc-custom - namespace: flux-system -spec: - interval: 30s - path: ./infrastructure/ldc-custom - prune: false - sourceRef: - kind: GitRepository - name: cluster-k8s - dependsOn: - - name: prometheus-stack - namespace: flux-system - timeout: 5m +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: ldc-custom + namespace: flux-system +spec: + interval: 30s + path: ./infrastructure/ldc-custom + prune: false + sourceRef: + kind: GitRepository + name: cluster-k8s + dependsOn: + - name: prometheus-stack + namespace: flux-system + timeout: 5m diff --git a/infrastructure/hashicorp-vault/external-secrets/resources/cert-manager.yaml b/infrastructure/hashicorp-vault/external-secrets/resources/cert-manager.yaml new file mode 100644 index 0000000..19f0ed6 --- /dev/null +++ b/infrastructure/hashicorp-vault/external-secrets/resources/cert-manager.yaml @@ -0,0 +1,22 @@ +apiVersion: external-secrets.io/v1beta1 +kind: ExternalSecret +metadata: + name: cloudflare-api-token-secret + namespace: common-services +spec: + refreshInterval: "15s" + secretStoreRef: + name: vault-secret-store + kind: ClusterSecretStore + target: + name: cloudflare-api-token-secret + template: + engineVersion: v2 + type: Opaque + data: + api-token: "{{ .api_key }}" + data: + - secretKey: api_key + remoteRef: + key: secret/certificate + property: cloudflare_token diff --git a/infrastructure/hashicorp-vault/external-secrets/resources/cluster-secret-store.yaml b/infrastructure/hashicorp-vault/external-secrets/resources/cluster-secret-store.yaml index 6124953..bba184e 100644 --- a/infrastructure/hashicorp-vault/external-secrets/resources/cluster-secret-store.yaml +++ b/infrastructure/hashicorp-vault/external-secrets/resources/cluster-secret-store.yaml @@ -5,7 +5,7 @@ metadata: spec: provider: vault: - server: "http://vault.vault.svc.cluster.local:8200" + server: "http://vault.common-services.svc.cluster.local:8200" path: "secret" version: "v2" auth: @@ -13,5 +13,5 @@ spec: # https://www.vaultproject.io/docs/auth/token tokenSecretRef: name: "vault-token" - namespace: "vault" + namespace: "common-services" key: "token" diff --git a/infrastructure/hashicorp-vault/external-secrets/resources/flux-resources.yaml b/infrastructure/hashicorp-vault/external-secrets/resources/flux-resources.yaml new file mode 100644 index 0000000..9fe6cd8 --- /dev/null +++ b/infrastructure/hashicorp-vault/external-secrets/resources/flux-resources.yaml @@ -0,0 +1,22 @@ +apiVersion: external-secrets.io/v1beta1 +kind: ExternalSecret +metadata: + name: msteams-url + namespace: flux-system +spec: + refreshInterval: "15s" + secretStoreRef: + name: vault-secret-store + kind: ClusterSecretStore + target: + name: msteams-url + template: + engineVersion: v2 + type: Opaque + data: + address: "{{ .url }}" + data: + - secretKey: url + remoteRef: + key: secret/teams + property: flux_teams_webhook diff --git a/infrastructure/hashicorp-vault/external-secrets/resources/gitlab-agent.yaml b/infrastructure/hashicorp-vault/external-secrets/resources/gitlab-agent.yaml index 2e67517..4d5fffd 100644 --- a/infrastructure/hashicorp-vault/external-secrets/resources/gitlab-agent.yaml +++ b/infrastructure/hashicorp-vault/external-secrets/resources/gitlab-agent.yaml @@ -2,7 +2,7 @@ apiVersion: external-secrets.io/v1beta1 kind: ExternalSecret metadata: name: gitlab-agent-token - namespace: gitlab + namespace: common-services spec: refreshInterval: "15s" secretStoreRef: diff --git a/infrastructure/hashicorp-vault/external-secrets/resources/gitlab-runner.yaml b/infrastructure/hashicorp-vault/external-secrets/resources/gitlab-runner.yaml index fa13013..3c8fbda 100644 --- a/infrastructure/hashicorp-vault/external-secrets/resources/gitlab-runner.yaml +++ b/infrastructure/hashicorp-vault/external-secrets/resources/gitlab-runner.yaml @@ -3,7 +3,7 @@ apiVersion: external-secrets.io/v1beta1 kind: ExternalSecret metadata: name: gitlab-runner-token - namespace: gitlab + namespace: common-services spec: refreshInterval: "15s" secretStoreRef: diff --git a/infrastructure/hashicorp-vault/external-secrets/resources/mariadb.yaml b/infrastructure/hashicorp-vault/external-secrets/resources/mariadb.yaml new file mode 100644 index 0000000..533cce3 --- /dev/null +++ b/infrastructure/hashicorp-vault/external-secrets/resources/mariadb.yaml @@ -0,0 +1,28 @@ +apiVersion: external-secrets.io/v1beta1 +kind: ExternalSecret +metadata: + name: mariadb-credentials + namespace: common-services +spec: + refreshInterval: "15s" + secretStoreRef: + name: vault-secret-store + kind: ClusterSecretStore + target: + name: mariadb-credentials + template: + engineVersion: v2 + type: Opaque + data: + mariadb-password: "{{ .password }}" + mariadb-replication-password: "{{ .root_password }}" + mariadb-root-password: "{{ .root_password }}" + data: + - secretKey: root_password + remoteRef: + key: secret/mariadb + property: root_password + - secretKey: password + remoteRef: + key: secret/mariadb + property: password diff --git a/infrastructure/hashicorp-vault/external-secrets/resources/prometheus-stack.yaml b/infrastructure/hashicorp-vault/external-secrets/resources/prometheus-stack.yaml new file mode 100644 index 0000000..fc40aec --- /dev/null +++ b/infrastructure/hashicorp-vault/external-secrets/resources/prometheus-stack.yaml @@ -0,0 +1,27 @@ +apiVersion: external-secrets.io/v1beta1 +kind: ExternalSecret +metadata: + name: grafana-admin + namespace: common-services +spec: + refreshInterval: "15s" + secretStoreRef: + name: vault-secret-store + kind: ClusterSecretStore + target: + name: grafana-admin + template: + engineVersion: v2 + type: Opaque + data: + user: "{{ .user }}" + password: "{{ .password }}" + data: + - secretKey: user + remoteRef: + key: secret/prometheus-stack + property: grafana_user + - secretKey: password + remoteRef: + key: secret/prometheus-stack + property: grafana_admin_password