Skip to content

Commit 288f033

Browse files
Merge pull request #141 from SgtCoDFish/runtimeconfiguration
Allow runtime configuration of issuers
2 parents c41e87f + a7f2470 commit 288f033

File tree

14 files changed

+978
-12
lines changed

14 files changed

+978
-12
lines changed

deploy/charts/csi-driver-spiffe/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ Verbosity of cert-manager-csi-driver logging.
9494
> ```
9595

9696
Duration requested for requested certificates.
97+
#### **app.runtimeIssuanceConfigMap** ~ `string`
98+
> Default value:
99+
> ```yaml
100+
> ""
101+
> ```
102+
103+
Name of a ConfigMap in the installation namespace to watch, providing runtime configuration of an issuer to use.
104+
105+
The "issuer-name", "issuer-kind" and "issuer-group" keys must be present in the ConfigMap for it to be used.
97106
#### **app.extraCertificateRequestAnnotations** ~ `unknown`
98107
> Default value:
99108
> ```yaml

deploy/charts/csi-driver-spiffe/templates/daemonset.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ spec:
8383
- --node-id=$(NODE_ID)
8484
- --endpoint=$(CSI_ENDPOINT)
8585
- --data-root=csi-data-dir
86+
- "--runtime-issuance-config-map-name={{.Values.app.runtimeIssuanceConfigMap}}"
87+
- "--runtime-issuance-config-map-namespace={{.Release.Namespace}}"
8688
{{- if .Values.app.extraCertificateRequestAnnotations }}
8789
- --extra-certificate-request-annotations={{ .Values.app.extraCertificateRequestAnnotations }}
8890
{{- end }}

deploy/charts/csi-driver-spiffe/templates/role.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
kind: Role
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
metadata:
4+
name: {{ include "cert-manager-csi-driver-spiffe.name" . }}
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
{{- include "cert-manager-csi-driver-spiffe.labels" . | nindent 4 }}
8+
rules:
9+
{{- if .Values.app.runtimeIssuanceConfigMap }}
10+
- apiGroups: [""]
11+
resources: ["configmaps"]
12+
verbs: ["get", "list", "watch"]
13+
resourceNames: ["{{.Values.app.runtimeIssuanceConfigMap}}"]
14+
{{- end }}
15+
16+
17+
---
18+
119
kind: Role
220
apiVersion: rbac.authorization.k8s.io/v1
321
metadata:

deploy/charts/csi-driver-spiffe/templates/rolebinding.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
kind: RoleBinding
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
metadata:
4+
name: {{ include "cert-manager-csi-driver-spiffe.name" . }}
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
{{- include "cert-manager-csi-driver-spiffe.labels" . | nindent 4 }}
8+
roleRef:
9+
apiGroup: rbac.authorization.k8s.io
10+
kind: Role
11+
name: {{ include "cert-manager-csi-driver-spiffe.name" . }}
12+
subjects:
13+
- kind: ServiceAccount
14+
name: {{ include "cert-manager-csi-driver-spiffe.name" . }}
15+
namespace: {{ .Release.Namespace }}
16+
17+
---
18+
119
kind: RoleBinding
220
apiVersion: rbac.authorization.k8s.io/v1
321
metadata:

deploy/charts/csi-driver-spiffe/values.schema.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
"name": {
6666
"$ref": "#/$defs/helm-values.app.name"
6767
},
68+
"runtimeIssuanceConfigMap": {
69+
"$ref": "#/$defs/helm-values.app.runtimeIssuanceConfigMap"
70+
},
6871
"trustDomain": {
6972
"$ref": "#/$defs/helm-values.app.trustDomain"
7073
}
@@ -447,6 +450,11 @@
447450
"description": "The name for the CSI driver installation.",
448451
"type": "string"
449452
},
453+
"helm-values.app.runtimeIssuanceConfigMap": {
454+
"default": "",
455+
"description": "Name of a ConfigMap in the installation namespace to watch, providing runtime configuration of an issuer to use.\n\nThe \"issuer-name\", \"issuer-kind\" and \"issuer-group\" keys must be present in the ConfigMap for it to be used.",
456+
"type": "string"
457+
},
450458
"helm-values.app.trustDomain": {
451459
"default": "cluster.local",
452460
"description": "The Trust Domain for this driver.",

deploy/charts/csi-driver-spiffe/values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ app:
4848
logLevel: 1 # 1-5
4949
# Duration requested for requested certificates.
5050
certificateRequestDuration: 1h
51+
52+
# Name of a ConfigMap in the installation namespace to watch, providing
53+
# runtime configuration of an issuer to use.
54+
#
55+
# The "issuer-name", "issuer-kind" and "issuer-group" keys must be present in
56+
# the ConfigMap for it to be used.
57+
runtimeIssuanceConfigMap: ""
58+
5159
# List of annotations to add to certificate requests
5260
#
5361
# For example:

internal/csi/app/app.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ func NewCommand(ctx context.Context) *cobra.Command {
7171
TrustDomain: opts.CertManager.TrustDomain,
7272
CertificateRequestAnnotations: opts.CertManager.CertificateRequestAnnotations,
7373
CertificateRequestDuration: opts.CertManager.CertificateRequestDuration,
74-
IssuerRef: opts.CertManager.IssuerRef,
74+
IssuerRef: &opts.CertManager.IssuerRef,
75+
76+
IssuanceConfigMapName: opts.CertManager.IssuanceConfigMapName,
77+
IssuanceConfigMapNamespace: opts.CertManager.IssuanceConfigMapNamespace,
7578

7679
CertificateFileName: opts.Volume.CertificateFileName,
7780
KeyFileName: opts.Volume.KeyFileName,

internal/csi/app/options/options.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ type OptionsDriver struct {
5656

5757
// OptionsCertManager is options specific to cert-manager CertificateRequests.
5858
type OptionsCertManager struct {
59+
// IssuanceConfigMapName is the name of a ConfigMap to watch for configuration options. The ConfigMap is expected to be in the same namespace as the csi-driver-spiffe pod.
60+
IssuanceConfigMapName string
61+
62+
// IssuanceConfigMapNamespace is the namespace where the runtime configuration ConfigMap is located
63+
IssuanceConfigMapNamespace string
64+
5965
// TrustDomain is the trust domain of this SPIFFE PKI. The TrustDomain will
6066
// appear in signed certificate's URI SANs.
6167
TrustDomain string
@@ -113,6 +119,10 @@ func (o *Options) addDriverFlags(fs *pflag.FlagSet) {
113119
}
114120

115121
func (o *Options) addCertManagerFlags(fs *pflag.FlagSet) {
122+
fs.StringVar(&o.CertManager.IssuanceConfigMapName, "runtime-issuance-config-map-name", "", "Name of a ConfigMap to watch at runtime for issuer details. If such a ConfigMap is found, overrides issuer-name, issuer-kind and issuer-group")
123+
124+
fs.StringVar(&o.CertManager.IssuanceConfigMapNamespace, "runtime-issuance-config-map-namespace", "", "Namespace for ConfigMap to be watched at runtime for issuer details")
125+
116126
fs.StringVar(&o.CertManager.TrustDomain, "trust-domain", "cluster.local",
117127
"The trust domain that will be requested for on created CertificateRequests.")
118128
fs.DurationVar(&o.CertManager.CertificateRequestDuration, "certificate-request-duration", time.Hour,

0 commit comments

Comments
 (0)