AETHER-761 Add support of private image registry with auth enabled

Change-Id: I25e804570357c513bfd1822ab9d971c7ed1c5405
diff --git a/omec/omec-control-plane/Chart.yaml b/omec/omec-control-plane/Chart.yaml
index f678e2f..37548ae 100644
--- a/omec/omec-control-plane/Chart.yaml
+++ b/omec/omec-control-plane/Chart.yaml
@@ -10,4 +10,4 @@
 name: omec-control-plane
 icon: https://guide.opencord.org/logos/cord.svg
 
-version: 0.5.0
+version: 0.5.1
diff --git a/omec/omec-control-plane/templates/secret-registry.yaml b/omec/omec-control-plane/templates/secret-registry.yaml
new file mode 100644
index 0000000..1502049
--- /dev/null
+++ b/omec/omec-control-plane/templates/secret-registry.yaml
@@ -0,0 +1,18 @@
+{{/*
+# Copyright 2020-present Open Networking Foundation
+
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+
+{{- if .Values.images.credentials }}
+---
+kind: Secret
+apiVersion: v1
+metadata:
+  name: {{ .Release.Name }}.registry
+  labels:
+    release: {{ .Release.Name }}
+type: kubernetes.io/dockerconfigjson
+data:
+  .dockerconfigjson: {{ printf `{"auths":{%s:{"auth":"%s"}}}` (.Values.images.credentials.registry | quote) (printf "%s:%s" .Values.images.credentials.username .Values.images.credentials.password | b64enc) | b64enc | quote }}
+{{- end }}
diff --git a/omec/omec-control-plane/templates/statefulset-hss.yaml b/omec/omec-control-plane/templates/statefulset-hss.yaml
index cedd809..7c4c4a6 100644
--- a/omec/omec-control-plane/templates/statefulset-hss.yaml
+++ b/omec/omec-control-plane/templates/statefulset-hss.yaml
@@ -37,6 +37,10 @@
         {{ .Values.nodeSelectors.hss.label }}: {{ .Values.nodeSelectors.hss.value }}
     {{- end }}
       serviceAccountName: hss
+    {{- if .Values.images.credentials }}
+      imagePullSecrets:
+        - name: {{ .Release.Name }}.registry
+    {{- end }}
       initContainers:
       - name: hss-bootstrap
         image: {{ .Values.images.tags.hssdb }}
diff --git a/omec/omec-control-plane/templates/statefulset-mme.yaml b/omec/omec-control-plane/templates/statefulset-mme.yaml
index 8dd2ea3..c0c180c 100644
--- a/omec/omec-control-plane/templates/statefulset-mme.yaml
+++ b/omec/omec-control-plane/templates/statefulset-mme.yaml
@@ -33,6 +33,10 @@
         {{ .Values.nodeSelectors.mme.label }}: {{ .Values.nodeSelectors.mme.value }}
     {{- end }}
       serviceAccountName: mme
+    {{- if .Values.images.credentials }}
+      imagePullSecrets:
+        - name: {{ .Release.Name }}.registry
+    {{- end }}
       initContainers:
       - name: mme-load-sctp-module
         image: {{ .Values.images.tags.init | quote }}
diff --git a/omec/omec-control-plane/templates/statefulset-spgwc.yaml b/omec/omec-control-plane/templates/statefulset-spgwc.yaml
index 6269c3f..91fe84f 100644
--- a/omec/omec-control-plane/templates/statefulset-spgwc.yaml
+++ b/omec/omec-control-plane/templates/statefulset-spgwc.yaml
@@ -33,6 +33,10 @@
         {{ .Values.nodeSelectors.spgwc.label }}: {{ .Values.nodeSelectors.spgwc.value }}
     {{- end }}
       serviceAccountName: spgwc
+    {{- if .Values.images.credentials }}
+      imagePullSecrets:
+        - name: {{ .Release.Name }}.registry
+    {{- end }}
     {{- if .Values.config.coreDump.enabled }}
       initContainers:
 {{ tuple "spgwc" . | include "omec-control-plane.coredump_init" | indent 6 }}
diff --git a/omec/omec-control-plane/values.yaml b/omec/omec-control-plane/values.yaml
index c8ef894..13b0a33 100644
--- a/omec/omec-control-plane/values.yaml
+++ b/omec/omec-control-plane/values.yaml
@@ -13,6 +13,11 @@
     spgwc: docker.io/omecproject/spgw:master-latest
     depCheck: quay.io/stackanetes/kubernetes-entrypoint:v0.3.1
   pullPolicy: IfNotPresent
+  credentials: {}
+  # If specified, use this credential to access the image
+  #   registry:
+  #   username:
+  #   password:
 
 nodeSelectors:
   enabled: false
diff --git a/omec/omec-upf-cni/Chart.yaml b/omec/omec-upf-cni/Chart.yaml
index 1048b63..ae32d3b 100644
--- a/omec/omec-upf-cni/Chart.yaml
+++ b/omec/omec-upf-cni/Chart.yaml
@@ -9,4 +9,4 @@
 name: omec-upf-cni
 icon: https://guide.opencord.org/logos/cord.svg
 
-version: 0.1.0
+version: 0.1.1
diff --git a/omec/omec-upf-cni/templates/daemonset-sriov-plugin.yaml b/omec/omec-upf-cni/templates/daemonset-sriov-plugin.yaml
index b9bb1cb..0624fb2 100644
--- a/omec/omec-upf-cni/templates/daemonset-sriov-plugin.yaml
+++ b/omec/omec-upf-cni/templates/daemonset-sriov-plugin.yaml
@@ -26,6 +26,10 @@
       hostPID: true
       nodeSelector:
         beta.kubernetes.io/arch: amd64
+    {{- if .Values.images.credentials }}
+      imagePullSecrets:
+        - name: {{ .Release.Name }}.registry
+    {{- end }}
       initContainers:
       - name: init-sriov-plugin
         image: {{ .Values.images.tags.omecCni }}
diff --git a/omec/omec-upf-cni/templates/secret-registry.yaml b/omec/omec-upf-cni/templates/secret-registry.yaml
new file mode 100644
index 0000000..1502049
--- /dev/null
+++ b/omec/omec-upf-cni/templates/secret-registry.yaml
@@ -0,0 +1,18 @@
+{{/*
+# Copyright 2020-present Open Networking Foundation
+
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+
+{{- if .Values.images.credentials }}
+---
+kind: Secret
+apiVersion: v1
+metadata:
+  name: {{ .Release.Name }}.registry
+  labels:
+    release: {{ .Release.Name }}
+type: kubernetes.io/dockerconfigjson
+data:
+  .dockerconfigjson: {{ printf `{"auths":{%s:{"auth":"%s"}}}` (.Values.images.credentials.registry | quote) (printf "%s:%s" .Values.images.credentials.username .Values.images.credentials.password | b64enc) | b64enc | quote }}
+{{- end }}
diff --git a/omec/omec-upf-cni/values.yaml b/omec/omec-upf-cni/values.yaml
index f9e1094..2008555 100644
--- a/omec/omec-upf-cni/values.yaml
+++ b/omec/omec-upf-cni/values.yaml
@@ -7,6 +7,11 @@
     omecCni: docker.io/omecproject/omec-cni:1.0.2
     sriovPlugin: docker.io/nfvpe/sriov-device-plugin:v3.2
   pullPolicy: IfNotPresent
+  credentials: {}
+  # If specified, use this credential to access the image
+  #   registry:
+  #   username:
+  #   password:
 
 config:
   sriov:
diff --git a/omec/omec-upf-pfcp-agent/Chart.yaml b/omec/omec-upf-pfcp-agent/Chart.yaml
index 06b0644..908fa1d 100644
--- a/omec/omec-upf-pfcp-agent/Chart.yaml
+++ b/omec/omec-upf-pfcp-agent/Chart.yaml
@@ -7,4 +7,4 @@
 name: omec-upf-pfcp-agent
 icon: https://guide.opencord.org/logos/cord.svg
 
-version: 0.1.0
+version: 0.1.1
diff --git a/omec/omec-upf-pfcp-agent/templates/secret-registry.yaml b/omec/omec-upf-pfcp-agent/templates/secret-registry.yaml
new file mode 100644
index 0000000..1502049
--- /dev/null
+++ b/omec/omec-upf-pfcp-agent/templates/secret-registry.yaml
@@ -0,0 +1,18 @@
+{{/*
+# Copyright 2020-present Open Networking Foundation
+
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+
+{{- if .Values.images.credentials }}
+---
+kind: Secret
+apiVersion: v1
+metadata:
+  name: {{ .Release.Name }}.registry
+  labels:
+    release: {{ .Release.Name }}
+type: kubernetes.io/dockerconfigjson
+data:
+  .dockerconfigjson: {{ printf `{"auths":{%s:{"auth":"%s"}}}` (.Values.images.credentials.registry | quote) (printf "%s:%s" .Values.images.credentials.username .Values.images.credentials.password | b64enc) | b64enc | quote }}
+{{- end }}
diff --git a/omec/omec-upf-pfcp-agent/templates/statefulset-pfcp-agent.yaml b/omec/omec-upf-pfcp-agent/templates/statefulset-pfcp-agent.yaml
index 56f6273..d979dec 100644
--- a/omec/omec-upf-pfcp-agent/templates/statefulset-pfcp-agent.yaml
+++ b/omec/omec-upf-pfcp-agent/templates/statefulset-pfcp-agent.yaml
@@ -28,7 +28,12 @@
       nodeSelector:
         {{ .Values.nodeSelectors.pfcp.label }}: {{ .Values.nodeSelectors.pfcp.value }}
     {{- end }}
+    {{- if .Values.images.credentials }}
+      imagePullSecrets:
+        - name: {{ .Release.Name }}.registry
+    {{- end }}
     {{- if .Values.config.coreDump.enabled }}
+      initContainers:
 {{ tuple "pfcp" . | include "omec-upf-pfcp-agent.coredump_init" | indent 8 }}
     {{- end }}
       containers:
diff --git a/omec/omec-upf-pfcp-agent/values.yaml b/omec/omec-upf-pfcp-agent/values.yaml
index 1fd9f5e..1306965 100644
--- a/omec/omec-upf-pfcp-agent/values.yaml
+++ b/omec/omec-upf-pfcp-agent/values.yaml
@@ -7,6 +7,11 @@
     init: docker.io/omecproject/pod-init:1.0.0
     pfcpiface: docker.io/omecproject/upf-epc-pfcpiface:up4
   pullPolicy: Always
+  credentials: {}
+  # If specified, use this credential to access the image
+  #   registry:
+  #   username:
+  #   password:
 
 nodeSelectors:
   enabled: false
diff --git a/omec/omec-user-plane/Chart.yaml b/omec/omec-user-plane/Chart.yaml
index 7592052..9c33dc9 100644
--- a/omec/omec-user-plane/Chart.yaml
+++ b/omec/omec-user-plane/Chart.yaml
@@ -7,4 +7,4 @@
 name: omec-user-plane
 icon: https://guide.opencord.org/logos/cord.svg
 
-version: 0.3.3
+version: 0.3.4
diff --git a/omec/omec-user-plane/templates/secret-registry.yaml b/omec/omec-user-plane/templates/secret-registry.yaml
new file mode 100644
index 0000000..1502049
--- /dev/null
+++ b/omec/omec-user-plane/templates/secret-registry.yaml
@@ -0,0 +1,18 @@
+{{/*
+# Copyright 2020-present Open Networking Foundation
+
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+*/}}
+
+{{- if .Values.images.credentials }}
+---
+kind: Secret
+apiVersion: v1
+metadata:
+  name: {{ .Release.Name }}.registry
+  labels:
+    release: {{ .Release.Name }}
+type: kubernetes.io/dockerconfigjson
+data:
+  .dockerconfigjson: {{ printf `{"auths":{%s:{"auth":"%s"}}}` (.Values.images.credentials.registry | quote) (printf "%s:%s" .Values.images.credentials.username .Values.images.credentials.password | b64enc) | b64enc | quote }}
+{{- end }}
diff --git a/omec/omec-user-plane/templates/statefulset-upf.yaml b/omec/omec-user-plane/templates/statefulset-upf.yaml
index fd63696..59187be 100644
--- a/omec/omec-user-plane/templates/statefulset-upf.yaml
+++ b/omec/omec-user-plane/templates/statefulset-upf.yaml
@@ -51,6 +51,10 @@
       nodeSelector:
         {{ .Values.nodeSelectors.upf.label }}: {{ .Values.nodeSelectors.upf.value }}
     {{- end }}
+    {{- if .Values.images.credentials }}
+      imagePullSecrets:
+        - name: {{ .Release.Name }}.registry
+    {{- end }}
       initContainers:
       - name: bess-init
         image: {{ .Values.images.tags.bess | quote }}
diff --git a/omec/omec-user-plane/values.yaml b/omec/omec-user-plane/values.yaml
index 088b2a8..e53951e 100644
--- a/omec/omec-user-plane/values.yaml
+++ b/omec/omec-user-plane/values.yaml
@@ -9,6 +9,11 @@
     pfcpiface: docker.io/omecproject/upf-epc-pfcpiface:master-latest
     zmqiface: docker.io/omecproject/upf-epc-cpiface:master-latest
   pullPolicy: Always
+  credentials: {}
+  # If specified, use this credential to access the image
+  #   registry:
+  #   username:
+  #   password:
 
 nodeSelectors:
   enabled: false