6b1e8e88b634249477e236191811b5f1c8a9b7ed
[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: extensions/v1beta1
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   template:
128     metadata:
129       labels:
130         app: helm
131         name: tiller
132     spec:
133       automountServiceAccountToken: true
134       imagePullSecrets:
135       {{- if $img.repositoryCred }}
136         - name: {{ $img.repositoryCred }}
137       {{- else }}
138         - name: {{ include "common.repositoryCred" $topCtx }}
139       {{- end }}
140       containers:
141       - env:
142         - name: TILLER_NAMESPACE
143           value: {{ $deployNameSpace }}
144         - name: TILLER_HISTORY_MAX
145           value: "0"
146         - name: TILLER_TLS_VERIFY
147           value: "1"
148         - name: TILLER_TLS_ENABLE
149           value: "1"
150         - name: TILLER_TLS_CERTS
151           value: /etc/certs
152         image: {{ if $img.repository }}{{- $img.repository -}}/{{ else }}{{ include "common.repository" $topCtx -}}/{{- end -}}{{- $img.name -}}{{- if $img.tag -}} : {{- $img.tag -}} {{- end }}
153         imagePullPolicy: {{ default "IfNotPresent" $img.pullPolicy }}
154         livenessProbe:
155           httpGet:
156             path: /liveness
157             port: 44135
158           initialDelaySeconds: 1
159           timeoutSeconds: 1
160         name: tiller
161         ports:
162         - containerPort: 44134
163           name: tiller
164         - containerPort: 44135
165           name: http
166         readinessProbe:
167           httpGet:
168             path: /readiness
169             port: 44135
170           initialDelaySeconds: 1
171           timeoutSeconds: 1
172         volumeMounts:
173         - mountPath: /etc/certs
174           name: tiller-certs
175           readOnly: true
176       serviceAccountName: {{ include "common.serviceaccountname.tiller" $ctx }}
177       volumes:
178       - name: tiller-certs
179         secret:
180           secretName: {{ $secretName }}
181 ---
182 apiVersion: v1
183 kind: Service
184 metadata:
185   creationTimestamp: null
186   labels:
187     app: helm
188     name: tiller
189   name: {{ include "common.servicename.tiller" $ctx }}
190   namespace: {{ $deployNameSpace }}
191 spec:
192   ports:
193   - name: tiller
194     port: {{ default 44134 .port }}
195     targetPort: tiller
196   selector:
197     app: helm
198     name: tiller
199   type: ClusterIP
200 {{- end }}
201 {{- end }}
202 {{- end }}
203 {{- end }}