/
apm_es_kibana_rbac.yaml
120 lines (120 loc) · 3.11 KB
/
apm_es_kibana_rbac.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# This file contains an example of Roles, RoleBindings and ServiceAccount which allow the associations to be established
# between resources living in different namespaces if the access control between resources across namespaces is enabled.
# This example is only valid if ECK is started with the related option.
# See https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-operator-config.html.
---
apiVersion: v1
kind: Namespace
metadata:
name: kibana-ns
---
apiVersion: v1
kind: Namespace
metadata:
name: elasticsearch-ns
---
apiVersion: v1
kind: Namespace
metadata:
name: apmserver-ns
---
# Create a Role at the cluster level to access some Elasticsearch clusters.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: elasticsearch-association
rules:
- apiGroups:
- elasticsearch.k8s.elastic.co
resources:
- elasticsearches
# It is also possible to do some fine grain filtering with some per cluster roles
# resourceNames:
# - elasticsearch-sample
# - an-other-elasticsearch-cluster
verbs:
- get # association is allowed if a resource can "get" the remote one
---
# This is the service account used by Kibana
apiVersion: v1
kind: ServiceAccount
metadata:
name: kibana-user
namespace: kibana-ns
---
# This RoleBinding gives the permission to Kibana to access the Elasticsearch cluster
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: allow-kibana-from-remote-namespace
namespace: elasticsearch-ns
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: elasticsearch-association
subjects:
- kind: ServiceAccount
name: kibana-user
namespace: kibana-ns
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: apmserver-user
namespace: apmserver-ns
---
# This RoleBinding gives the permission to ApmServer to access the Elasticsearch cluster
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: allow-apmserver-from-remote-namespace
namespace: elasticsearch-ns
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: elasticsearch-association
subjects:
- kind: ServiceAccount
name: apmserver-user
namespace: apmserver-ns
---
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: elasticsearch-sample
namespace: elasticsearch-ns
spec:
version: 7.16.2
nodeSets:
- name: default
count: 1
config:
node.store.allow_mmap: false
---
apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana
metadata:
name: kibana-sample
namespace: kibana-ns
spec:
version: 7.16.2
count: 1
elasticsearchRef:
name: "elasticsearch-sample"
namespace: "elasticsearch-ns"
# Service account used by Kibana to get access to the Elasticsearch cluster
serviceAccountName: kibana-user
---
apiVersion: apm.k8s.elastic.co/v1
kind: ApmServer
metadata:
name: apm-apm-sample
namespace: apmserver-ns
spec:
version: 7.16.2
count: 1
elasticsearchRef:
name: "elasticsearch-sample"
namespace: "elasticsearch-ns"
# Service account used by the APM Server to get access to the Elasticsearch cluster
serviceAccountName: apmserver-user