Skip to content
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:

- run: make -j verify

test-unit:
test:
runs-on: ubuntu-latest
timeout-minutes: 15

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

- run: make -j test-unit
- run: make -j test-unit test-helm
35 changes: 16 additions & 19 deletions deploy/charts/venafi-kubernetes-agent/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,23 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if or .Values.http_proxy .Values.https_proxy .Values.no_proxy }}
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_UID
valueFrom:
fieldRef:
fieldPath: metadata.uid
- name: POD_NODE
valueFrom:
fieldRef:
fieldPath: spec.nodeName
{{- with .Values.http_proxy }}
- name: HTTP_PROXY
value: {{ . }}
Expand All @@ -46,7 +61,6 @@ spec:
- name: NO_PROXY
value: {{ . }}
{{- end }}
{{- end }}
{{- if not (empty .Values.command) }}
command:
{{- range .Values.command }}
Expand Down Expand Up @@ -89,23 +103,6 @@ spec:
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_UID
valueFrom:
fieldRef:
fieldPath: metadata.uid
- name: POD_NODE
valueFrom:
fieldRef:
fieldPath: spec.nodeName
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies. I introduced this bug, in 5679dc5

{{- if .Values.metrics.enabled }}
ports:
- containerPort: 8081
Expand Down
37 changes: 34 additions & 3 deletions deploy/charts/venafi-kubernetes-agent/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ tests:

# Check the volumes and volumeMounts works correctly
- it: Volumes and VolumeMounts added correctly
set:
config.organisation: test_org
config.cluster: test_cluster
values:
- ./values/custom-volumes.yaml
asserts:
Expand All @@ -102,3 +99,37 @@ tests:
items:
- key: cabundle
path: ca-certificates.crt

# Check proxy settings are additive not overriding and set to correct values.
# Values from our documentation: https://docs.venafi.cloud/vaas/k8s-components/c-vcp-network-requirements/#modifying-network-settings-for-kubernetes
- it: All environment variables present when all proxy settings are supplied
set:
http_proxy: "http://<proxy server>:<port>"
https_proxy: "https://<proxy server>:<port>"
no_proxy: "127.0.0.1,localhost,kubernetes.default.svc,kubernetes.default.svc.cluster.local"
template: deployment.yaml
asserts:
- isKind:
of: Deployment
- lengthEqual :
path: spec.template.spec.containers[0].env
count: 7
- equal:
path: spec.template.spec.containers[0].env[?(@.name == "NO_PROXY")].value
value: "127.0.0.1,localhost,kubernetes.default.svc,kubernetes.default.svc.cluster.local"
- equal:
path: spec.template.spec.containers[0].env[?(@.name == "HTTPS_PROXY")].value
value: "https://<proxy server>:<port>"
- equal:
path: spec.template.spec.containers[0].env[?(@.name == "HTTP_PROXY")].value
value: "http://<proxy server>:<port>"

# Check no proxy settings are set when no proxy settings are provided
- it: Only default environment variables are set when no proxy settings are provided
template: deployment.yaml
asserts:
- isKind:
of: Deployment
- lengthEqual :
path: spec.template.spec.containers[0].env
count: 4
2 changes: 2 additions & 0 deletions make/00_mod.mk
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ endef

golangci_lint_config := .golangci.yaml
go_header_file := /dev/null

include make/extra_tools.mk
12 changes: 12 additions & 0 deletions make/02_mod.mk
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,15 @@ shared_generate_targets += generate-crds-venconn
## @category Testing
test-e2e-gke:
./hack/e2e/test.sh

.PHONY: test-helm
## Run `helm unittest`.
## @category Testing
test-helm: | $(NEEDS_HELM-UNITTEST)
$(HELM-UNITTEST) ./deploy/charts/venafi-kubernetes-agent/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not including the jetstack-secure chart here because it is soon to be removed: #672


.PHONY: test-helm-snapshot
## Update the `helm unittest` snapshots.
## @category Testing
test-helm-snapshot: | $(NEEDS_HELM-UNITTEST)
$(HELM-UNITTEST) ./deploy/charts/venafi-kubernetes-agent/ -u
6 changes: 6 additions & 0 deletions make/extra_tools.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ADDITIONAL_TOOLS :=
ADDITIONAL_GO_DEPENDENCIES :=

# https://pkg.go.dev/github.com/helm-unittest/helm-unittest?tab=versions
ADDITIONAL_TOOLS += helm-unittest=v0.8.2
ADDITIONAL_GO_DEPENDENCIES += helm-unittest=github.com/helm-unittest/helm-unittest/cmd/helm-unittest