Skip to content
This repository was archived by the owner on Mar 22, 2024. It is now read-only.

Commit d341c5a

Browse files
authored
UpstreamAuthority cert-manager support (#82)
1 parent a82ee69 commit d341c5a

File tree

8 files changed

+95
-0
lines changed

8 files changed

+95
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
apiVersion: cert-manager.io/v1
3+
kind: Issuer
4+
metadata:
5+
name: selfsigned-issuer
6+
spec:
7+
selfSigned: {}
8+
---
9+
apiVersion: cert-manager.io/v1
10+
kind: Certificate
11+
metadata:
12+
name: demo-selfsigned-ca
13+
spec:
14+
isCA: true
15+
commonName: demo-selfsigned-ca
16+
secretName: root-secret
17+
privateKey:
18+
algorithm: ECDSA
19+
size: 256
20+
issuerRef:
21+
name: selfsigned-issuer
22+
kind: Issuer
23+
group: cert-manager.io
24+
---
25+
apiVersion: cert-manager.io/v1
26+
kind: Issuer
27+
metadata:
28+
name: demo-ca
29+
spec:
30+
ca:
31+
secretName: root-secret
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
helm install cert-manager cert-manager --namespace cert-manager --create-namespace --version v1.11.0 --set installCRDs=true --repo https://charts.jetstack.io --wait
4+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
5+
kubectl apply -f $SCRIPT_DIR/cert-manager-ca.yaml -n "$VALUES"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
spire-server:
2+
upstreamAuthority:
3+
certManager:
4+
enabled: true
5+
issuer_name: "demo-ca"

.github/workflows/helm-chart-ci.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,15 @@ jobs:
151151

152152
- name: Run chart-testing (install)
153153
run: |
154+
[ "$VALUES" != "default" ] && kubectl create namespace "$VALUES"
155+
post-install() {
156+
[ -x .github/tests/$VALUES/post-install.sh ] && .github/tests/$VALUES/post-install.sh
157+
exit $1
158+
}
159+
trap 'post-install $? $LINENO' EXIT
160+
[ -x .github/tests/$VALUES/pre-install.sh ] && .github/tests/$VALUES/pre-install.sh
154161
ct install --debug \
162+
--namespace $VALUES \
155163
--target-branch ${{ github.base_ref }} \
156164
--exclude-deprecated \
157165
${{ (matrix.values != 'default' && '--helm-extra-set-args "--values=.github/tests/$VALUES/values.yaml"') || '' }}

charts/spire/charts/spire-server/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ A Helm chart to install the SPIRE server.
7878
| tolerations | list | `[]` | |
7979
| topologySpreadConstraints | list | `[]` | |
8080
| trustDomain | string | `"example.org"` | |
81+
| upstreamAuthority.certManager.enabled | bool | `false` | |
82+
| upstreamAuthority.certManager.issuer_group | string | `"cert-manager.io"` | |
83+
| upstreamAuthority.certManager.issuer_kind | string | `"Issuer"` | |
84+
| upstreamAuthority.certManager.issuer_name | string | `"spire-ca"` | |
85+
| upstreamAuthority.certManager.kube_config_file | string | `""` | |
86+
| upstreamAuthority.certManager.namespace | string | `""` | Specify to use a namespace other then the one the chart is installed into |
87+
| upstreamAuthority.certManager.rbac.create | bool | `true` | |
8188
| upstreamAuthority.disk.enabled | bool | `false` | |
8289
| upstreamAuthority.disk.secret.create | bool | `true` | If disabled requires you to create a secret with the given keys (certificate, key and optional bundle) yourself. |
8390
| upstreamAuthority.disk.secret.data | object | `{"bundle":"","certificate":"","key":""}` | If secret creation is enabled, will create a secret with following certificate info |

charts/spire/charts/spire-server/templates/configmap.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{ $namespace := .Release.Namespace }}
12
apiVersion: v1
23
kind: ConfigMap
34
metadata:
@@ -71,6 +72,22 @@ data:
7172
}
7273
{{- end }}
7374
{{- end }}
75+
76+
{{- with .Values.upstreamAuthority.certManager }}
77+
{{- if eq (.enabled | toString) "true" }}
78+
UpstreamAuthority "cert-manager" {
79+
plugin_data {
80+
issuer_name = {{ .issuer_name | quote }}
81+
issuer_kind = {{ .issuer_kind | quote }}
82+
issuer_group = {{ .issuer_group | quote }}
83+
namespace = {{ default $namespace .namespace | quote }}
84+
{{- if ne .kube_config_file "" }}
85+
kube_config_file = {{ .kube_config_file | quote }}
86+
{{- end }}
87+
}
88+
}
89+
{{- end }}
90+
{{- end }}
7491
}
7592
7693
health_checks {

charts/spire/charts/spire-server/templates/roles.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ rules:
1818
verbs:
1919
- get
2020
- patch
21+
{{- if and .Values.upstreamAuthority.certManager.enabled .Values.upstreamAuthority.certManager.rbac.create }}
22+
- apiGroups: ["cert-manager.io"]
23+
resources:
24+
- certificaterequests
25+
verbs:
26+
- list
27+
- get
28+
- create
29+
- delete
30+
- patch
31+
- update
32+
{{- end }}
2133
---
2234
kind: RoleBinding
2335
apiVersion: rbac.authorization.k8s.io/v1

charts/spire/charts/spire-server/values.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ upstreamAuthority:
104104
certificate: ""
105105
key: ""
106106
bundle: ""
107+
certManager:
108+
enabled: false
109+
rbac:
110+
create: true
111+
issuer_name: "spire-ca"
112+
issuer_kind: "Issuer"
113+
issuer_group: "cert-manager.io"
114+
# -- Specify to use a namespace other then the one the chart is installed into
115+
namespace: ""
116+
kube_config_file: ""
107117

108118
controllerManager:
109119
enabled: false

0 commit comments

Comments
 (0)