Skip to content

Commit 83af9d3

Browse files
authored
feat(shield): Add support for hostAliases (#2370)
1 parent a7d5381 commit 83af9d3

File tree

10 files changed

+226
-1
lines changed

10 files changed

+226
-1
lines changed

charts/shield/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ maintainers:
1313
- name: mavimo
1414
1515
type: application
16-
version: 1.18.1
16+
version: 1.19.0
1717
appVersion: "1.0.0"

charts/shield/README.md

Lines changed: 3 additions & 0 deletions
Large diffs are not rendered by default.

charts/shield/templates/cluster/deployment.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ spec:
6464
{{- else if .Values.cluster.dns_policy }}
6565
dnsPolicy: {{ .Values.cluster.dns_policy }}
6666
{{- end }}
67+
{{- if .Values.cluster.host_aliases }}
68+
hostAliases:
69+
{{ toYaml .Values.cluster.host_aliases | nindent 8 }}
70+
{{- end }}
6771
containers:
6872
- name: "cluster-shield"
6973
imagePullPolicy: {{ .Values.cluster.image.pull_policy }}

charts/shield/templates/host/daemonset-windows.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ spec:
2727
hostProcess: true
2828
runAsUserName: "NT AUTHORITY\\SYSTEM"
2929
hostNetwork: true
30+
{{- if .Values.host_windows.host_aliases }}
31+
hostAliases:
32+
{{ toYaml .Values.host_windows.host_aliases | nindent 8 }}
33+
{{- end }}
3034
serviceAccountName: {{ include "host.service_account_name" . }}
3135
{{- if (include "host.has_priority_class" .) }}
3236
priorityClassName: "{{ include "host.priority_class_name" . }}"

charts/shield/templates/host/daemonset.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ spec:
2424
hostNetwork: true
2525
dnsPolicy: {{ default "ClusterFirstWithHostNet" .Values.host.dns_policy }}
2626
hostPID: true
27+
{{- if .Values.host.host_aliases }}
28+
hostAliases:
29+
{{ toYaml .Values.host.host_aliases | nindent 8 }}
30+
{{- end }}
2731
serviceAccountName: {{ include "host.service_account_name" . }}
2832
{{- if (include "host.has_priority_class" .) }}
2933
priorityClassName: "{{ include "host.priority_class_name" . }}"

charts/shield/tests/cluster/deployment_test.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,3 +1438,59 @@ tests:
14381438
name: my-cluster-volume
14391439
mountPath: /host/my-cluster-mount-path
14401440
template: templates/cluster/deployment.yaml
1441+
1442+
- it: Host Alias are not included by default
1443+
asserts:
1444+
- notContains:
1445+
path: spec.template.spec.hostAliases
1446+
template: templates/cluster/deployment.yaml
1447+
1448+
- it: Single Host Alias is included if configured
1449+
set:
1450+
cluster:
1451+
host_aliases:
1452+
- ip: 1.2.3.4
1453+
hostnames:
1454+
- acme.public
1455+
- acme.internal
1456+
asserts:
1457+
- equal:
1458+
path: spec.template.spec.hostAliases[0].ip
1459+
value: 1.2.3.4
1460+
- equal:
1461+
path: spec.template.spec.hostAliases[0].hostnames
1462+
value:
1463+
- acme.public
1464+
- acme.internal
1465+
template: templates/cluster/deployment.yaml
1466+
1467+
- it: Multiple Host Alias are included if configured
1468+
set:
1469+
cluster:
1470+
host_aliases:
1471+
- ip: 1.2.3.4
1472+
hostnames:
1473+
- acme.public
1474+
- acme.internal
1475+
- ip: 4.3.2.1
1476+
hostnames:
1477+
- company.public
1478+
- company.internal
1479+
asserts:
1480+
- equal:
1481+
path: spec.template.spec.hostAliases[0].ip
1482+
value: 1.2.3.4
1483+
- equal:
1484+
path: spec.template.spec.hostAliases[0].hostnames
1485+
value:
1486+
- acme.public
1487+
- acme.internal
1488+
- equal:
1489+
path: spec.template.spec.hostAliases[1].ip
1490+
value: 4.3.2.1
1491+
- equal:
1492+
path: spec.template.spec.hostAliases[1].hostnames
1493+
value:
1494+
- company.public
1495+
- company.internal
1496+
template: templates/cluster/deployment.yaml

charts/shield/tests/host/daemonset-windows_test.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,3 +463,57 @@ tests:
463463
- equal:
464464
path: metadata.labels["sysdig/component-version"]
465465
value: sha256_61fdf83f6ec198919d595ea1e6dc093258dfcdc3d75db81fe060b65c
466+
467+
468+
- it: Host Alias are not included by default
469+
asserts:
470+
- notContains:
471+
path: spec.template.spec.hostAliases
472+
473+
- it: Single Host Alias is included if configured
474+
set:
475+
host_windows:
476+
host_aliases:
477+
- ip: 1.2.3.4
478+
hostnames:
479+
- acme.public
480+
- acme.internal
481+
asserts:
482+
- equal:
483+
path: spec.template.spec.hostAliases[0].ip
484+
value: 1.2.3.4
485+
- equal:
486+
path: spec.template.spec.hostAliases[0].hostnames
487+
value:
488+
- acme.public
489+
- acme.internal
490+
491+
- it: Multiple Host Alias are included if configured
492+
set:
493+
host_windows:
494+
host_aliases:
495+
- ip: 1.2.3.4
496+
hostnames:
497+
- acme.public
498+
- acme.internal
499+
- ip: 4.3.2.1
500+
hostnames:
501+
- company.public
502+
- company.internal
503+
asserts:
504+
- equal:
505+
path: spec.template.spec.hostAliases[0].ip
506+
value: 1.2.3.4
507+
- equal:
508+
path: spec.template.spec.hostAliases[0].hostnames
509+
value:
510+
- acme.public
511+
- acme.internal
512+
- equal:
513+
path: spec.template.spec.hostAliases[1].ip
514+
value: 4.3.2.1
515+
- equal:
516+
path: spec.template.spec.hostAliases[1].hostnames
517+
value:
518+
- company.public
519+
- company.internal

charts/shield/tests/host/daemonset_test.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,3 +794,56 @@ tests:
794794
- equal:
795795
path: spec.template.spec.dnsPolicy
796796
value: ClusterFirst
797+
798+
- it: Host Alias are not included by default
799+
asserts:
800+
- notContains:
801+
path: spec.template.spec.hostAliases
802+
803+
- it: Single Host Alias is included if configured
804+
set:
805+
host:
806+
host_aliases:
807+
- ip: 1.2.3.4
808+
hostnames:
809+
- acme.public
810+
- acme.internal
811+
asserts:
812+
- equal:
813+
path: spec.template.spec.hostAliases[0].ip
814+
value: 1.2.3.4
815+
- equal:
816+
path: spec.template.spec.hostAliases[0].hostnames
817+
value:
818+
- acme.public
819+
- acme.internal
820+
821+
- it: Multiple Host Alias are included if configured
822+
set:
823+
host:
824+
host_aliases:
825+
- ip: 1.2.3.4
826+
hostnames:
827+
- acme.public
828+
- acme.internal
829+
- ip: 4.3.2.1
830+
hostnames:
831+
- company.public
832+
- company.internal
833+
asserts:
834+
- equal:
835+
path: spec.template.spec.hostAliases[0].ip
836+
value: 1.2.3.4
837+
- equal:
838+
path: spec.template.spec.hostAliases[0].hostnames
839+
value:
840+
- acme.public
841+
- acme.internal
842+
- equal:
843+
path: spec.template.spec.hostAliases[1].ip
844+
value: 4.3.2.1
845+
- equal:
846+
path: spec.template.spec.hostAliases[1].hostnames
847+
value:
848+
- company.public
849+
- company.internal

charts/shield/values.schema.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,9 @@
335335
"env": {
336336
"$ref": "#/$defs/EnvVars"
337337
},
338+
"host_aliases": {
339+
"$ref": "#/$defs/HostAliases"
340+
},
338341
"pod_disruption_budget": {
339342
"type": "object",
340343
"description": "Pod disruption budget configuration for the Cluster Shield pods",
@@ -401,6 +404,9 @@
401404
"env": {
402405
"$ref": "#/$defs/EnvVars"
403406
},
407+
"host_aliases": {
408+
"$ref": "#/$defs/HostAliases"
409+
},
404410
"volumes": {
405411
"$ref": "#/$defs/Volumes"
406412
},
@@ -419,6 +425,9 @@
419425
"env": {
420426
"$ref": "#/$defs/EnvVars"
421427
},
428+
"host_aliases": {
429+
"$ref": "#/$defs/HostAliases"
430+
},
422431
"volumes": {
423432
"$ref": "#/$defs/Volumes"
424433
},
@@ -1215,6 +1224,38 @@
12151224
}
12161225
},
12171226
"additionalProperties": false
1227+
},
1228+
"HostAliases": {
1229+
"type": "array",
1230+
"items": {
1231+
"type": "object",
1232+
"description": "Define host aliases for the pod",
1233+
"properties": {
1234+
"ip": {
1235+
"type": "string",
1236+
"description": "The IP address to alias"
1237+
},
1238+
"hostnames": {
1239+
"type": "array",
1240+
"items": {
1241+
"type": "string"
1242+
},
1243+
"description": "The list of hostname to be assicated to the IP addresses"
1244+
}
1245+
},
1246+
"required": [
1247+
"ip",
1248+
"hostnames"
1249+
]
1250+
},
1251+
"examples": [
1252+
[
1253+
{
1254+
"ip": "1.2.3.4",
1255+
"hostnames": ["acme.internal", "acme.alias"]
1256+
}
1257+
]
1258+
]
12181259
}
12191260
}
12201261
}

charts/shield/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ host_windows:
196196
cpu: 250m
197197
# The memory request for the host shield
198198
memory: 384Mi
199+
# The host aliases for the windows host shield workloads
200+
host_aliases: []
199201
# The annotations for the host shield workloads (metadata.annotations)
200202
workload_annotations: {}
201203
# The labels for the host shield workloads (metadata.labels)
@@ -304,6 +306,8 @@ host:
304306
cpu: 250m
305307
# The memory request for the host shield
306308
memory: 384Mi
309+
# The host aliases for the linux host shield workloads
310+
host_aliases: []
307311
# The annotations for the host shield workloads (metadata.annotations)
308312
workload_annotations: {}
309313
# The labels for the host shield workloads (metadata.labels)
@@ -438,6 +442,8 @@ cluster:
438442
cpu: 1500m
439443
# The memory limit for the cluster shield
440444
memory: 1536Mi
445+
# The host aliases for the cluster shield workloads
446+
host_aliases: []
441447
# The annotations for the cluster shield workloads (metadata.annotations)
442448
workload_annotations: {}
443449
# The labels for the cluster shield workloads (metadata.labels)

0 commit comments

Comments
 (0)