Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
RBAC support (#1292)
Browse files Browse the repository at this point in the history
With this change deis-controller became available to work in RBAC-only clusters
  • Loading branch information
Bregor authored and vdice committed May 31, 2017
1 parent 4b015cd commit 0397cd1
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 0 deletions.
10 changes: 10 additions & 0 deletions charts/controller/templates/_helpers.tmpl
@@ -0,0 +1,10 @@
{{/*
Set apiVersion based on Kubernetes version
*/}}
{{- define "rbacAPIVersion" -}}
{{- if ge .Capabilities.KubeVersion.Minor "6" -}}
rbac.authorization.k8s.io/v1beta1
{{- else -}}
rbac.authorization.k8s.io/v1alpha1
{{- end -}}
{{- end -}}
59 changes: 59 additions & 0 deletions charts/controller/templates/controller-clusterrole.yaml
@@ -0,0 +1,59 @@
{{- if (.Values.global.use_rbac) -}}
{{- if (.Capabilities.APIVersions.Has (include "rbacAPIVersion" .)) -}}
kind: ClusterRole
apiVersion: {{ template "rbacAPIVersion" . }}
metadata:
name: deis:deis-controller
labels:
app: deis-controller
heritage: deis
rules:
- apiGroups: [""]
resources: ["namespaces"]
verbs: ["get", "list", "create", "delete"]
- apiGroups: [""]
resources: ["services"]
verbs: ["get", "list", "create", "update", "delete"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list"]
- apiGroups: [""]
resources: ["events"]
verbs: ["list", "create"]
- apiGroups: [""]
resources: ["secrets"]
verbs: ["list", "get", "create", "update", "delete"]
- apiGroups: [""]
resources: ["replicationcontrollers"]
verbs: ["get", "list", "create", "update", "delete"]
- apiGroups: [""]
resources: ["replicationcontrollers/scale"]
verbs: ["get", "update"]
- apiGroups: [""]
resources: ["pods/log"]
verbs: ["get"]
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "delete"]
- apiGroups: [""]
resources: ["resourcequotas"]
verbs: ["get", "create"]
- apiGroups: ["extensions"]
resources: ["replicasets"]
verbs: ["get", "list", "delete", "update"]
- apiGroups: ["extensions", "apps"]
resources: ["deployments"]
verbs: ["get", "list", "create", "update", "delete"]
- apiGroups: ["extensions"]
resources: ["deployments/scale", "replicasets/scale"]
verbs: ["get", "update"]
- apiGroups: ["extensions", "autoscaling"]
resources: ["horizontalpodautoscalers"]
verbs: ["get", "list", "create", "update", "delete"]
{{ if .Values.global.experimental_native_ingress }}
- apiGroups: ["extensions"]
resources: ["ingresses"]
verbs: ["get", "list", "watch", "create", "update", "delete"]
{{- end -}}
{{- end -}}
{{- end -}}
19 changes: 19 additions & 0 deletions charts/controller/templates/controller-clusterrolebinding.yaml
@@ -0,0 +1,19 @@
{{- if (.Values.global.use_rbac) -}}
{{- if (.Capabilities.APIVersions.Has (include "rbacAPIVersion" .)) -}}
kind: ClusterRoleBinding
apiVersion: {{ template "rbacAPIVersion" . }}
metadata:
name: deis:deis-controller
labels:
app: deis-controller
heritage: deis
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: deis:deis-controller
subjects:
- kind: ServiceAccount
name: deis-controller
namespace: {{ .Release.Namespace }}
{{- end -}}
{{- end -}}
2 changes: 2 additions & 0 deletions charts/controller/values.yaml
Expand Up @@ -55,3 +55,5 @@ global:
# - true: The deis controller will now create Kubernetes ingress rules for each app, and ingress rules will automatically be created for the controller itself.
# - false: The default mode, and the default behavior of Deis workflow.
experimental_native_ingress: false
# Role-Based Access Control for Kubernetes >= 1.5
use_rbac: false

0 comments on commit 0397cd1

Please sign in to comment.