Kubernetes and GitLab Docker Registry Access
Problem Statement
We run multiple Kubernetes Cluster (EKS based) in our production environment. Today we have stored all Docker images in the included GitLab Container Registry. The registry itself has stored all data in S3. In the beginning it was not possible to create new deploy tokens via API, so we decided to have a dedicated GitLab Bot User who has access to all projects in use.
For now we have two problems:
- since the Container Registry is not high-available, we have a massiv single-point of failure called GitLab [1]
- deploy tokens are GitLab project based or group based, since we have workloads with multiple containers per pod and we bound a ImagePullSecret to the default service account, with deploy tokens we have to move the imagePullSecret into the deployment definition (we don't like this)
What we want is the following:
- a Container Registry integrated into our GitLab workflows but highly available (EC2 instances in ASG, S3 backend)
- a Container Registry authentication module without dependency to the GitLab API [2]
- a single imagePullSecrets per k8s Namespace with access to a list of repositories
[1] We know, that we can move to GitLab Geo with the premium licence, but we a active/standby setup doesn't provide enough availability and reliability we need. [2] Our cluster are pretty dynamic in terms of capacity. We run node autoscaler and pod autoscaler to manage our load. We also run the descheduler. This means, we have hundreds of image pulls per day and all rely on the availability of GitLab.
Proposed Solution (we want to verify this with you)
We run multiple EC2 nodes in a ASG behind and ELB. Each node runs the Docker Container Registry (S3 storage backend) and a simple go http service (we call it CRA = container-registry-auth). Instead of https://<gitserver>/jwt/auth
, we use our CRA
here. The CRA has two authentication modes:
A) proxy mode to GitLab (to allow the standard GitLab authentication procedures) B) a JWT based authentication / authorisation mode
The JWT is issued by an internal provisioning tool (this tool is creating namespaces, managing AWS policies, etc) and it is signed by an RSA private key. It also included the the authorisation information (list of repositories). The CRA is validating (authentication) with the RSA public key the JWT and is authorising the docker pull request (match the request repository to one of the repositories in the JWT).
Benefits
- no direct dependency to GitLab during docker login and docker pull
- a single JWT token can authorise the access to multiple repositories
Problems we see
- there is a fork of the Docker Container Registry and we are not sure about the direction of this move and what implication this in the future might have
- we believe as long as we run in a read-only mode here, we will not run in any consistency issues (needs to be validated)
- in GitLab Geo there is the need for configuring "registry notification" - not sure why this is need and how this is usable with dynamic number of Docker Container Registries (ASG)
Thanks for feedback.