Allow containers to speciify command and arguement list
[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       labels:
34         app: {{ include "ricxapp.namespace" . }}-{{ include "ricxapp.name" . }}
35         release: {{ .Release.Name }}
36     spec:
37       hostname: {{ include "ricxapp.name" . }}
38       imagePullSecrets:
39 {{- range .Values.containers }}
40         - name: {{ .image.registry | replace "." "-" | replace ":" "-" | replace "/" "-" | trunc 63 | trimSuffix "-" }}
41 {{- end }}
42       volumes:
43         - name: config-volume
44           configMap:
45             name: {{ include "ricxapp.configmapname" . }}-appconfig
46       containers:
47 {{- $containers := .Values.containers }}
48 {{- $ports := .Values.messaging.ports }}
49 {{- range $container := $containers }}
50   {{- $portlist := list }}
51   {{- range $port := $ports }}
52     {{- if eq $port.container $container.name }}
53         {{- $portlist = append $portlist $port }}
54     {{- end }}
55   {{- end }}
56         - name: {{ $container.name }}
57           image: "{{ $container.image.registry }}/{{ $container.image.name }}:{{ $container.image.tag }}"
58           {{- if $container.command }}
59           command: [
60           {{- range $command := $container.command -}}
61           {{- $command | quote -}}
62           {{- if ne $command (last $container.command) }}
63           {{- print ", " -}}
64           {{- end -}}
65           {{- end -}}
66           {{- print "]" -}}
67           {{- end}}
68           {{- if $container.args }}
69           args: [
70           {{- range $arg := $container.args -}}
71           {{- $arg | quote -}}
72           {{- if ne $arg (last $container.args) }}
73           {{- print ", " -}}
74           {{- end -}}
75           {{- end -}}
76           {{- print "]" -}}
77           {{- end}}
78           imagePullPolicy: {{ $.Values.image_pull_policy }}
79   {{- if $portlist }}
80           ports:
81     {{- range $port := $portlist }}
82             - name: {{ $port.name }}
83               containerPort: {{ $port.port }}
84               protocol: TCP
85     {{- end }}
86   {{- end }}
87 {{- end }}
88           volumeMounts:
89             - name: config-volume
90               mountPath: {{ .Values.appconfig.path }}
91           envFrom:
92             - configMapRef:
93                 name: {{ include "ricxapp.configmapname" . }}-appenv
94             - configMapRef:
95                 name: dbaas-appconfig
96           restartPolicy: Always