Skip to content

Commit 20bbfb1

Browse files
authored
Merge pull request #513 from Bregor/features/rbac
RBAC support
2 parents a6403e7 + ce77ee6 commit 20bbfb1

6 files changed

Lines changed: 85 additions & 0 deletions

File tree

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 -}}
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: ClusterRole
4+
apiVersion: {{ template "rbacAPIVersion" . }}
5+
metadata:
6+
name: deis:deis-builder
7+
labels:
8+
app: deis-builder
9+
heritage: deis
10+
rules:
11+
- apiGroups: [""]
12+
resources: ["namespaces"]
13+
verbs: ["list"]
14+
{{- end -}}
15+
{{- end -}}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{- if (.Values.global.use_rbac) -}}
2+
{{- if (.Capabilities.APIVersions.Has (include "rbacAPIVersion" .)) -}}
3+
kind: ClusterRoleBinding
4+
apiVersion: {{ template "rbacAPIVersion" . }}
5+
metadata:
6+
name: deis:deis-builder
7+
labels:
8+
app: deis-builder
9+
heritage: deis
10+
roleRef:
11+
apiGroup: rbac.authorization.k8s.io
12+
kind: ClusterRole
13+
name: deis:deis-builder
14+
subjects:
15+
- kind: ServiceAccount
16+
name: deis-builder
17+
namespace: {{ .Release.Namespace }}
18+
{{- end -}}
19+
{{- end -}}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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-builder
7+
labels:
8+
app: deis-builder
9+
heritage: deis
10+
rules:
11+
- apiGroups: [""]
12+
resources: ["secrets"]
13+
verbs: ["create", "update", "delete"]
14+
- apiGroups: [""]
15+
resources: ["pods"]
16+
verbs: ["create", "get", "watch", "list"]
17+
- apiGroups: [""]
18+
resources: ["pods/log"]
19+
verbs: ["get"]
20+
{{- end -}}
21+
{{- 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-builder
7+
labels:
8+
app: deis-builder
9+
heritage: deis
10+
roleRef:
11+
apiGroup: rbac.authorization.k8s.io
12+
kind: Role
13+
name: deis-builder
14+
subjects:
15+
- kind: ServiceAccount
16+
name: deis-builder
17+
{{- end -}}
18+
{{- end -}}

charts/builder/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ global:
1212
# - true: The deis controller will now create Kubernetes ingress rules for each app, and ingress rules will automatically be created for the controller itself.
1313
# - false: The default mode, and the default behavior of Deis workflow.
1414
experimental_native_ingress: false
15+
# Role-Based Access Control for Kubernetes >= 1.5
16+
use_rbac: false

0 commit comments

Comments
 (0)