Skip to content

Commit fc39b52

Browse files
committed
feat(shield): use alt region in host-shield windows only when version higher than 0.7.1
1 parent b48da33 commit fc39b52

6 files changed

+83
-9
lines changed

charts/shield/templates/cluster/_config.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"ca_cert_file" (printf "%s%s" (include "cluster.tls_certificates.mount_path" .) (include "cluster.tls_certificates.ca_cert_file_name" .))
5959
) -}}
6060
{{- if (include "cluster.audit_enabled" .) -}}
61-
{{- if regexMatch "^v?([0-9]+)(\\.[0-9]+)?(\\.[0-9]+)?(-([0-9A-Za-z\\-]+(\\.[0-9A-Za-z\\-]+)*))?(\\+([0-9A-Za-z\\-]+(\\.[0-9A-Za-z\\-]+)*))?$" (.Values.on_prem_version | default "") -}}
61+
{{- if (include "common.semver.is_valid" (.Values.on_prem_version | default "")) -}}
6262
{{- if semverCompare "< 6.12.0" .Values.on_prem_version -}}
6363
{{- if not (include "common.credentials.has_secure_api_token" . ) -}}
6464
{{- fail "Secure API Token is required for kubernetes audit with On Premise Versions < 6.12.0" -}}
@@ -81,7 +81,7 @@
8181
{{- $_ := set $clusterScannerConfig "leader_election_lock_name" (include "cluster.container_vulnerability_management_lease_name" .) -}}
8282
{{- $_ := set $config "cluster_scanner" $clusterScannerConfig -}}
8383

84-
{{- if regexMatch "^v?([0-9]+)(\\.[0-9]+)?(\\.[0-9]+)?(-([0-9A-Za-z\\-]+(\\.[0-9A-Za-z\\-]+)*))?(\\+([0-9A-Za-z\\-]+(\\.[0-9A-Za-z\\-]+)*))?$" (.Values.on_prem_version | default "") -}}
84+
{{- if (include "common.semver.is_valid" (.Values.on_prem_version | default "")) -}}
8585
{{- if semverCompare "< 6.12.0" .Values.on_prem_version -}}
8686
{{- $_ := set $config.features.container_vulnerability_management "platform_services_enabled" false -}}
8787
{{- end -}}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{- define "common.semver.is_valid" -}}
2+
{{- if regexMatch "^v?([0-9]+)(\\.[0-9]+)?(\\.[0-9]+)?(-([0-9A-Za-z\\-]+(\\.[0-9A-Za-z\\-]+)*))?(\\+([0-9A-Za-z\\-]+(\\.[0-9A-Za-z\\-]+)*))?$" . -}}
3+
{{- true -}}
4+
{{- end -}}
5+
{{- end -}}

charts/shield/templates/host/_windows_configmap_helpers.tpl

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@
4242
{{- end -}}
4343
{{- end -}}
4444
{{- if (include "common.is_alt_region" .) -}}
45-
{{- $_ := set $sysdigEndpointConfig "region" "custom" -}}
46-
{{- $_ := set $sysdigEndpointConfig "api_url" (printf "https://%s" (include "common.secure_api_endpoint" .)) -}}
47-
{{- $_ := set $sysdigEndpointConfig.collector "host" (include "common.collector_endpoint" .) -}}
48-
{{- $_ := set $sysdigEndpointConfig.collector "port" 6443 -}}
45+
{{- if not (include "host.windows.supports_alt_regions" .) -}}
46+
{{- $_ := set $sysdigEndpointConfig "region" "custom" -}}
47+
{{- $_ := set $sysdigEndpointConfig "api_url" (printf "https://%s" (include "common.secure_api_endpoint" .)) -}}
48+
{{- $_ := set $sysdigEndpointConfig.collector "host" (include "common.collector_endpoint" .) -}}
49+
{{- $_ := set $sysdigEndpointConfig.collector "port" 6443 -}}
50+
{{- end -}}
4951
{{- end -}}
5052
{{- $_ := set $config "sysdig_endpoint" $sysdigEndpointConfig -}}
5153
@@ -70,6 +72,16 @@
7072
{{- $finalConfig | toYaml }}
7173
{{- end }}
7274
75+
{{- define "host.windows.supports_alt_regions" -}}
76+
{{- if (include "common.semver.is_valid" (.Values.host_windows.image.tag | default "")) -}}
77+
{{- if semverCompare "> 0.7.1" .Values.host_windows.image.tag -}}
78+
{{- true -}}
79+
{{- end -}}
80+
{{- else -}}
81+
{{- true -}}
82+
{{- end -}}
83+
{{- end -}}
84+
7385
{{/* Generate the 'dragent.yaml' content */}}
7486
{{- define "host.windows.configmap" }}
7587
{{- $config := dict

charts/shield/tests/host/configmap-dragent-yaml_test.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,6 @@ tests:
11471147
- notExists:
11481148
path: data["prometheus.yaml"]
11491149

1150-
11511150
- it: Alternative regions
11521151
set:
11531152
sysdig_endpoint:

charts/shield/tests/host/configmap-windows-dragent-yaml_test.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,6 @@ tests:
708708
log:
709709
console_priority: debug
710710
711-
712711
- it: Alternative regions
713712
set:
714713
sysdig_endpoint:

charts/shield/tests/host/configmap-windows-host-shield-config_test.yaml

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ tests:
331331
proxy:
332332
no_proxy: example.com
333333
334-
- it: Alternative regions
334+
- it: Alternative regions (default)
335335
set:
336336
sysdig_endpoint:
337337
region: "eu1-alt"
@@ -356,3 +356,62 @@ tests:
356356
host: ingest-alt-eu1.app.sysdig.com
357357
port: 6443
358358
region: custom
359+
360+
- it: Alternative regions (host-shield windows version <= 0.7.1)
361+
set:
362+
sysdig_endpoint:
363+
region: "eu1-alt"
364+
host_windows:
365+
image:
366+
tag: "0.7.1"
367+
asserts:
368+
- hasDocuments:
369+
count: 1
370+
- containsDocument:
371+
kind: ConfigMap
372+
apiVersion: v1
373+
name: release-name-shield-host-windows
374+
- equal:
375+
path: metadata.namespace
376+
value: shield-namespace
377+
- exists:
378+
path: data["host-shield.yaml"]
379+
- matchRegex:
380+
path: data["host-shield.yaml"]
381+
pattern: |
382+
sysdig_endpoint:
383+
api_url: https://eu1.app.sysdig.com
384+
collector:
385+
host: ingest-alt-eu1.app.sysdig.com
386+
port: 6443
387+
region: custom
388+
389+
- it: Alternative regions (host-shield windows version > 0.7.1)
390+
set:
391+
sysdig_endpoint:
392+
region: "eu1-alt"
393+
api_url:
394+
collector:
395+
host:
396+
port:
397+
host_windows:
398+
image:
399+
tag: "0.7.2"
400+
asserts:
401+
- hasDocuments:
402+
count: 1
403+
- containsDocument:
404+
kind: ConfigMap
405+
apiVersion: v1
406+
name: release-name-shield-host-windows
407+
- equal:
408+
path: metadata.namespace
409+
value: shield-namespace
410+
- exists:
411+
path: data["host-shield.yaml"]
412+
- matchRegex:
413+
path: data["host-shield.yaml"]
414+
pattern: |
415+
sysdig_endpoint:
416+
collector: {}
417+
region: eu1-alt

0 commit comments

Comments
 (0)