Moving dev back to LF Gerrit
[it/dep.git] / ric-infra / 45-Tiller / helm / xapp-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: ["namespaces"]
50   verbs: ["get"]
51 - apiGroups: [""]  
52   resources: ["pods", "configmaps", "deployments", "services"]
53   verbs: ["get", "list", "create", "delete"]
54 ---
55 apiVersion: rbac.authorization.k8s.io/v1beta1
56 kind: RoleBinding
57 metadata:
58   name: {{ include "common.serviceaccountname.tiller" $ctx }}-{{ $nameSpace }}-tiller-base
59   namespace: {{ $nameSpace }}
60 roleRef:
61   apiGroup: rbac.authorization.k8s.io
62   kind: Role
63   name: {{ include "common.tillerName" $ctx }}-tiller-base
64 subjects:
65   - kind: ServiceAccount
66     name: {{ include "common.serviceaccountname.tiller" $ctx }}
67     namespace: {{ $deployNameSpace }}
68 ---  
69 apiVersion: rbac.authorization.k8s.io/v1beta1
70 kind: Role
71 metadata:
72   name: {{ include "common.tillerName" $ctx }}-tiller-operation
73   namespace: {{ $deployNameSpace }}
74 rules:
75 - apiGroups: [""]  
76   resources: ["configmaps"]
77   verbs: ["get", "list", "create", "delete", "update"]
78 ---
79 apiVersion: rbac.authorization.k8s.io/v1beta1
80 kind: RoleBinding
81 metadata:
82   name: {{ include "common.serviceaccountname.tiller" $ctx }}-{{ $nameSpace }}-tiller-operation
83   namespace: {{ $deployNameSpace }}
84 roleRef:
85   apiGroup: rbac.authorization.k8s.io
86   kind: Role
87   name: {{ include "common.tillerName" $ctx }}-tiller-operation
88 subjects:
89   - kind: ServiceAccount
90     name: {{ include "common.serviceaccountname.tiller" $ctx }}
91     namespace: {{ $deployNameSpace }}
92 {{- if .serviceAccount.role }}
93 ---
94 apiVersion: rbac.authorization.k8s.io/v1beta1
95 kind: Role
96 metadata:
97   name: {{ include "common.tillerName" $ctx }}-tiller-deployer
98   namespace: {{ $nameSpace }}
99 rules:
100 {{ toYaml .serviceAccount.role }}
101 ---
102 apiVersion: rbac.authorization.k8s.io/v1beta1
103 kind: RoleBinding
104 metadata:
105   name: {{ include "common.serviceaccountname.tiller" $ctx }}-{{ $nameSpace }}-tiller-deployer
106   namespace: {{ $nameSpace }}
107 roleRef:
108   apiGroup: rbac.authorization.k8s.io
109   kind: Role
110   name: {{ include "common.tillerName" $ctx }}-tiller-deployer
111 subjects:
112   - kind: ServiceAccount
113     name: {{ include "common.serviceaccountname.tiller" $ctx }}
114     namespace: {{ $deployNameSpace }}
115 {{- end }}
116 ---
117 apiVersion: apps/v1
118 kind: Deployment
119 metadata:
120   labels:
121     app: helm
122     name: tiller
123   name: {{ include "common.deploymentname.tiller" $ctx }}
124   namespace: {{ $deployNameSpace }}
125 spec:
126   replicas: 1
127   selector:
128     matchLabels:
129       app: helm
130       name: tiller
131   template:
132     metadata:
133       labels:
134         app: helm
135         name: tiller
136     spec:
137       automountServiceAccountToken: true
138       imagePullSecrets:
139       {{- if $img.repositoryCred }}
140         - name: {{ $img.repositoryCred }}
141       {{- else }}
142         - name: {{ include "common.repositoryCred" $topCtx }}
143       {{- end }}
144       containers:
145       - env:
146         - name: TILLER_NAMESPACE
147           value: {{ $deployNameSpace }}
148         - name: TILLER_HISTORY_MAX
149           value: "0"
150         - name: TILLER_TLS_VERIFY
151           value: "1"
152         - name: TILLER_TLS_ENABLE
153           value: "1"
154         - name: TILLER_TLS_CERTS
155           value: /etc/certs
156         image: {{ if $img.repository }}{{- $img.repository -}}/{{ else }}{{ include "common.repository" $topCtx -}}/{{- end -}}{{- $img.name -}}{{- if $img.tag -}} : {{- $img.tag -}} {{- end }}
157         imagePullPolicy: {{ default "IfNotPresent" $img.pullPolicy }}
158         livenessProbe:
159           httpGet:
160             path: /liveness
161             port: 44135
162           initialDelaySeconds: 1
163           timeoutSeconds: 1
164         name: tiller
165         ports:
166         - containerPort: 44134
167           name: tiller
168         - containerPort: 44135
169           name: http
170         readinessProbe:
171           httpGet:
172             path: /readiness
173             port: 44135
174           initialDelaySeconds: 1
175           timeoutSeconds: 1
176         volumeMounts:
177         - mountPath: /etc/certs
178           name: tiller-certs
179           readOnly: true
180       serviceAccountName: {{ include "common.serviceaccountname.tiller" $ctx }}
181       volumes:
182       - name: tiller-certs
183         secret:
184           secretName: {{ $secretName }}
185 ---
186 apiVersion: v1
187 kind: Service
188 metadata:
189   creationTimestamp: null
190   labels:
191     app: helm
192     name: tiller
193   name: {{ include "common.servicename.tiller" $ctx }}
194   namespace: {{ $deployNameSpace }}
195 spec:
196   ports:
197   - name: tiller
198     port: {{ default 44134 .port }}
199     targetPort: tiller
200   selector:
201     app: helm
202     name: tiller
203   type: ClusterIP
204 {{- end }}
205 {{- end }}
206 {{- end }}
207 {{- end }}