Skip to content

Instantly share code, notes, and snippets.

@mikamboo
Last active April 26, 2020 21:53
Show Gist options
  • Save mikamboo/b259d309be904acc49c35da88256bda4 to your computer and use it in GitHub Desktop.
Save mikamboo/b259d309be904acc49c35da88256bda4 to your computer and use it in GitHub Desktop.
Kubernetes : Gitlab cluster-admin ServiceAccount
title date author cover
Kubernetes : Gitlab cluster-admin ServiceAccount
2020-03-01
mikamboo

Kubernetes : Gitlab cluster-admin ServiceAccount

Gitlab k8s integration require to use a kube-system namespace service account with cluster-admin privileges.

Service account

A Service Account can be created manually through API calls kubectl apply ... with following yaml :

apiVersion: v1
kind: ServiceAccount
metadata:
  name: gitlab-admin
  namespace: kube-system

Cluster role biding

Once, ServiceAccount created, we have to link it to a an existing role. For this case cluster-admin cluster role exists by default. We can bind it to our ServiceAccount with following configuration :

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: gitlab-admin
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: gitlab-admin
  namespace: kube-system

Single ligne apply

This gist contains gitlab-admin-sa.yaml file that we can use to create above ServiAccount and ClusterRoleBing :

kubectl apply -f https://git.io/Jvbo4
{
"title": "Kubernetes : Gitlab cluster-admin ServiceAccount"
}
apiVersion: v1
kind: ServiceAccount
metadata:
name: gitlab-admin
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: gitlab-admin
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: gitlab-admin
namespace: kube-system
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment