Skip to content

Commit

Permalink
support multiple namespaces (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
balonik committed Jun 1, 2023
1 parent ad1cf5e commit 0f3c2a0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ webhooks:
- name: envars-webhook.${NAMESPACE}.svc
# [...]
namespaceSelector:
matchLabels:
name: samples
matchExpressions:
- key: name
operator: In
values: ["samples"]
```

- In deployment configmap, enable verbose logs to see the JSON body for request and response in server logs.
Expand Down
4 changes: 3 additions & 1 deletion charts/envars-webhook/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apiVersion: v2
name: envars-webhook
description: Generate TLS cert and deploy the webhook
home: "https://github.com/danfromtitan/envars-from-node-labels"
sources: ["https://github.com/danfromtitan/envars-from-node-labels"]
type: application
appVersion: "0.1.0"
version: 0.1.6
version: 0.2.0
11 changes: 8 additions & 3 deletions charts/envars-webhook/templates/mutatingwebhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:
labels:
{{- include "envars-webhook.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": "pre-install"
"helm.sh/hook": "post-install,post-upgrade,pre-delete"
"helm.sh/hook-delete-policy": "before-hook-creation"
webhooks:
- name: {{ include "envars-webhook.name" . }}.{{ .Release.Namespace }}.svc
Expand All @@ -23,8 +23,13 @@ webhooks:
path: "/mutate"
caBundle: {{ $ca.Cert | b64enc }}
namespaceSelector:
matchLabels:
{{ .Values.webhook.namespaceSelectorLabel | default "name" }}: {{ .Values.webhook.namespaceSelector }}
matchExpressions:
- key: {{ .Values.webhook.namespaceSelectorLabel }}
operator: In
values:
{{- with .Values.webhook.namespaceSelector }}
{{- toYaml . | nindent 12 }}
{{- end }}
rules:
- operations: [ "CREATE", "UPDATE", "DELETE" ]
apiGroups: [""]
Expand Down
7 changes: 4 additions & 3 deletions charts/envars-webhook/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ affinity: {}

# Webhook settings
webhook:
# The namespace that the webhook would accept requests from
namespaceSelector: samples
# The namespace(s) that the webhook would accept requests from.
namespaceSelector:
- samples

# The label to use for selecting namespace
# namespaceSelectorLabel: name
namespaceSelectorLabel: name

# Show the JSON body for requests and responses in webhook logs
verboseLogs: false
Expand Down
6 changes: 4 additions & 2 deletions deploy/deployment.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ webhooks:
path: "/mutate"
caBundle: ${CA_PEM_B64}
namespaceSelector:
matchLabels:
name: samples
matchExpressions:
- key: name
operator: In
values: ["samples"]
rules:
- operations: [ "CREATE", "UPDATE", "DELETE" ]
apiGroups: [""]
Expand Down

0 comments on commit 0f3c2a0

Please sign in to comment.