Add xApp pod annotation suport
[it/dev.git] / xapp_onboarder / xapp_onboarder / resources / xapp-std / templates / deployment.yaml
1 ################################################################################
2 #   Copyright (c) 2019 AT&T Intellectual Property.                             #
3 #                                                                              #
4 #   Licensed under the Apache License, Version 2.0 (the "License");            #
5 #   you may not use this file except in compliance with the License.           #
6 #   You may obtain a copy of the License at                                    #
7 #                                                                              #
8 #       http://www.apache.org/licenses/LICENSE-2.0                             #
9 #                                                                              #
10 #   Unless required by applicable law or agreed to in writing, software        #
11 #   distributed under the License is distributed on an "AS IS" BASIS,          #
12 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
13 #   See the License for the specific language governing permissions and        #
14 #   limitations under the License.                                             #
15 ################################################################################'
16 apiVersion: apps/v1
17 kind: Deployment
18 metadata:
19   name: {{ include "ricxapp.fullname" . }}
20   labels:
21     app: {{ include "ricxapp.namespace" . }}-{{ include "ricxapp.name" . }}
22     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
23     release: {{ .Release.Name }}
24     heritage: {{ .Release.Service }}
25 spec:
26   replicas: {{ .Values.replicaCount }}
27   selector:
28     matchLabels:
29       app: {{ include "ricxapp.namespace" . }}-{{ include "ricxapp.name" . }}
30       release: {{ .Release.Name }}
31   template:
32     metadata:
33       {{- if .Values.annotations }}
34       annotations:
35         {{- range $key, $value := .Values.annotations }}
36           {{- if kindIs "string" $value }}
37         {{ $key }}: {{ $value | toPrettyJson }}
38           {{- else }}
39         {{ $key }}: |
40 {{- $value | toPrettyJson | nindent 10 }}
41           {{- end }}
42         {{- end -}}
43       {{ end }}
44       labels:
45         app: {{ include "ricxapp.namespace" . }}-{{ include "ricxapp.name" . }}
46         release: {{ .Release.Name }}
47     spec:
48       hostname: {{ include "ricxapp.name" . }}
49       imagePullSecrets:
50 {{- range .Values.containers }}
51         - name: {{ .image.registry | replace "." "-" | replace ":" "-" | replace "/" "-" | trunc 63 | trimSuffix "-" }}
52 {{- end }}
53       volumes:
54         - name: config-volume
55           configMap:
56             name: {{ include "ricxapp.configmapname" . }}-appconfig
57       containers:
58 {{- $containers := .Values.containers }}
59 {{- $ports := .Values.messaging.ports }}
60 {{- range $container := $containers }}
61   {{- $portlist := list }}
62   {{- range $port := $ports }}
63     {{- if eq $port.container $container.name }}
64         {{- $portlist = append $portlist $port }}
65     {{- end }}
66   {{- end }}
67         - name: {{ $container.name }}
68           image: "{{ $container.image.registry }}/{{ $container.image.name }}:{{ $container.image.tag }}"
69           {{- if $container.command }}
70           command: [
71           {{- range $command := $container.command -}}
72           {{- $command | quote -}}
73           {{- if ne $command (last $container.command) }}
74           {{- print ", " -}}
75           {{- end -}}
76           {{- end -}}
77           {{- print "]" -}}
78           {{- end}}
79           {{- if $container.args }}
80           args: [
81           {{- range $arg := $container.args -}}
82           {{- $arg | quote -}}
83           {{- if ne $arg (last $container.args) }}
84           {{- print ", " -}}
85           {{- end -}}
86           {{- end -}}
87           {{- print "]" -}}
88           {{- end}}
89           imagePullPolicy: {{ $.Values.image_pull_policy }}
90   {{- if $portlist }}
91           ports:
92     {{- range $port := $portlist }}
93             - name: {{ $port.name }}
94               containerPort: {{ $port.port }}
95               protocol: TCP
96     {{- end }}
97   {{- end }}
98 {{- end }}
99           volumeMounts:
100             - name: config-volume
101               mountPath: {{ .Values.appconfig.path }}
102           envFrom:
103             - configMapRef:
104                 name: {{ include "ricxapp.configmapname" . }}-appenv
105             - configMapRef:
106                 name: dbaas-appconfig
107           restartPolicy: Always