f85a486715df4ada63db9aa3b7a4c857e7f852c3
[it/dep.git] / ric-infra / 25-tiller / helm / ricplt-tiller / templates / deployment-tiller.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 {{- if .Values.global }}
18 {{- if .Values.global.tillers }}
19 {{- $topCtx :=  . }}
20 {{- range keys .Values.global.tillers }}
21 {{- $key := . }}
22 {{- with index $topCtx.Values.global.tillers . }}
23 {{- $nameSpace := .nameSpace }}
24 {{- $deployNameSpace := .deployNameSpace }}
25 {{- $img := .image.tiller }}
26 {{- $secretName := default "tiller-secret" .secret.tillerSecretName }}
27 {{- $ctx := dict "ctx" $topCtx "key" $key }}
28 ---
29 apiVersion: v1
30 kind: ServiceAccount
31 metadata:
32   name: {{ include "common.serviceaccountname.tiller" $ctx }}
33   namespace: {{ $deployNameSpace }}
34 ---  
35 apiVersion: rbac.authorization.k8s.io/v1beta1
36 kind: Role
37 metadata:
38   name: {{ include "common.tillerName" $ctx }}-tiller-base
39   namespace: {{ $nameSpace }}
40 rules:
41 - apiGroups: [""]
42   resources: ["secrets"]
43   resourceNames: [ {{ $secretName }} ]
44   verbs: ["get"]
45 - apiGroups: [""]
46   resources: ["pods/portforward"]
47   verbs: ["create"]
48 - apiGroups: [""]  
49   resources: ["pods", "configmaps", "deployments", "services"]
50   verbs: ["get", "list", "create", "delete"]
51 ---
52 apiVersion: rbac.authorization.k8s.io/v1beta1
53 kind: RoleBinding
54 metadata:
55   name: {{ include "common.serviceaccountname.tiller" $ctx }}-{{ $nameSpace }}-tiller-base
56   namespace: {{ $nameSpace }}
57 roleRef:
58   apiGroup: rbac.authorization.k8s.io
59   kind: Role
60   name: {{ include "common.tillerName" $ctx }}-tiller-base
61 subjects:
62   - kind: ServiceAccount
63     name: {{ include "common.serviceaccountname.tiller" $ctx }}
64     namespace: {{ $deployNameSpace }}
65 {{- if .serviceAccount.role }}
66 ---
67 apiVersion: rbac.authorization.k8s.io/v1beta1
68 kind: Role
69 metadata:
70   name: {{ include "common.tillerName" $ctx }}-tiller-deployer
71   namespace: {{ $nameSpace }}
72 rules:
73 {{ toYaml .serviceAccount.role }}
74 ---
75 apiVersion: rbac.authorization.k8s.io/v1beta1
76 kind: RoleBinding
77 metadata:
78   name: {{ include "common.serviceaccountname.tiller" $ctx }}-{{ $nameSpace }}-tiller-deployer
79   namespace: {{ $nameSpace }}
80 roleRef:
81   apiGroup: rbac.authorization.k8s.io
82   kind: Role
83   name: {{ include "common.tillerName" $ctx }}-tiller-deployer
84 subjects:
85   - kind: ServiceAccount
86     name: {{ include "common.serviceaccountname.tiller" $ctx }}
87     namespace: {{ $deployNameSpace }}
88 {{- end }}
89 ---
90 apiVersion: extensions/v1beta1
91 kind: Deployment
92 metadata:
93   labels:
94     app: helm
95     name: tiller
96   name: {{ include "common.deploymentname.tiller" $ctx }}
97   namespace: {{ $deployNameSpace }}
98 spec:
99   replicas: 1
100   template:
101     metadata:
102       labels:
103         app: helm
104         name: tiller
105     spec:
106       automountServiceAccountToken: true
107       imagePullSecrets:
108       {{- if $img.repositoryCred }}
109         - name: {{ $img.repositoryCred }}
110       {{- else }}
111         - name: {{ include "common.repositoryCred" $topCtx }}
112       {{- end }}
113       containers:
114       - env:
115         - name: TILLER_NAMESPACE
116           value: {{ $deployNameSpace }}
117         - name: TILLER_HISTORY_MAX
118           value: "0"
119         - name: TILLER_TLS_VERIFY
120           value: "1"
121         - name: TILLER_TLS_ENABLE
122           value: "1"
123         - name: TILLER_TLS_CERTS
124           value: /etc/certs
125         image: {{ if $img.repository }}{{- $img.repository -}}/{{ else }}{{ include "common.repository" $topCtx -}}/{{- end -}}{{- $img.name -}}{{- if $img.tag -}} : {{- $img.tag -}} {{- end }}
126         imagePullPolicy: {{ default "IfNotPresent" $img.pullPolicy }}
127         livenessProbe:
128           httpGet:
129             path: /liveness
130             port: 44135
131           initialDelaySeconds: 1
132           timeoutSeconds: 1
133         name: tiller
134         ports:
135         - containerPort: 44134
136           name: tiller
137         - containerPort: 44135
138           name: http
139         readinessProbe:
140           httpGet:
141             path: /readiness
142             port: 44135
143           initialDelaySeconds: 1
144           timeoutSeconds: 1
145         volumeMounts:
146         - mountPath: /etc/certs
147           name: tiller-certs
148           readOnly: true
149       serviceAccountName: {{ include "common.serviceaccountname.tiller" $ctx }}
150       volumes:
151       - name: tiller-certs
152         secret:
153           secretName: {{ $secretName }}
154 ---
155 apiVersion: v1
156 kind: Service
157 metadata:
158   creationTimestamp: null
159   labels:
160     app: helm
161     name: tiller
162   name: {{ include "common.servicename.tiller" $ctx }}
163   namespace: {{ $deployNameSpace }}
164 spec:
165   ports:
166   - name: tiller
167     port: {{ default 44134 .port }}
168     targetPort: tiller
169   selector:
170     app: helm
171     name: tiller
172   type: ClusterIP
173 {{- end }}
174 {{- end }}
175 {{- end }}
176 {{- end }}