Skip to content

Commit ff4058d

Browse files
committed
RBAC support
With this change deis-monitor-telegraf became available to work in RBAC-only clusters Works with both Kubernetes 1.5 and 1.6 (see templates/_helpers.tmpl for details) Actually tested with 1.5.7 and 1.6.2 ClusterRole allows deis-monitor-telegraf: - pods: get
1 parent 115ea92 commit ff4058d

4 files changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- if (.Values.global.use_rbac) -}}
2+
{{- if (.Capabilities.APIVersions.Has (include "rbacAPIVersion" .)) -}}
3+
kind: Role
4+
apiVersion: {{ template "rbacAPIVersion" . }}
5+
metadata:
6+
name: deis-monitor-telegraf
7+
labels:
8+
app: deis-monitor-telegraf
9+
heritage: deis
10+
rules:
11+
- apiGroups: [""]
12+
resources: ["pods"]
13+
verbs: ["get"]
14+
{{- end -}}
15+
{{- end -}}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{- if (.Values.global.use_rbac) -}}
2+
{{- if (.Capabilities.APIVersions.Has (include "rbacAPIVersion" .)) -}}
3+
kind: RoleBinding
4+
apiVersion: {{ template "rbacAPIVersion" . }}
5+
metadata:
6+
name: deis-monitor-telegraf
7+
labels:
8+
app: deis-monitor-telegraf
9+
heritage: deis
10+
roleRef:
11+
apiGroup: rbac.authorization.k8s.io
12+
kind: Role
13+
name: deis-monitor-telegraf
14+
subjects:
15+
- kind: ServiceAccount
16+
name: deis-monitor-telegraf
17+
{{- end -}}
18+
{{- end -}}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{/*
2+
Set apiVersion based on Kubernetes version
3+
*/}}
4+
{{- define "rbacAPIVersion" -}}
5+
{{- if ge .Capabilities.KubeVersion.Minor "6" -}}
6+
rbac.authorization.k8s.io/v1beta1
7+
{{- else -}}
8+
rbac.authorization.k8s.io/v1alpha1
9+
{{- end -}}
10+
{{- end -}}

charts/monitor/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,5 @@ global:
4949
# - on-cluster: Run Redis within the Kubernetes cluster
5050
# - off-cluster: Run Redis outside the Kubernetes cluster (configure in loggerRedis section)
5151
logger_redis_location: "on-cluster"
52+
# Role-Based Access Control for Kubernetes >= 1.5
53+
use_rbac: false

0 commit comments

Comments
 (0)