Merge "helm3 and K8 1.18 support added"
[ric-plt/ric-dep.git] / helm / appmgr / templates / deployment.yaml
1 ################################################################################
2 #   Copyright (c) 2019 AT&T Intellectual Property.                             #
3 #   Copyright (c) 2019 Nokia.                                                  #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 {{- $tillerKey := .Values.appmgr.tillerkey | default "ricxapp" }}
18 {{- $topCtx :=  . }}
19 {{- $ctx := dict "ctx" $topCtx "key" $tillerKey }}
20 {{- $secretPath := .Values.appmgr.appsecretpath | default "/opt/ric/secret" }}
21 {{- $certName := include "common.tillerHelmClientTLSSecret" $ctx }} 
22 apiVersion: apps/v1
23 kind: Deployment
24 metadata:
25   name: {{ include "common.deploymentname.appmgr" . }}
26   namespace: {{ include "common.namespace.platform" . }}
27   labels:
28     app: {{ include "common.namespace.platform" . }}-{{ include "common.name.appmgr" . }}
29     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
30     release: {{ .Release.Name }}
31     heritage: {{ .Release.Service }}
32 spec:
33   replicas: {{ .Values.appmgr.replicaCount }}
34   selector:
35     matchLabels:
36       app: {{ include "common.namespace.platform" . }}-{{ include "common.name.appmgr" . }}
37       release: {{ .Release.Name }}
38   template:
39     metadata:
40       {{- if .Values.appmgr.annotations }}
41       annotations:
42         {{- .Values.appmgr.annotations | nindent 8 -}}
43       {{ end }}
44       labels:
45         app: {{ include "common.namespace.platform" . }}-{{ include "common.name.appmgr" . }}
46         release: {{ .Release.Name }}
47     spec:
48       hostname: {{ include "common.name.appmgr" . }}
49       serviceAccountName: {{ include "common.serviceaccountname.appmgr" . }}
50       imagePullSecrets:
51         {{- $newctx := dict "ctx" $topCtx "defaultregistry" .Values.appmgr.image.init.registry }}
52         - name: {{ include "common.dockerregistry.credential" $newctx -}}
53 {{- if or (eq ( include "common.tillerTLSVerify" $ctx ) "true" )  (eq ( include "common.tillerTLSAuthenticate" $ctx ) "true") }}
54       initContainers:
55         - name: {{ include "common.containername.appmgr" . }}-copy-tiller-secret
56           {{- $newctx := dict "ctx" $topCtx "defaultregistry" .Values.appmgr.image.init.registry }}
57           image: {{ include "common.dockerregistry.url" $newctx }}/{{ .Values.appmgr.image.init.name }}:{{ .Values.appmgr.image.init.tag }}
58           {{- $newctx := dict "ctx" $topCtx "defaultpullpolicy" .Values.appmgr.imagePullPolicy }}
59           imagePullPolicy: {{ include "common.dockerregistry.pullpolicy" $newctx }}
60           env:
61             - name: SVCACCT_NAME
62               value: {{ include "common.serviceaccountname.appmgr" . }}
63             - name: CLUSTER_NAME
64               value: {{ default "kubernetes" .Values.appmgr.clusterName }}
65             - name: KUBECONFIG
66               value: /tmp/kubeconfig
67             - name: K8S_API_HOST
68               value: {{ default "https://kubernetes.default.svc.cluster.local/" .Values.common.k8sAPIHost }}
69             - name: SECRET_NAMESPACE
70               value: {{ include "common.tillerDeployNameSpace" $ctx }}
71             - name: SECRET_NAME
72               value: {{ include "common.tillerHelmClientTLSSecret" $ctx }}
73           envFrom:
74             - configMapRef:
75                 name: {{ include "common.configmapname.appmgr" . }}-env
76           command: ["/appmgr-tiller-secret-copier.sh"]
77           volumeMounts:
78             - name: helm-secret-volume
79               mountPath: {{ $secretPath }}
80               readOnly: false
81             - name: appmgr-bin-volume
82               mountPath: /svcacct-to-kubeconfig.sh
83               subPath: svcacct-to-kubeconfig.sh
84             - name: appmgr-bin-volume
85               mountPath: /appmgr-tiller-secret-copier.sh
86               subPath: appmgr-tiller-secret-copier.sh
87 {{- end }}      
88       containers:
89         - name: {{ include "common.containername.appmgr" . }}
90           {{- $newctx := dict "ctx" $topCtx "defaultregistry" .Values.appmgr.image.appmgr.registry }}
91           image: {{ include "common.dockerregistry.url" $newctx }}/{{ .Values.appmgr.image.appmgr.name }}:{{ .Values.appmgr.image.appmgr.tag }}
92           {{- $newctx := dict "ctx" $topCtx "defaultpullpolicy" .Values.appmgr.imagePullPolicy }}
93           imagePullPolicy: {{ include "common.dockerregistry.pullpolicy" $newctx }}
94           ports:
95             - name: http
96               containerPort: {{ include "common.serviceport.appmgr.http" . }}
97               protocol: TCP
98             - name: rmrroute
99               containerPort: {{ include "common.serviceport.appmgr.rmr.route" . }}
100               protocol: TCP
101             - name: rmrdata
102               containerPort: {{ include "common.serviceport.appmgr.rmr.data" . }}
103               protocol: TCP
104           volumeMounts:
105             - name: config-volume
106               mountPath: {{ .Values.appmgr.appconfigpath }}/appmgr.yaml
107               subPath: appmgr.yaml
108             - name: helm-secret-volume
109               mountPath: {{ $secretPath }}
110               readOnly: false
111             - name: secret-volume
112               mountPath: {{ $secretPath }}/helm_repo_username
113               subPath: helm_repo_username
114             - name: secret-volume
115               mountPath: {{ $secretPath }}/helm_repo_password
116               subPath: helm_repo_password
117           envFrom:
118             - configMapRef:
119                 name: {{ include "common.configmapname.appmgr" . }}-env
120             - configMapRef:
121                 name: {{ include "common.configmapname.dbaas" . }}-appconfig
122           livenessProbe:
123             #exec:
124             #  command:
125             #    - /bin/bash
126             #    - -c
127             #    - ps -ef | grep {{ .Values.livenessprocessname }}| grep -v "grep"
128             #initialDelaySeconds: 120
129             #periodSeconds: 30
130           readinessProbe:
131           #  httpGet:
132           #    path: /
133           #    port: http
134           securityContext:
135             # ubuntu
136             #runAsUser: 1000
137             #allowPrivilegeEscalation: false
138       restartPolicy: Always
139       volumes:
140         - name: config-volume
141           configMap:
142             name: {{ include "common.configmapname.appmgr" . }}-appconfig
143         - name: secret-volume
144           secret:
145             secretName: {{ include "common.secretname.appmgr" . }}
146         - name: helm-secret-volume
147           emptyDir: {}
148         - name: appmgr-bin-volume
149           configMap:
150             name: {{ include "common.configmapname.appmgr" . }}-bin
151             defaultMode: 0755