Skip to content

Commit

Permalink
examples: add RBAC manifest files example
Browse files Browse the repository at this point in the history
Manifest files for roles and deploying the Habitat operator, to be used
for Kubernetes cluster where RBAC is enabled.
  • Loading branch information
Lili Cosic committed Nov 14, 2017
1 parent dfc5f0b commit 3bee9d1
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
14 changes: 14 additions & 0 deletions examples/rbac/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# RBAC Habitat example

[RBAC](https://kubernetes.io/docs/admin/authorization/rbac/) stands for role-based access control, and in Kubernetes it's aimed at limiting the permissions within the cluster. The Habitat operator requires some access within the cluster, for example for creating and managing the `CRD` and all the other necessary resources. This is where the following example comes in. If the API server is started with the `--authorization-mode=RBAC` flag, then the following roles must be created for the Habitat operator to function properly.

## Workflow

Before deploying the Habitat operator inside your cluster the following roles must be created:

kubectl apply -f examples/rbac/rbac.yml

Once those roles were successfully created the Habitat operator can be deployed in the cluster:

kubectl apply -f examples/rbac/habitat.yml

15 changes: 15 additions & 0 deletions examples/rbac/habitat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: habitat-operator
spec:
replicas: 1
template:
metadata:
labels:
name: habitat-operator
spec:
containers:
- name: habitat-operator
image: kinvolk/habitat-operator:v0.1.0
serviceAccountName: habitat-operator
54 changes: 54 additions & 0 deletions examples/rbac/rbac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: habitat-operator
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: habitat-operator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: habitat-operator
subjects:
- kind: ServiceAccount
name: habitat-operator
namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: habitat-operator
rules:
- apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- apiGroups:
- habitat.sh
resources:
- habitats
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- apiGroups:
- apps
resources:
- deployments
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- apiGroups: [""]
resources:
- configmaps
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- apiGroups: [""]
resources:
- secrets
verbs: ["get"]
- apiGroups: [""]
resources:
- pods
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources:
- namespaces
verbs: ["list"]

0 comments on commit 3bee9d1

Please sign in to comment.