Skip to content

Commit ee0d9af

Browse files
[VC-42222] Fix proxy settings in the Helm chart (#669)
* fix: Only provide one env key in deployment.yaml * chore: Add two tests for env key and fix failing test for helm chart * chore: Add actual values of proxy settings from our documentation into existing test * Run the Helm tests automatically Signed-off-by: Peter Fiddes <[email protected]> Signed-off-by: Richard Wall <[email protected]> Co-authored-by: Richard Wall <[email protected]>
1 parent 076f734 commit ee0d9af

File tree

6 files changed

+72
-24
lines changed

6 files changed

+72
-24
lines changed

.github/workflows/tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232

3333
- run: make -j verify
3434

35-
test-unit:
35+
test:
3636
runs-on: ubuntu-latest
3737
timeout-minutes: 15
3838

@@ -62,4 +62,4 @@ jobs:
6262
path: _bin/downloaded
6363
key: downloaded-${{ runner.os }}-${{ hashFiles('klone.yaml') }}-test-unit
6464

65-
- run: make -j test-unit
65+
- run: make -j test-unit test-helm

deploy/charts/venafi-kubernetes-agent/templates/deployment.yaml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,23 @@ spec:
3232
{{- toYaml .Values.securityContext | nindent 12 }}
3333
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
3434
imagePullPolicy: {{ .Values.image.pullPolicy }}
35-
{{- if or .Values.http_proxy .Values.https_proxy .Values.no_proxy }}
3635
env:
36+
- name: POD_NAMESPACE
37+
valueFrom:
38+
fieldRef:
39+
fieldPath: metadata.namespace
40+
- name: POD_NAME
41+
valueFrom:
42+
fieldRef:
43+
fieldPath: metadata.name
44+
- name: POD_UID
45+
valueFrom:
46+
fieldRef:
47+
fieldPath: metadata.uid
48+
- name: POD_NODE
49+
valueFrom:
50+
fieldRef:
51+
fieldPath: spec.nodeName
3752
{{- with .Values.http_proxy }}
3853
- name: HTTP_PROXY
3954
value: {{ . }}
@@ -46,7 +61,6 @@ spec:
4661
- name: NO_PROXY
4762
value: {{ . }}
4863
{{- end }}
49-
{{- end }}
5064
{{- if not (empty .Values.command) }}
5165
command:
5266
{{- range .Values.command }}
@@ -89,23 +103,6 @@ spec:
89103
{{- with .Values.volumeMounts }}
90104
{{- toYaml . | nindent 12 }}
91105
{{- end }}
92-
env:
93-
- name: POD_NAMESPACE
94-
valueFrom:
95-
fieldRef:
96-
fieldPath: metadata.namespace
97-
- name: POD_NAME
98-
valueFrom:
99-
fieldRef:
100-
fieldPath: metadata.name
101-
- name: POD_UID
102-
valueFrom:
103-
fieldRef:
104-
fieldPath: metadata.uid
105-
- name: POD_NODE
106-
valueFrom:
107-
fieldRef:
108-
fieldPath: spec.nodeName
109106
{{- if .Values.metrics.enabled }}
110107
ports:
111108
- containerPort: 8081

deploy/charts/venafi-kubernetes-agent/tests/deployment_test.yaml

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ tests:
7777

7878
# Check the volumes and volumeMounts works correctly
7979
- it: Volumes and VolumeMounts added correctly
80-
set:
81-
config.organisation: test_org
82-
config.cluster: test_cluster
8380
values:
8481
- ./values/custom-volumes.yaml
8582
asserts:
@@ -102,3 +99,37 @@ tests:
10299
items:
103100
- key: cabundle
104101
path: ca-certificates.crt
102+
103+
# Check proxy settings are additive not overriding and set to correct values.
104+
# Values from our documentation: https://docs.venafi.cloud/vaas/k8s-components/c-vcp-network-requirements/#modifying-network-settings-for-kubernetes
105+
- it: All environment variables present when all proxy settings are supplied
106+
set:
107+
http_proxy: "http://<proxy server>:<port>"
108+
https_proxy: "https://<proxy server>:<port>"
109+
no_proxy: "127.0.0.1,localhost,kubernetes.default.svc,kubernetes.default.svc.cluster.local"
110+
template: deployment.yaml
111+
asserts:
112+
- isKind:
113+
of: Deployment
114+
- lengthEqual :
115+
path: spec.template.spec.containers[0].env
116+
count: 7
117+
- equal:
118+
path: spec.template.spec.containers[0].env[?(@.name == "NO_PROXY")].value
119+
value: "127.0.0.1,localhost,kubernetes.default.svc,kubernetes.default.svc.cluster.local"
120+
- equal:
121+
path: spec.template.spec.containers[0].env[?(@.name == "HTTPS_PROXY")].value
122+
value: "https://<proxy server>:<port>"
123+
- equal:
124+
path: spec.template.spec.containers[0].env[?(@.name == "HTTP_PROXY")].value
125+
value: "http://<proxy server>:<port>"
126+
127+
# Check no proxy settings are set when no proxy settings are provided
128+
- it: Only default environment variables are set when no proxy settings are provided
129+
template: deployment.yaml
130+
asserts:
131+
- isKind:
132+
of: Deployment
133+
- lengthEqual :
134+
path: spec.template.spec.containers[0].env
135+
count: 4

make/00_mod.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,5 @@ endef
5353

5454
golangci_lint_config := .golangci.yaml
5555
go_header_file := /dev/null
56+
57+
include make/extra_tools.mk

make/02_mod.mk

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,15 @@ shared_generate_targets += generate-crds-venconn
5252
## @category Testing
5353
test-e2e-gke:
5454
./hack/e2e/test.sh
55+
56+
.PHONY: test-helm
57+
## Run `helm unittest`.
58+
## @category Testing
59+
test-helm: | $(NEEDS_HELM-UNITTEST)
60+
$(HELM-UNITTEST) ./deploy/charts/venafi-kubernetes-agent/
61+
62+
.PHONY: test-helm-snapshot
63+
## Update the `helm unittest` snapshots.
64+
## @category Testing
65+
test-helm-snapshot: | $(NEEDS_HELM-UNITTEST)
66+
$(HELM-UNITTEST) ./deploy/charts/venafi-kubernetes-agent/ -u

make/extra_tools.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ADDITIONAL_TOOLS :=
2+
ADDITIONAL_GO_DEPENDENCIES :=
3+
4+
# https://pkg.go.dev/github.com/helm-unittest/helm-unittest?tab=versions
5+
ADDITIONAL_TOOLS += helm-unittest=v0.8.2
6+
ADDITIONAL_GO_DEPENDENCIES += helm-unittest=github.com/helm-unittest/helm-unittest/cmd/helm-unittest

0 commit comments

Comments
 (0)