Sign inSign up

numberly/gitlab2rbac

By numberly

•Updated over 5 years ago

gitlab2rbac ensures that your Kubernetes cluster users have the same permissions than on GitLab

Image
1

100K+

numberly/gitlab2rbac repository overview

⁠gitlab2rbac

This is a beta version. gitlab2rbac is still undergoing final testing before its official release.

gitlab2rbac ensures that your Kubernetes cluster users have the same permissions than on GitLab.

It takes GitLab Permissions⁠ by project as input and generates RBAC⁠ objects inside Kubernetes.

graph

⁠Installation

⁠Requirements

Before anything else, gitlab2rbac requires:

⁠Configuration

gitlab2rbac needs a namespace, cluster roles and cluster role bindings. Create them with:

$ kubectl apply -f https://raw.githubusercontent.com/numberly/gitlab2rbac/master/deploy/configuration.yaml

You will then need to create a ConfigMap⁠ that contains all the useful information for gitlab2rbac:

cat <<EOF | kubectl create -f -
apiVersion: v1
kind: ConfigMap
metadata:
  name: gitlab2rbac
  namespace: gitlab2rbac
data:
  GITLAB_URL: https://{{ your GitLab instance URL }}
  GITLAB_PRIVATE_TOKEN: {{ your GitLab private token }}
  KUBERNETES_LOAD_INCLUSTER_CONFIG: "True"
EOF
⁠Deployment

Finally, just apply the manifest:

$ kubectl apply -f https://raw.githubusercontent.com/numberly/gitlab2rbac/master/deploy/gitlab2rbac.yaml

This will deploy gitlab2rbac to your cluster, under the gitlab2rbac namespace. The components in the manifest are:

  • the deployment, which is the cluster-wide controller that handles RBAC policies
  • the service account and the RBAC permissions that the controller need to function

⁠Running locally

⁠Requirements
  • Python 3 (should also work with Python 2 but it's not supported)
  • Virtualenv (recommended)
⁠Setup

Even if gitlab2rbac doesn't run inside Kubernetes, it needs a cluster with existing cluster roles. Create them with:

$ kubectl apply -f https://raw.githubusercontent.com/numberly/gitlab2rbac/master/deploy/configuration.yaml

Then you can clone the repository, install the dependencies and run gitlab2rbac:

$ git clone https://github.com/numberly/gitlab2rbac.git
$ cd gitlab2rbac
$ virtualenv .venv && source .venv/bin/activate
(.venv) $ pip install -r requirements.txt
(.venv) $ GITLAB_URL={{ your GitLab instance URL }} GITLAB_PRIVATE_TOKEN={{ your GitLab private token }} python gitlab2rbac.py

⁠Default configuration

⁠Roles description
RoleUse casesTypical examples
GuestInspirationSomeone from another team
ReporterComplete overview, testsProject manager, marketing
DeveloperDeployment, debugEngineer, technical project manager
MaintainerSensitive configurationsLead/senior engineer
⁠RBAC grid

What we mean by R and W is defined by Kubernetes API verbs:

  • Read (R): get, list, watch
  • Write (W): create, update, patch, delete, deletecollection
⁠Cluster-wide

Any authenticated user has access to those cluster-wide resources:

  • apiservices
  • componentstatuses
  • namespaces
  • nodes

Any admin on GitLab is an admin of the Kubernetes cluster.

⁠Workload
ResourceGuestReporterDeveloperMaintainer
cronjobsRRR+WR+W
daemonsetsRRR+WR+W
deploymentsRRR+WR+W
horizontalpodautoscalersRRR+WR+W
ingressesRRR+WR+W
jobsRRR+WR+W
podsRRR+WR+W
replicasetsRRR+WR+W
replicationcontrollersRRR+WR+W
servicesRRR+WR+W
statefulsetsRRR+WR+W
verticalpodautoscalersRRR+WR+W
eventsRRR+W
⁠Actions
ResourceGuestReporterDeveloperMaintainer
pods/logR+WR+WR+W
pods/portforwardR+WR+WR+W
deployments/rollbackR+WR+W
deployments/scaleR+WR+W
pods/attachR+WR+W
pods/execR+WR+W
replicasets/scaleR+WR+W
replicationcontrollers/scaleR+WR+W
statefulsets/scaleR+WR+W
⁠Setup
ResourceGuestReporterDeveloperMaintainer
configmapsRRR+WR+W
endpointsRRR+WR+W
networkpoliciesRRR+WR+W
persistentvolumeclaimsRRR+WR+W
persistentvolumeclaims/statusRRR+WR+W
poddisruptionbudgetsRRR+WR+W
poddisruptionbudgets/statusRRR+WR+W
serviceaccountsRRR+WR+W
certificatesR+WR+W
secretsR+WR+W
limitrangesRR+W
resourcequotasRR+W
rolebindingsRR+W
rolesRR+W

⁠Advanced configuration

gitlab2rbac supports multiple environment variables for advanced configuration:

FlagDescriptionDefault
GITLAB2RBAC_FREQUENCYUpdate interval in seconds.60
GITLAB_ADMINS_GROUPBase your k8s admins on GitLab namespace (None means GitLab administrators).None
GITLAB_GROUPS_SEARCHLimit to those groups (separated by commas, empty means all groups).gitlab2rbac
GITLAB_NAMESPACE_GRANULARITYWhether to get permissions from GitLab projects or groups.project
GITLAB_PRIVATE_TOKENConfigure gitlab API token.
GITLAB_TIMEOUTTimeout for GitLab operations, in seconds.10
GITLAB_URLConfigure gitlab API target.
KUBERNETES_AUTO_CREATEReplicate GitLab groups/projects as Kubernetes namespaces.False
KUBERNETES_LOAD_INCLUSTER_CONFIGLoad configuration inside Kubernetes when gitlab2rbac runs as a pod.False
KUBERNETES_TIMEOUTTimeout for Kubernetes operations, in seconds.10

⁠License

MIT

Tag summary

Content type

Image

Digest

Size

332.6 MB

Last updated

over 5 years ago

docker pull numberly/gitlab2rbac