Scope: How to configure KOBIL Shift deployment to use predefined ServiceAccounts (SA). This allows to run the KOBIL Shift deployment without cluster-admin permission.
Background here is, that the KOBIL Shift deployment by default expects to run in context of a ServiceAccount which is granted to kubernetes cluster admin rights and therefore all required resources and objects could be created. In case from security concerns this could be limited.
Prepare non-cluster-admin service account to deploy Shift operator
Prerequisites
-
Service account
ci-userin namespaceservice-accountswith cluster role binding to default cluster roleadmin. E.g.apiVersion: v1kind: ServiceAccountmetadata:name: ci-usernamespace: service-accounts---apiVersion: rbac.authorization.k8s.io/v1kind: ClusterRoleBindingmetadata:name: ci-user-adminroleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: adminsubjects:- kind: ServiceAccountname: ci-usernamespace: service-accounts -
Namespace
shiftfor the Shift operator deployment.
Extend ci-user's permissions
The following steps must be performed by a cluster admin.
-
Create Cluster role
ks-shift-operatorcontaining additional permissions required by Shift Operator (KOBIL can provide more specific role declaration in detail when required):apiVersion: rbac.authorization.k8s.io/v1kind: ClusterRolemetadata:name: ks-shift-operatorrules:- apiGroups:- shift.kobil.comresources:- '*'verbs:- create- delete- get- list- patch- update- watch -
Create cluster role binding that binds service account
ci-userto cluster roleks-shift-operator:apiVersion: rbac.authorization.k8s.io/v1kind: ClusterRoleBindingmetadata:name: ci-user-ks-shift-operatorroleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: ks-shift-operatorsubjects:- kind: ServiceAccountname: ci-usernamespace: service-accounts
Create the shift-operator service account and required role bindings
The following steps can be performed by the ci-user.
-
Create service account
shift-operatorin namespaceshift.apiVersion: v1kind: ServiceAccountmetadata:name: shift-operatornamespace: shift -
Create role binding in namespace
shiftthat binds service accountshift-operatorto default cluster roleadmin.apiVersion: rbac.authorization.k8s.io/v1kind: RoleBindingmetadata:name: shift-operator-adminnamespace: shiftroleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: adminsubjects:- kind: ServiceAccountname: shift-operatornamespace: shift -
Create role binding in namespace
shiftthat binds service accountshift-operatorto cluster roleks-shift-operator.apiVersion: rbac.authorization.k8s.io/v1kind: RoleBindingmetadata:name: shift-operator-ks-shift-operatornamespace: shiftroleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: ks-shift-operatorsubjects:- kind: ServiceAccountname: shift-operatornamespace: shift
Shift Operator helm chart metaconfiguration / values.yaml
Use the following configuration when deploying Shift operator helm chart to make sure the service account shift-operator prepared in the previous step is used:
pod:
serviceAccount:
create: false
name: "shift-operator"
rbac:
create: false
Update Shift helm chart metaconfiguration / values.yaml
Use the following configuration when deploying Shift helm chart to make sure the service account/SA shift-service prepared in the namespace is used:
NOTE: This update have to be put into any service section in the Shift helm chart each
<service-name-section>:
valuesOverride:
pod:
serviceAccount:
create: false
name: "shift-service"
createRbac: false