Extend K8S and RIC installation instructions
[it/dep.git] / ric-platform / 50-RIC-Platform / 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 apiVersion: apps/v1
22 kind: Deployment
23 metadata:
24   name: {{ include "common.deploymentname.appmgr" . }}
25   namespace: {{ include "common.namespace.platform" . }}
26   labels:
27     app: {{ include "common.namespace.platform" . }}-{{ include "common.name.appmgr" . }}
28     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
29     release: {{ .Release.Name }}
30     heritage: {{ .Release.Service }}
31 spec:
32   replicas: {{ .Values.appmgr.replicaCount }}
33   selector:
34     matchLabels:
35       app: {{ include "common.namespace.platform" . }}-{{ include "common.name.appmgr" . }}
36       release: {{ .Release.Name }}
37   template:
38     metadata:
39       {{- if .Values.appmgr.annotations }}
40       annotations:
41         {{- .Values.appmgr.annotations | nindent 8 -}}
42       {{ end }}
43       labels:
44         app: {{ include "common.namespace.platform" . }}-{{ include "common.name.appmgr" . }}
45         release: {{ .Release.Name }}
46     spec:
47       hostname: {{ include "common.name.appmgr" . }}
48       serviceAccountName: {{ include "common.serviceaccountname.appmgr" . }}
49       imagePullSecrets:
50         - name: {{ include "common.repositoryCred" . }}
51 {{- if or (eq ( include "common.tillerTLSVerify" $ctx ) "true" )  (eq ( include "common.tillerTLSAuthenticate" $ctx ) "true") }}
52       initContainers:
53         - name: {{ include "common.containername.appmgr" . }}-copy-tiller-secret
54           image: {{ include "common.repository" . }}/{{ .Values.appmgr.image.init.name }}:{{ .Values.appmgr.image.init.tag }}
55           imagePullPolicy: {{ default "IfNotPresent" .pullPolicy }}
56           env:
57             - name: SVCACCT_NAME
58               value: {{ include "common.serviceaccountname.appmgr" . }}
59             - name: CLUSTER_NAME
60               value: {{ default "kubernetes" .Values.global.clusterName }}
61             - name: KUBECONFIG
62               value: /tmp/kubeconfig
63             - name: K8S_API_HOST
64               value: {{ default "kubernetes.default.svc.cluster.local" .Values.global.k8sAPIHost }}
65             - name: SECRET_NAMESPACE
66               value: {{ include "common.tillerDeployNameSpace" $ctx }}
67             - name: SECRET_NAME
68               value: {{ include "common.tillerHelmClientTLSSecret" $ctx }}
69           envFrom:
70             - configMapRef:
71                 name: {{ include "common.configmapname.appmgr" . }}-env
72           command: ["/appmgr-tiller-secret-copier.sh"]
73           volumeMounts:
74             - name: helm-secret-volume
75               mountPath: {{ $secretPath }}
76               readOnly: false
77             - name: appmgr-bin-volume
78               mountPath: /svcacct-to-kubeconfig.sh
79               subPath: svcacct-to-kubeconfig.sh
80             - name: appmgr-bin-volume
81               mountPath: /appmgr-tiller-secret-copier.sh
82               subPath: appmgr-tiller-secret-copier.sh
83 {{- end }}      
84       containers:
85         - name: {{ include "common.containername.appmgr" . }}
86           image: {{ include "common.repository" . }}/{{ .Values.appmgr.image.name }}:{{ .Values.appmgr.image.tag }}
87           imagePullPolicy: {{ include "common.pullPolicy" . }}
88           ports:
89             - name: http
90               containerPort: {{ include "common.serviceport.appmgr.http" . }}
91               protocol: TCP
92             - name: rmrroute
93               containerPort: {{ include "common.serviceport.appmgr.rmr.route" . }}
94               protocol: TCP
95             - name: rmrdata
96               containerPort: {{ include "common.serviceport.appmgr.rmr.data" . }}
97               protocol: TCP
98           volumeMounts:
99             - name: config-volume
100               mountPath: {{ .Values.appmgr.appconfigpath }}/appmgr.yaml
101               subPath: appmgr.yaml
102             - name: cert-volume
103               mountPath: {{ .Values.appmgr.appcertpath }}
104             - name: helm-secret-volume
105               mountPath: {{ $secretPath }}
106               readOnly: false
107             - name: secret-volume
108               mountPath: {{ $secretPath }}/helm_repo_username
109               subPath: helm_repo_username
110             - name: secret-volume
111               mountPath: {{ $secretPath }}/helm_repo_password
112               subPath: helm_repo_password
113           envFrom:
114             - configMapRef:
115                 name: {{ include "common.configmapname.appmgr" . }}-env
116           livenessProbe:
117             #exec:
118             #  command:
119             #    - /bin/bash
120             #    - -c
121             #    - ps -ef | grep {{ .Values.livenessprocessname }}| grep -v "grep"
122             #initialDelaySeconds: 120
123             #periodSeconds: 30
124           readinessProbe:
125           #  httpGet:
126           #    path: /
127           #    port: http
128           restartPolicy: Always
129           securityContext:
130             # ubuntu
131             #runAsUser: 1000
132             #allowPrivilegeEscalation: false
133       volumes:
134         - name: config-volume
135           configMap:
136             name: {{ include "common.configmapname.appmgr" . }}-appconfig
137         - name: cert-volume
138           configMap:
139             name: {{ include "common.helmrepositorycert" . }}
140         - name: secret-volume
141           secret:
142             secretName: {{ include "common.helmrepositorycred" . }}
143         - name: helm-secret-volume
144           emptyDir: {}
145         - name: appmgr-bin-volume
146           configMap:
147             name: {{ include "common.configmapname.appmgr" . }}-bin
148             defaultMode: 0755