Service Account, Role and RoleBinding Creation

In this section, you will learn to create a service account, role and rolebinding resources.

A sample command to create the resources is as follows:

kubectl -n <ocudr-namespace> create -f ocudr-sample-resource-template.yaml

A sample template to create the resources is as follows:

Note:

You need to update the <helm-release> and <namespace> values with its respective ocudr namespace and ocudr helm release name.
#
# Sample template start
#
apiVersion: v1
kind: ServiceAccount
metadata:
  name: <helm-release>-serviceaccount
  namespace: <namespace>
---
 
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: <helm-release>-role
  namespace: <namespace>
rules:
- apiGroups:
  - "" # "" indicates the core API group
  resources:
  - services
  - configmaps
  - pods
  - secrets
  - endpoints
  verbs:
  - get
  - watch
  - list
---
 
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
  name: <helm-release>-rolebinding
  namespace: <namespace>
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: <helm-release>-role
subjects:
- kind: ServiceAccount                                  
  name:  <helm-release>-serviceaccount
  namespace: <namespace>
 
#
# Sample template end
#