Skip to content

Commit c520b31

Browse files
committed
fix: certificate namespaces in helm
Signed-off-by: Lukas Reining <[email protected]>
1 parent ed9e319 commit c520b31

File tree

4 files changed

+71
-1
lines changed

4 files changed

+71
-1
lines changed

.github/scripts/strip-kustomize-helm.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
echo 'Running strip-kustomize-helm.sh script'
1010
CHARTS_DIR='./chart/open-feature-operator/templates'
11+
1112
# Careful! Ordering of these expressions matter!
1213
sed_expressions=(
1314
"s/___newline___/\\n/g"
@@ -17,9 +18,16 @@ sed_expressions=(
1718
"/___delete_me___/d"
1819
"s/___//g"
1920
)
21+
2022
find $CHARTS_DIR -name "*.yaml" | while read file; do
2123
for expr in "${sed_expressions[@]}"; do
22-
sed -i "$expr" "$file"
24+
if [[ "$OSTYPE" == "darwin"* ]]; then
25+
# macOS (BSD) version
26+
sed -i '' "$expr" "$file"
27+
else
28+
# Linux (GNU) version
29+
sed -i "$expr" "$file"
30+
fi
2331
done
2432
done
2533

config/default/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ replacements:
7979
delimiter: '.'
8080
index: 0
8181
create: true
82+
8283
- source:
8384
kind: Service
8485
version: v1
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: cert-manager.io/v1
2+
kind: Certificate
3+
metadata:
4+
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml
5+
spec:
6+
dnsNames:
7+
- SERVICE_NAME.{{ include "chart.namespace" . }}.svc
8+
- SERVICE_NAME.{{ include "chart.namespace" . }}.svc.cluster.local
9+
---
10+
# The following manifests contain a self-signed issuer CR and a metrics certificate CR.
11+
# More document can be found at https://docs.cert-manager.io
12+
apiVersion: cert-manager.io/v1
13+
kind: Certificate
14+
metadata:
15+
name: metrics-certs # this name should match the one appeared in kustomizeconfig.yaml
16+
spec:
17+
dnsNames:
18+
# SERVICE_NAME and SERVICE_NAMESPACE will be substituted by kustomize
19+
# replacements in the config/default/kustomization.yaml file.
20+
- SERVICE_NAME.{{ include "chart.namespace" . }}.svc
21+
- SERVICE_NAME.{{ include "chart.namespace" . }}.svc.cluster.local

config/overlays/helm/kustomization.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,49 @@ patches:
1717
- path: exclude-webhook-server-container-port.yaml
1818
- path: exclude-validatingwebhook.yaml
1919
- path: mutatingwebhook.yaml
20+
- path: certificate-patch.yaml
2021

2122
configMapGenerator:
2223
- name: manager-config
2324
behavior: merge
2425
files:
2526
- controller_manager_config.yaml
27+
28+
replacements:
29+
- source: # Uncomment the following block to enable certificates for metrics
30+
kind: Service
31+
version: v1
32+
name: controller-manager-metrics-service
33+
fieldPath: metadata.name
34+
targets:
35+
- select:
36+
kind: Certificate
37+
group: cert-manager.io
38+
version: v1
39+
name: metrics-certs
40+
fieldPaths:
41+
- spec.dnsNames.0
42+
- spec.dnsNames.1
43+
options:
44+
delimiter: '.'
45+
index: 0
46+
create: true
47+
48+
- source: # Uncomment the following block if you have any webhook
49+
kind: Service
50+
version: v1
51+
name: webhook-service
52+
fieldPath: .metadata.name # Name of the service
53+
targets:
54+
- select:
55+
kind: Certificate
56+
group: cert-manager.io
57+
version: v1
58+
name: serving-cert
59+
fieldPaths:
60+
- spec.dnsNames.0
61+
- spec.dnsNames.1
62+
options:
63+
delimiter: '.'
64+
index: 0
65+
create: true

0 commit comments

Comments
 (0)