Skip to content

Commit 0f627cd

Browse files
authored
Merge pull request cert-manager#5417 from mjudeikis/master
helm: Add NetworkPolicy support
2 parents 4a1fd0a + 1efea17 commit 0f627cd

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

deploy/charts/cert-manager/README.template.md

+3
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ The following table lists the configurable parameters of the cert-manager chart
146146
| `webhook.serviceAccount.automountServiceAccountToken` | Automount API credentials for the webhook Service Account | |
147147
| `webhook.resources` | CPU/memory resource requests/limits for the webhook pods | `{}` |
148148
| `webhook.nodeSelector` | Node labels for webhook pod assignment | `{}` |
149+
| `webhook.networkPolicy.enabled` | Enable default network policies for webhooks egress and ingress traffic | `false` |
150+
| `webhook.networkPolicy.ingress` | Sets ingress policy block. See NetworkPolicy documentation. See `values.yaml` for example. | `{}` |
151+
| `webhook.networkPolicy.egress` | Sets ingress policy block. See NetworkPolicy documentation. See `values.yaml` for example. | `{}` |
149152
| `webhook.affinity` | Node affinity for webhook pod assignment | `{}` |
150153
| `webhook.tolerations` | Node tolerations for webhook pod assignment | `[]` |
151154
| `webhook.topologySpreadConstraints` | Topology spread constraints for webhook pod assignment | `[]` |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{- if .Values.webhook.networkPolicy.enabled }}
2+
apiVersion: networking.k8s.io/v1
3+
kind: NetworkPolicy
4+
metadata:
5+
name: {{ template "webhook.fullname" . }}-allow-egress
6+
namespace: {{ include "cert-manager.namespace" . }}
7+
spec:
8+
egress:
9+
{{- with .Values.webhook.networkPolicy.egress }}
10+
{{- toYaml . | nindent 2 }}
11+
{{- end }}
12+
podSelector:
13+
matchLabels:
14+
app: {{ include "webhook.name" . }}
15+
app.kubernetes.io/name: {{ include "webhook.name" . }}
16+
app.kubernetes.io/instance: {{ .Release.Name }}
17+
app.kubernetes.io/component: "webhook"
18+
{{- with .Values.webhook.podLabels }}
19+
{{- toYaml . | nindent 6 }}
20+
{{- end }}
21+
policyTypes:
22+
- Egress
23+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{{- if .Values.webhook.networkPolicy.enabled }}
2+
3+
apiVersion: networking.k8s.io/v1
4+
kind: NetworkPolicy
5+
metadata:
6+
name: {{ template "webhook.fullname" . }}-allow-ingress
7+
namespace: {{ include "cert-manager.namespace" . }}
8+
spec:
9+
ingress:
10+
{{- with .Values.webhook.networkPolicy.ingress }}
11+
{{- toYaml . | nindent 2 }}
12+
{{- end }}
13+
podSelector:
14+
matchLabels:
15+
app: {{ include "webhook.name" . }}
16+
app.kubernetes.io/name: {{ include "webhook.name" . }}
17+
app.kubernetes.io/instance: {{ .Release.Name }}
18+
app.kubernetes.io/component: "webhook"
19+
{{- with .Values.webhook.podLabels }}
20+
{{- toYaml . | nindent 6 }}
21+
{{- end }}
22+
policyTypes:
23+
- Ingress
24+
25+
{{- end }}

deploy/charts/cert-manager/values.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,27 @@ webhook:
389389
url: {}
390390
# host:
391391

392+
# Enables default network policies for webhooks.
393+
networkPolicy:
394+
enabled: false
395+
ingress:
396+
- from:
397+
- ipBlock:
398+
cidr: 0.0.0.0/0
399+
egress:
400+
- ports:
401+
- port: 80
402+
protocol: TCP
403+
- port: 443
404+
protocol: TCP
405+
- port: 53
406+
protocol: TCP
407+
- port: 53
408+
protocol: UDP
409+
to:
410+
- ipBlock:
411+
cidr: 0.0.0.0/0
412+
392413
cainjector:
393414
enabled: true
394415
replicaCount: 1

0 commit comments

Comments
 (0)