0a622f3b288c005a71e37485d6a261114c3a42eb
[ric-plt/appmgr.git] / xapp_orchestrater / dev / 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         kubernetes_name: {{ include "ricxapp.namespace" . }}_{{ include "ricxapp.name" . }}
47         release: {{ .Release.Name }}
48     spec:
49       hostname: {{ include "ricxapp.name" . }}
50       imagePullSecrets:
51 {{- range .Values.containers }}
52         - name: {{ .image.registry | replace "." "-" | replace ":" "-" | replace "/" "-" | trunc 63 | trimSuffix "-" }}
53 {{- end }}
54       volumes:
55         - name: config-volume
56           configMap:
57             name: {{ include "ricxapp.configmapname" . }}-appconfig
58         {{- if .Values.controls }}
59         {{- if .Values.controls.fileStorage }}
60         - name: diskwriter
61           hostPath: 
62             path: {{ .Values.storage.mountPath }}
63             type: DirectoryOrCreate
64         {{- end }}
65         {{- end }}
66       containers:
67 {{- $containers := .Values.containers }}
68 {{- $ports := .Values.messaging.ports }}
69 {{- range $container := $containers }}
70   {{- $portlist := list }}
71   {{- range $port := $ports }}
72     {{- if eq $port.container $container.name }}
73         {{- $portlist = append $portlist $port }}
74     {{- end }}
75   {{- end }}
76         - name: {{ $container.name }}
77           image: "{{ $container.image.registry }}/{{ $container.image.name }}:{{ $container.image.tag }}"
78           {{- if $container.command }}
79           command: [
80           {{- range $command := $container.command -}}
81           {{- $command | quote -}}
82           {{- if ne $command (last $container.command) }}
83           {{- print ", " -}}
84           {{- end -}}
85           {{- end -}}
86           {{- print "]" -}}
87           {{- end}}
88           {{- if $container.args }}
89           args: [
90           {{- range $arg := $container.args -}}
91           {{- $arg | quote -}}
92           {{- if ne $arg (last $container.args) }}
93           {{- print ", " -}}
94           {{- end -}}
95           {{- end -}}
96           {{- print "]" -}}
97           {{- end}}
98           imagePullPolicy: {{ $.Values.image_pull_policy }}
99   {{- if $portlist }}
100           ports:
101     {{- range $port := $portlist }}
102             - name: {{ $port.name }}
103               containerPort: {{ $port.port }}
104               protocol: TCP
105     {{- end }}
106   {{- end }}
107 {{- end }}
108           volumeMounts:
109             - name: config-volume
110               mountPath: {{ .Values.appconfig.path }}
111             {{- if .Values.controls }}
112             {{- if .Values.controls.fileStorage }}
113             - name: diskwriter
114               mountPath: {{ .Values.storage.mountPath }}
115             {{- end }}
116             {{- end }}
117           envFrom:
118             - configMapRef:
119                 name: {{ include "ricxapp.configmapname" . }}-appenv
120             - configMapRef:
121                 name: dbaas-appconfig