Skip to content

Commit

Permalink
fix prometheus need kubernetes all namespace access control bug (apac…
Browse files Browse the repository at this point in the history
…he#5659)

Fixes apache#5658 

### Motivation
Fix prometheus access control not enough in kubernetes

### Modifications
Add service account for pulsar cluster prometheus, service account binding cluster role, cluster role have  access control.
  • Loading branch information
sky-big authored and sijie committed Nov 21, 2019
1 parent f68ee8b commit 0565c78
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 0 deletions.
42 changes: 42 additions & 0 deletions deployment/kubernetes/aws/monitoring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,47 @@
# under the License.
#

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: prometheus-cluster-role
rules:
- apiGroups: [""]
resources:
- nodes
- nodes/proxy
- services
- endpoints
- pods
verbs: ["get", "list", "watch"]
- nonResourceURLs: ["/metrics"]
verbs: ["get"]

---

apiVersion: v1
kind: ServiceAccount
metadata:
name: prometheus-service-account
namespace: default

---

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: prometheus-cluster-role-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: prometheus-cluster-role
subjects:
- kind: ServiceAccount
name: prometheus-service-account
namespace: default

---

apiVersion: v1
kind: ConfigMap
metadata:
Expand Down Expand Up @@ -119,6 +160,7 @@ spec:
app: pulsar
component: prometheus
spec:
serviceAccount: prometheus-service-account
containers:
- name: prometheus
image: prom/prometheus:v1.6.3
Expand Down
42 changes: 42 additions & 0 deletions deployment/kubernetes/generic/k8s-1-9-and-above/monitoring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,47 @@
# under the License.
#

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: prometheus-cluster-role
rules:
- apiGroups: [""]
resources:
- nodes
- nodes/proxy
- services
- endpoints
- pods
verbs: ["get", "list", "watch"]
- nonResourceURLs: ["/metrics"]
verbs: ["get"]

---

apiVersion: v1
kind: ServiceAccount
metadata:
name: prometheus-service-account
namespace: default

---

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: prometheus-cluster-role-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: prometheus-cluster-role
subjects:
- kind: ServiceAccount
name: prometheus-service-account
namespace: default

---

apiVersion: v1
kind: ConfigMap
metadata:
Expand Down Expand Up @@ -97,6 +138,7 @@ spec:
app: pulsar
component: prometheus
spec:
serviceAccount: prometheus-service-account
containers:
- name: prometheus
image: prom/prometheus:v1.6.3
Expand Down
42 changes: 42 additions & 0 deletions deployment/kubernetes/generic/original/monitoring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,47 @@
# under the License.
#

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: prometheus-cluster-role
rules:
- apiGroups: [""]
resources:
- nodes
- nodes/proxy
- services
- endpoints
- pods
verbs: ["get", "list", "watch"]
- nonResourceURLs: ["/metrics"]
verbs: ["get"]

---

apiVersion: v1
kind: ServiceAccount
metadata:
name: prometheus-service-account
namespace: default

---

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: prometheus-cluster-role-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: prometheus-cluster-role
subjects:
- kind: ServiceAccount
name: prometheus-service-account
namespace: default

---

apiVersion: v1
kind: ConfigMap
metadata:
Expand Down Expand Up @@ -74,6 +115,7 @@ spec:
app: pulsar
component: prometheus
spec:
serviceAccount: prometheus-service-account
containers:
- name: prometheus
image: prom/prometheus:v1.6.3
Expand Down
42 changes: 42 additions & 0 deletions deployment/kubernetes/google-kubernetes-engine/monitoring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,47 @@
# under the License.
#

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: prometheus-cluster-role
rules:
- apiGroups: [""]
resources:
- nodes
- nodes/proxy
- services
- endpoints
- pods
verbs: ["get", "list", "watch"]
- nonResourceURLs: ["/metrics"]
verbs: ["get"]

---

apiVersion: v1
kind: ServiceAccount
metadata:
name: prometheus-service-account
namespace: default

---

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: prometheus-cluster-role-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: prometheus-cluster-role
subjects:
- kind: ServiceAccount
name: prometheus-service-account
namespace: default

---

apiVersion: v1
kind: ConfigMap
metadata:
Expand Down Expand Up @@ -91,6 +132,7 @@ spec:
app: pulsar
component: prometheus
spec:
serviceAccount: prometheus-service-account
containers:
- name: prometheus
image: prom/prometheus:v1.6.3
Expand Down

0 comments on commit 0565c78

Please sign in to comment.