Skip to content

Commit 53c5037

Browse files
authored
feat: add support NetworkPolicy (#91)
1 parent 94f5601 commit 53c5037

File tree

4 files changed

+72
-1
lines changed

4 files changed

+72
-1
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,17 @@ helm upgrade aks-node-termination-handler \
332332
aks-node-termination-handler/aks-node-termination-handler \
333333
--set priorityClassName=system-node-critical \
334334
--set hostNetwork=true
335+
```
336+
337+
## NetworkPolicy support
338+
339+
To limit what the workload can communicate with, Networkpolicy can be added via `--set networkPolicy.enabled=true`. To only allow egress communication towards required endpoints, supply the control plane IP address via `--set networkPolicy.controlPlaneIP=10.11.12.13`. Additional egress rules can be added via `--set networkPolicy.additionalEgressRules=[]`, see the chart-provided `values.yaml` file for examples.
340+
341+
```bash
342+
helm upgrade aks-node-termination-handler \
343+
--install \
344+
--namespace kube-system \
345+
aks-node-termination-handler/aks-node-termination-handler \
346+
--set networkPolicy.enabled=true \
347+
--set networkPolicy.controlPlaneIP=10.11.12.2
335348
```

charts/aks-node-termination-handler/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v2
22
icon: https://helm.sh/img/helm.svg
33
name: aks-node-termination-handler
4-
version: 1.1.6
4+
version: 1.1.7
55
description: Gracefully handle Azure Virtual Machines shutdown within Kubernetes
66
maintainers:
77
- name: maksim-paskal # Maksim Paskal
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{{ if .Values.networkPolicy.enabled }}
2+
apiVersion: networking.k8s.io/v1
3+
kind: NetworkPolicy
4+
metadata:
5+
name: {{ .Release.Name }}
6+
spec:
7+
egress:
8+
- ports:
9+
- port: 80
10+
protocol: TCP
11+
to:
12+
- ipBlock:
13+
cidr: 169.254.169.254/32
14+
- ports:
15+
- port: 443
16+
protocol: TCP
17+
{{- if .Values.networkPolicy.controlPlaneIP }}
18+
to:
19+
- ipBlock:
20+
cidr: {{ .Values.networkPolicy.controlPlaneIP }}/32
21+
{{- end }}
22+
{{- if .Values.networkPolicy.additionalEgressRules }}
23+
{{ toYaml .Values.networkPolicy.additionalEgressRules | indent 2 }}
24+
{{- end }}
25+
- ports:
26+
- port: 53
27+
protocol: UDP
28+
- port: 53
29+
protocol: TCP
30+
to:
31+
- namespaceSelector: {}
32+
podSelector:
33+
matchLabels:
34+
k8s-app: kube-dns
35+
ingress:
36+
- from:
37+
- namespaceSelector: {}
38+
ports:
39+
- port: 17923
40+
protocol: TCP
41+
podSelector:
42+
matchLabels:
43+
app: {{ .Release.Name }}
44+
policyTypes:
45+
- Ingress
46+
- Egress
47+
{{ end }}

charts/aks-node-termination-handler/values.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ configMap:
2727
extraVolumes: []
2828
extraVolumeMounts: []
2929

30+
networkPolicy:
31+
enabled: false
32+
# controlPlaneIP: "123.X.X.X" # If not provided, network policy will allow all access to port 443/tcp
33+
# additionalEgressRules:
34+
# - ports:
35+
# - port: 443
36+
# protocol: TCP
37+
# to:
38+
# - ipBlock:
39+
# cidr: 124.X.X.X/24
40+
3041
metrics:
3142
addAnnotations: true
3243

0 commit comments

Comments
 (0)