Skip to content

Commit 79ab646

Browse files
committed
feat(platform-namespace-core): update chart version to 0.3.0 and add validation for namespace labels
Signed-off-by: Arthur Le Roux <[email protected]>
1 parent 750e8d5 commit 79ab646

File tree

7 files changed

+72
-86
lines changed

7 files changed

+72
-86
lines changed

charts/platform-namespace-core/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: platform-namespace-core
33
description: A Helm chart that defines core Kubernetes platform namespaced resources
44
type: application
5-
version: 0.2.0
5+
version: 0.3.0
66
appVersion: "0.1.0"
77
icon: https://avatars.githubusercontent.com/u/9391624?s=200&v=4
88
home: https://github.com/wiremind/wiremind-helm-charts/tree/main/charts/platform-namespace-core

charts/platform-namespace-core/templates/_helpers.tpl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,33 @@ Usage: {{ include "platform-namespace-core.serviceAccountName" (dict "def" $def
6363
{{ printf "%s" $defName }}
6464
{{- end -}}
6565
{{- end -}}
66+
67+
{{/*
68+
Validate the platform-namespace-core chart.
69+
*/}}
70+
{{- define "platform-namespace-core.validate" -}}
71+
{{- $errors := list -}}
72+
{{ if .Values.namespace.create }}
73+
{{- if not (hasKey .Values.namespace.labels "project") }}
74+
{{- $errors = append $errors (printf "Namespace label 'project' must be defined for platform-namespace-core") -}}
75+
{{- end -}}
76+
{{- if not (hasKey .Values.namespace.labels "product") }}
77+
{{- $errors = append $errors (printf "Namespace label 'product' must be defined for platform-namespace-core") -}}
78+
{{- end -}}
79+
{{- end -}}
80+
81+
{{- if gt (len $errors) 0 }}
82+
{{- fail (join "\n" $errors) }}
83+
{{- end -}}
84+
{{- end -}}
85+
86+
{{/*
87+
ClusterSecretStore name definition.
88+
*/}}
89+
{{- define "platform-namespace-core.cluster-secret-store.name" -}}
90+
{{- if eq .Values.namespace.labels.project "platform" -}}
91+
{{- printf "%s-platform-%s" .Values.clusterSecretStore.provider.name .Release.Name -}}
92+
{{- else -}}
93+
{{- printf "%s-%s" .Values.clusterSecretStore.provider.name .Release.Name -}}
94+
{{- end -}}
95+
{{- end -}}
Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,24 @@
1-
{{- if .Values.externalSecrets.enabled }}
2-
3-
{{- range $name, $cfg := .Values.externalSecrets.clusterSecretStore }}
4-
5-
{{- if or (not (hasKey $cfg "enabled")) $cfg.enabled }}
1+
{{- if .Values.clusterSecretStore.enabled -}}
62

73
apiVersion: external-secrets.io/v1
84
kind: ClusterSecretStore
95
metadata:
10-
name: {{ printf "%s-%s" $.Values.externalSecrets.provider.name $name | quote }}
6+
name: {{ include "platform-namespace-core.cluster-secret-store.name" $ }}
117
labels:
128
{{- include "platform-namespace-core.labels" $ | nindent 4 }}
139
spec:
1410
provider:
15-
{{- if eq $.Values.externalSecrets.provider.name "infisical" }}
16-
infisical:
17-
auth:
18-
universalAuthCredentials:
19-
clientId:
20-
key: clientId
21-
name: {{ $.Values.externalSecrets.provider.secretName | quote }}
22-
namespace: {{ $.Values.externalSecrets.provider.secretNamespace | quote }}
23-
clientSecret:
24-
key: clientSecret
25-
name: {{ $.Values.externalSecrets.provider.secretName | quote }}
26-
namespace: {{ $.Values.externalSecrets.provider.secretNamespace | quote }}
27-
hostAPI: {{ $.Values.externalSecrets.provider.hostAPI | quote }}
28-
secretsScope:
29-
projectSlug: {{ $cfg.project | quote }}
30-
environmentSlug: {{ $cfg.environment | quote }}
31-
recursive: true
32-
secretsPath: {{ $cfg.folder | quote }}
33-
{{- end }}
11+
{{- toYaml .Values.clusterSecretStore.provider | nindent 4 }}
3412
conditions:
35-
- key: "kubernetes.io/metadata.name"
36-
operator: "In"
37-
values:
38-
- "default"
39-
- {{ $.Release.Name | quote }}
40-
{{- with $cfg.namespaceConditions }}
41-
{{- toYaml . | nindent 4 }}
42-
{{- end }}
43-
44-
---
45-
46-
{{- end }}
47-
48-
{{- end }}
13+
{{- if eq $.Values.namespace.labels.project "platform" }}
14+
- namespaces:
15+
- {{ $.Release.Name | quote }}
16+
{{- else }}
17+
- namespaceSelector:
18+
matchLabels:
19+
{{- range $key, $value := $.Values.namespace.labels }}
20+
{{ $key }}: {{ $value | quote }}
21+
{{- end }}
22+
{{- end }}
4923

50-
{{- end }}
24+
{{- end -}}

charts/platform-namespace-core/templates/external-secrets/externalsecret.yaml

Lines changed: 0 additions & 38 deletions
This file was deleted.

charts/platform-namespace-core/templates/namespace.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ metadata:
99
{{- with .Values.namespace.labels }}
1010
{{- toYaml . | nindent 4 }}
1111
{{- end }}
12+
{{- if .Values.namespace.reloader.enabled }}
13+
reloader: enabled
14+
{{- end }}
1215
{{- with .Values.namespace.annotations }}
1316
annotations:
1417
{{- toYaml . | nindent 4 }}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ include "platform-namespace-core.validate" . }}

charts/platform-namespace-core/values.yaml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,29 @@ certManager:
88
dnsNames:
99
- "*.{{ .Release.Name }}.{{ .Values.certManager.certificates.wildcard.domain }}"
1010

11-
externalSecrets:
11+
clusterSecretStore:
1212
enabled: false
1313
provider:
14-
name: ""
15-
secretName: "credentials"
16-
secretNamespace: "default"
17-
hostAPI: "https://example.com"
18-
clusterSecretStore: {}
19-
externalSecret: {}
14+
# Example configuration for AWS Provider
15+
# Full documentation for all providers: https://external-secrets.io/latest/provider
16+
aws:
17+
service: SecretsManager
18+
role: iam-role
19+
region: eu-central-1
20+
auth:
21+
secretRef:
22+
accessKeyIDSecretRef:
23+
namespace: external-secrets
24+
name: awssm-secret
25+
key: access-key
26+
secretAccessKeySecretRef:
27+
namespace: external-secrets
28+
name: awssm-secret
29+
key: secret-access-key
30+
jwt:
31+
serviceAccountRef:
32+
name: my-serviceaccount
33+
namespace: sa-namespace
2034

2135
gitlabRunnersConfig:
2236
enabled: false
@@ -44,6 +58,8 @@ namespace:
4458
create: false
4559
labels: {}
4660
annotations: {}
61+
reloader:
62+
enabled: true
4763
podSecurityLabels:
4864
profile: baseline
4965
definitions:

0 commit comments

Comments
 (0)