Add role to allow appmgr to access xApp k8s service
[ric-plt/ric-dep.git] / helm / appmgr / templates / serviceaccount.yaml
1 ################################################################################
2 #   Copyright (c) 2019-2020 AT&T Intellectual Property.                        #
3 #                                                                              #
4 #   Licensed under the Apache License, Version 2.0 (the "License");            #
5 #   you may not use this file except in compliance with the License.           #
6 #   You may obtain a copy of the License at                                    #
7 #                                                                              #
8 #       http://www.apache.org/licenses/LICENSE-2.0                             #
9 #                                                                              #
10 #   Unless required by applicable law or agreed to in writing, software        #
11 #   distributed under the License is distributed on an "AS IS" BASIS,          #
12 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
13 #   See the License for the specific language governing permissions and        #
14 #   limitations under the License.                                             #
15 ################################################################################
16
17 {{- $tillerKey := .Values.appmgr.tillerkey | default "ricxapp" }}
18 {{- $topCtx :=  . }}
19 {{- $ctx := dict "ctx" $topCtx "key" $tillerKey }}
20 {{- $certName := include "common.tillerHelmClientTLSSecret" $ctx }}
21 ---
22 apiVersion: v1
23 kind: ServiceAccount
24 metadata:
25   name: {{ include "common.serviceaccountname.appmgr" . }}
26   namespace: {{ include "common.namespace.platform" . }}
27 ---
28 apiVersion: rbac.authorization.k8s.io/v1beta1
29 kind: Role
30 metadata:
31   name: {{ include "common.serviceaccountname.appmgr" . }}-{{ include "common.tillerNameSpace" $ctx }}-access
32   namespace: {{ include "common.tillerDeployNameSpace" $ctx }}
33 rules:
34 - apiGroups: [""]
35   resources: ["pods/portforward"]
36   verbs: ["create"]
37 - apiGroups: [""]
38   resources: ["pods", "configmaps", "deployments", "services"]
39   verbs: ["get", "list", "create", "delete"]
40 {{- if or (eq (include "common.tillerTLSVerify" $ctx) "true" )  (eq (include "common.tillerTLSAuthenticate" $ctx) "true") }}
41 - apiGroups: [""]
42   resources: ["secrets"]
43   resourceNames: [ {{ include "common.tillerHelmClientTLSSecret" $ctx | quote }} ]
44   verbs: ["get"]
45 {{- end }}
46 ---
47 apiVersion: rbac.authorization.k8s.io/v1beta1
48 kind: RoleBinding
49 metadata:
50   name: {{ include "common.serviceaccountname.appmgr" . }}-{{ include "common.tillerNameSpace" $ctx }}-access
51   namespace: {{ include "common.tillerDeployNameSpace" $ctx }}
52 roleRef:
53   apiGroup: rbac.authorization.k8s.io
54   kind: Role
55   name: {{ include "common.serviceaccountname.appmgr" . }}-{{ include "common.tillerNameSpace" $ctx }}-access
56 subjects:
57   - kind: ServiceAccount
58     name: {{ include "common.serviceaccountname.appmgr" . }}
59     namespace: {{ include "common.namespace.platform" . }}
60 ---
61 apiVersion: rbac.authorization.k8s.io/v1beta1
62 kind: Role
63 metadata:
64   name: {{ include "common.serviceaccountname.appmgr" . }}-{{ include "common.tillerNameSpace" $ctx }}-getappconfig
65   namespace: {{ include "common.tillerNameSpace" $ctx }}
66 rules:
67 - apiGroups: [""]
68   resources: ["configmaps", "endpoints", "services"]
69   verbs: ["get", "list", "create", "update", "delete"]
70 ---
71 apiVersion: rbac.authorization.k8s.io/v1beta1
72 kind: RoleBinding
73 metadata:
74   name: {{ include "common.serviceaccountname.appmgr" . }}-{{ include "common.namespace.xapp" . }}-getappconfig
75   namespace: {{ include "common.tillerNameSpace" $ctx }}
76 roleRef:
77   apiGroup: rbac.authorization.k8s.io
78   kind: Role
79   name: {{ include "common.serviceaccountname.appmgr" . }}-{{ include "common.tillerNameSpace" $ctx }}-getappconfig
80 subjects:
81   - kind: ServiceAccount
82     name: {{ include "common.serviceaccountname.appmgr" . }}
83     namespace: {{ include "common.namespace.platform" . }}