Add support for prometheus
[ric-plt/ric-dep.git] / helm / infrastructure / templates / job-tiller-secrets.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.common }}
18 {{- $kubeapiServerEndpoint := .Values.common.k8sAPIHost }}
19 {{- if .Values.common.tillers }}
20 {{- $topCtx := . }}
21 {{- range keys .Values.common.tillers }}
22 {{- $key := . }}
23 {{- with index $topCtx.Values.common.tillers  . }}
24 {{- $img := .image.tillerTLSSecrets }}
25 {{- $imgPullPolicy := .imagePullPolicy }}
26 {{- $tillerSecret := default "tiller-secret" .secret.tillerSecretName }}
27 {{- $helmSecret := default "helm-secret" .secret.helmSecretName }}
28 {{- $serviceAccountName := default "tiller" .serviceAccount }}
29 {{- $nameSpace := .nameSpace }}
30 {{- $deployNameSpace := .deployNameSpace }}
31 {{- $img := .image.tillerTLSSecrets }}
32 {{- $ctx := dict "ctx" $topCtx "key" $key }}
33 {{- if .secret.create }}
34 {{- $serviceAccountName := randAlpha 6 | lower | printf "tiller-secret-creator-%s" }}
35 ---
36 apiVersion: v1
37 kind: ServiceAccount
38 metadata:
39   name: {{ $serviceAccountName }}
40   namespace: {{ $deployNameSpace }}
41 ---
42 apiVersion: rbac.authorization.k8s.io/v1beta1
43 kind: Role
44 metadata:
45   name: {{ $serviceAccountName }}-secret-create
46   namespace: {{ $deployNameSpace }}
47 rules:
48 - apiGroups: [""]
49   resources: ["secrets"]
50   verbs: ["create", "get", "patch"]
51 ---
52 apiVersion: rbac.authorization.k8s.io/v1beta1
53 kind: RoleBinding
54 metadata:
55   name: {{ $serviceAccountName }}-secret-create
56   namespace: {{ $deployNameSpace }}
57 roleRef:
58   apiGroup: rbac.authorization.k8s.io
59   kind: Role
60   name: {{ $serviceAccountName }}-secret-create
61 subjects:
62   - kind: ServiceAccount
63     name: {{ $serviceAccountName }}
64     namespace: {{ $deployNameSpace }}
65 ---
66 apiVersion: batch/v1
67 kind: Job
68 metadata:
69   name: tiller-secret-generator
70   namespace: {{ $deployNameSpace }}
71 spec:
72   template:
73     spec:
74       serviceAccountName: {{ $serviceAccountName }}
75       restartPolicy: Never
76       {{- $newctx := dict "ctx" $topCtx "defaultregistry" $img.registry }}
77       imagePullSecrets:
78         - name: {{ include "common.dockerregistry.credential" $newctx }}
79       containers:
80         - name: tiller-secret-generator
81           image: {{ include "common.dockerregistry.url" $newctx }}/{{- $img.name -}}:{{- $img.tag }}
82           {{- $newctx := dict "ctx" $topCtx "defaultpullpolicy" $imgPullPolicy }}
83           imagePullPolicy: {{ include "common.dockerregistry.pullpolicy" $newctx }}
84           env:
85             - name: ENTITIES
86               value: {{ tuple $tillerSecret $helmSecret | join " "  }}
87             - name: TILLER_KEY_NAME
88               value: {{ $tillerSecret }}.key.pem
89             - name: TILLER_CERT_NAME
90               value: {{ $tillerSecret }}.cert.pem
91             - name: HELM_KEY_NAME
92               value: {{ $helmSecret }}.key.pem
93             - name: HELM_CERT_NAME
94               value: {{ $helmSecret }}.cert.pem
95             - name: TILLER_CN
96               value: {{ default ( include "common.servicename.tiller" $ctx ) .hostname }}
97             - name: CLUSTER_SERVER
98               value: {{ default "https://kubernetes.default.svc.cluster.local/" $kubeapiServerEndpoint }}
99 {{- end }}
100 {{- end }}
101 {{- end }}
102 {{- end }}
103 {{- end }}