Adding env variables for prometheus in E2T helmchart
[ric-plt/ric-dep.git] / helm / e2term / templates / deployment.yaml
index 615347e..661f1ca 100644 (file)
@@ -15,6 +15,8 @@
 #   limitations under the License.                                             #
 ################################################################################
 {{- $topCtx :=  . }}
+{{- $health := .Values.health }}
+{{- $common_env := .Values.common_env_variables }}
 {{- range keys .Values.e2term }}
 {{- $key := . }}
 {{- with index $topCtx.Values.e2term . }}
@@ -28,7 +30,7 @@ metadata:
   name: {{ include "common.deploymentname.e2term" $topCtx }}-{{ $key }}
   namespace: {{ include "common.namespace.platform" $topCtx }}
   labels:
-    app: {{ include "common.namespace.platform" $topCtx }}-{{ include "common.name.e2term" $topCtx }}
+    app: {{ include "common.namespace.platform" $topCtx }}-{{ include "common.name.e2term" $topCtx }}-{{ $key }}
     chart: {{ $topCtx.Chart.Name }}-{{ $topCtx.Chart.Version | replace "+" "_" }}
     release: {{ $topCtx.Release.Name }}
     heritage: {{ $topCtx.Release.Service }}
@@ -36,16 +38,61 @@ spec:
   replicas: {{ .replicaCount }}
   selector:
     matchLabels:
-      app: {{ include "common.namespace.platform" $topCtx }}-{{ include "common.name.e2term" $topCtx }}
+      app: {{ include "common.namespace.platform" $topCtx }}-{{ include "common.name.e2term" $topCtx }}-{{ $key }}
       release: {{ $topCtx.Release.Name }}
   template:
     metadata:
-      {{- if .annotations }}
+        {{- if $.Values.global }}
+          {{- if $.Values.global.danm_networks }}
+            {{- $networklist := list }}
+            {{- range $network := $.Values.global.danm_networks }}
+              {{- if $network.tenants }}
+                {{- if $network.tenants.e2term }}
+                  {{- if (hasKey $network.tenants.e2term $key) }}
+                    {{- $networklist = append $networklist $network }}
+                  {{- end }}
+                {{- end }}
+              {{- end }}
+            {{- end }}
+            {{- if $networklist }}
       annotations:
-        {{- .annotations | nindent 8 -}}
-      {{ end }}
+        danm.k8s.io/interfaces: |
+          [
+            {{- range $network := $networklist }}
+              {{- printf "\n            {\"clusterNetwork\": \"%s\"" $network.name }}
+              {{- with index $network.tenants.e2term $key }}
+              {{- if .ip }}
+                {{- printf ", \"ip\": \"%s\"" .ip }}
+              {{- else }}
+                {{- printf ", \"ip\": \"dynamic\"" }}
+              {{- end }}
+              {{- if .ip6 }}
+                {{- printf ", \"ip6\": \"%s\"" .ip6 }}
+              {{- end }}
+              {{- if .proutes }}
+                {{- printf ", \"proutes\": {" }}
+                {{- range $subnet, $gw := .proutes }}
+                  {{- if eq $subnet ( first ( keys .proutes ))}}
+                    {{- printf "\"%s\": \"%s\"" $subnet $gw }}
+                  {{- else }}
+                    {{- printf ", \"%s\": \"%s\"" $subnet $gw }}
+                  {{- end }}
+                {{- end }}
+                {{- printf "}" }}
+              {{- end }}
+              {{- end }}
+              {{- if ne $network.name (last $networklist).name }}
+              {{- printf "}," }}
+              {{- else }}
+              {{- printf "}" }}
+              {{- end }}
+            {{- end }}
+          ]
+            {{- end }}
+          {{- end }}
+        {{- end }}
       labels:
-        app: {{ include "common.namespace.platform" $topCtx }}-{{ include "common.name.e2term" $topCtx }}
+        app: {{ include "common.namespace.platform" $topCtx }}-{{ include "common.name.e2term" $topCtx }}-{{ $key }}
         release: {{ $topCtx.Release.Name }}
     spec:
       hostname: {{ include "common.name.e2term" $topCtx }}-{{ $key }}
@@ -80,19 +127,51 @@ spec:
           envFrom:
             - configMapRef:
                 name: {{ include "common.configmapname.e2term" $topCtx }}-env-{{ $key }}
+          env:
+            - name: SYSTEM_NAME
+              value: "SEP"
+            - name: CONFIG_MAP_NAME
+              value: "{{ $common_env.ConfigMapName }}"
+            - name: HOST_NAME
+              valueFrom:
+               fieldRef:
+                fieldPath: spec.nodeName
+            - name: SERVICE_NAME
+              value: "{{ $common_env.ServiceName }}"
+            - name: CONTAINER_NAME
+              value: "{{ include "common.containername.e2term" $topCtx }}"
+            - name: POD_NAME
+              valueFrom:
+               fieldRef:
+                fieldPath: metadata.name
           ports:
             - name: "rmrroute-{{ $key }}"
               containerPort: {{ include "common.serviceport.e2term.rmr.route" $topCtx }}
             - name: "rmrdata-{{ $key }}"
               containerPort: {{ include "common.serviceport.e2term.rmr.data" $topCtx }}
-            - name: "rmrsctp-{{ $key }}" 
+            - name: "sctp-{{ $key }}"
               containerPort: 36422
-              protocol: SCTP 
+              protocol: SCTP
+            - name: "prmts-{{ $key }}"
+              containerPort: {{ include "common.serviceport.e2term.prometheus" $topCtx }}
           stdin: true
           tty: true
           securityContext:
             privileged: {{ .privilegedmode }}
-
+          {{- if eq $health.liveness.enabled true }}
+          readinessProbe:
+            exec:
+              command: [ "/bin/sh", "-c", "{{ $health.readiness.command }}:{{ include "common.serviceport.e2term.rmr.data" . }}" ]
+            initialDelaySeconds: {{ $health.readiness.initialDelaySeconds }}
+            periodSeconds: {{ $health.readiness.periodSeconds }}
+          {{- end }}
+          {{- if eq $health.liveness.enabled true }}
+          livenessProbe:
+            exec:
+              command: [ "/bin/sh", "-c", "{{ $health.liveness.command }}:{{ include "common.serviceport.e2term.rmr.data" . }}" ]
+            initialDelaySeconds: {{ $health.liveness.initialDelaySeconds }}
+            periodSeconds: {{ $health.liveness.periodSeconds }}
+          {{- end }}
 {{ if .pizpub.enabled }}
         - name: {{ include "common.containername.e2term" $topCtx }}-pizpub
           {{- $pizpubimagectx := dict "ctx" $topCtx "defaultregistry" .pizpub.image.registry }}