diff --git a/charts/infrastructure/templates/_helpers/es-cluster-store.tpl b/charts/infrastructure/templates/_helpers/es-cluster-store.tpl new file mode 100644 index 0000000..2da2bd8 --- /dev/null +++ b/charts/infrastructure/templates/_helpers/es-cluster-store.tpl @@ -0,0 +1,53 @@ +{{ define "es-cluster-store" -}} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: secret-manager-{{ .namespace }} + namespace: {{ .namespace }} +rules: +- apiGroups: [""] + resources: ["secrets"] + verbs: ["list", "get"] +--- +apiVersion: v1 +automountServiceAccountToken: true +kind: ServiceAccount +metadata: + name: secret-manager-{{ .namespace }} + namespace: {{ .namespace }} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: secret-manager-{{ .namespace }} + namespace: {{ .namespace }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: secret-manager-{{ .namespace }} +subjects: +- kind: ServiceAccount + name: secret-manager-{{ .namespace }} + namespace: {{ .namespace }} + +--- +apiVersion: external-secrets.io/v1beta1 +kind: ClusterSecretStore +metadata: + name: {{ .namespace }} +spec: + provider: + kubernetes: + remoteNamespace: {{ .namespace }} + server: + caProvider: + type: ConfigMap + name: kube-root-ca.crt + key: ca.crt + namespace: {{ .namespace }} + auth: + serviceAccount: + name: secret-manager-{{ .namespace }} + namespace: {{ .namespace }} +{{ end }} \ No newline at end of file diff --git a/charts/infrastructure/templates/es-cluster-store.yaml b/charts/infrastructure/templates/es-cluster-store.yaml new file mode 100644 index 0000000..b03646d --- /dev/null +++ b/charts/infrastructure/templates/es-cluster-store.yaml @@ -0,0 +1,3 @@ +{{ range $i, $val := .Values.enabledClusterSecretStores }} +{{ include "es-cluster-store" (dict "name" $val)}} +{{ end }} \ No newline at end of file diff --git a/charts/infrastructure/values.yaml b/charts/infrastructure/values.yaml index b0129d2..97f16d6 100644 --- a/charts/infrastructure/values.yaml +++ b/charts/infrastructure/values.yaml @@ -15,4 +15,7 @@ gitops: metallb: addresses: - - 10.0.100.1-10.0.100.255 \ No newline at end of file + - 10.0.100.1-10.0.100.255 + +enabledClusterSecretStores: + - secrets \ No newline at end of file diff --git a/tf-secrets.tf b/tf-secrets.tf new file mode 100644 index 0000000..8f4b228 --- /dev/null +++ b/tf-secrets.tf @@ -0,0 +1,17 @@ +resource "kubernetes_namespace" "secrets" { + metadata { + name = "secrets" + } +} +resource "kubernetes_secret" "vpn" { + metadata { + name = "vpn-credentials" + namespace = "secrets" + } + data = { + user = var.vpn.user + password = var.vpn.password + provider = var.vpn.provider + country = var.vpn.country + } +} diff --git a/tf-variables.tf b/tf-variables.tf index 81725e6..8396636 100644 --- a/tf-variables.tf +++ b/tf-variables.tf @@ -31,6 +31,16 @@ variable "tailscale" { }) sensitive = true } +variable "vpn" { + type = object({ + user = string, + password = string, + provider = string, + country = string, + }) + sensitive = true + +} variable "globals" { type = object({