diff --git a/charts/core/templates/controller-deployment.yaml b/charts/core/templates/controller-deployment.yaml index c0a16ac2..b6a4b55a 100644 --- a/charts/core/templates/controller-deployment.yaml +++ b/charts/core/templates/controller-deployment.yaml @@ -49,7 +49,11 @@ spec: serviceAccount: {{ .Values.serviceAccount }} containers: - name: neuvector-controller-pod + {{ if eq .Values.registry "registry.neuvector.com" }} + image: "{{ .Values.registry }}/controller:{{ .Values.tag }}" + {{- else }} image: "{{ .Values.registry }}/{{ .Values.controller.image.repository }}:{{ .Values.tag }}" + {{- end }} securityContext: privileged: true resources: diff --git a/charts/core/templates/enforcer-daemonset.yaml b/charts/core/templates/enforcer-daemonset.yaml index 1defccc8..4651156a 100644 --- a/charts/core/templates/enforcer-daemonset.yaml +++ b/charts/core/templates/enforcer-daemonset.yaml @@ -40,7 +40,11 @@ spec: serviceAccount: {{ .Values.serviceAccount }} containers: - name: neuvector-enforcer-pod + {{ if eq .Values.registry "registry.neuvector.com" }} + image: "{{ .Values.registry }}/enforcer:{{ .Values.tag }}" + {{- else }} image: "{{ .Values.registry }}/{{ .Values.enforcer.image.repository }}:{{ .Values.tag }}" + {{- end }} securityContext: privileged: true resources: diff --git a/charts/core/templates/manager-deployment.yaml b/charts/core/templates/manager-deployment.yaml index 32f8ec60..02fe79cd 100644 --- a/charts/core/templates/manager-deployment.yaml +++ b/charts/core/templates/manager-deployment.yaml @@ -34,7 +34,11 @@ spec: serviceAccount: {{ .Values.serviceAccount }} containers: - name: neuvector-manager-pod + {{ if eq .Values.registry "registry.neuvector.com" }} + image: "{{ .Values.registry }}/manager:{{ .Values.tag }}" + {{- else }} image: "{{ .Values.registry }}/{{ .Values.manager.image.repository }}:{{ .Values.tag }}" + {{- end }} env: - name: CTRL_SERVER_IP value: neuvector-svc-controller.{{ .Release.Namespace }} diff --git a/charts/core/templates/scanner-deployment.yaml b/charts/core/templates/scanner-deployment.yaml index fb18ab45..22d18f7a 100644 --- a/charts/core/templates/scanner-deployment.yaml +++ b/charts/core/templates/scanner-deployment.yaml @@ -35,7 +35,11 @@ spec: serviceAccount: {{ .Values.serviceAccount }} containers: - name: neuvector-scanner-pod + {{ if eq .Values.registry "registry.neuvector.com" }} + image: "{{ .Values.registry }}/scanner:{{ .Values.tag }}" + {{- else }} image: "{{ .Values.registry }}/{{ .Values.cve.scanner.image.repository }}:{{ .Values.cve.scanner.image.tag }}" + {{- end }} imagePullPolicy: Always env: - name: CLUSTER_JOIN_ADDR diff --git a/charts/core/templates/updater-cronjob.yaml b/charts/core/templates/updater-cronjob.yaml index 9c337096..1953a52e 100644 --- a/charts/core/templates/updater-cronjob.yaml +++ b/charts/core/templates/updater-cronjob.yaml @@ -33,7 +33,11 @@ spec: serviceAccount: {{ .Values.serviceAccount }} containers: - name: neuvector-updater-pod + {{ if eq .Values.registry "registry.neuvector.com" }} + image: "{{ .Values.registry }}/updater:{{ .Values.tag }}" + {{- else }} image: "{{ .Values.registry }}/{{ .Values.cve.updater.image.repository }}:{{ .Values.cve.updater.image.tag }}" + {{- end }} imagePullPolicy: Always {{- if .Values.cve.scanner.enabled }} lifecycle: diff --git a/test/deployment_test.go b/test/deployment_test.go index 6cefff5b..79835188 100644 --- a/test/deployment_test.go +++ b/test/deployment_test.go @@ -23,6 +23,30 @@ func TestControllerDeployment(t *testing.T) { } } +func TestControllerDeploymentRegistry(t *testing.T) { + helmChartPath := "../charts/core" + + options := &helm.Options{ + SetValues: map[string]string{ + "registry": "registry.neuvector.com", + }, + } + + // Test ingress + out := helm.RenderTemplate(t, options, helmChartPath, []string{"templates/controller-deployment.yaml"}) + outs := splitYaml(out) + + if len(outs) != 1 { + t.Errorf("Resource count is wrong. count=%v\n", len(outs)) + } + + var dep appsv1.Deployment + helm.UnmarshalK8SYaml(t, outs[0], &dep) + if dep.Spec.Template.Spec.Containers[0].Image != "registry.neuvector.com/controller:latest" { + t.Errorf("Image location is wrong, %v\n", dep.Spec.Template.Spec.Containers[0].Image) + } +} + func TestControllerDeploymentCert(t *testing.T) { helmChartPath := "../charts/core"