Your submission was sent successfully! Close

Container registry for Kubernetes with GitLab

Container orchestration solutions such as Kubernetes allow development teams to be quick and agile with their software deployments.

One of the main features of Kubernetes is the ability to reduce the deployment of version piece of software down to a simple image tag which can be applied at the end of a command.” – said Tytus Kurek, Product Manager for Charmed Kubernetes at Canonical.

This opens the doors to streamlined deployments but creates another problem. How do we streamline? We can do this manually, but it’s not very streamlined. Or we can do this automatically, but we need to be smart. We can’t just deploy as soon as a new version is released. We need to check it first. This is where a container registry and CI/CD come in.


Before we get started, we have to find ourselves a healthy Kubernetes cluster. Canonical offers both Charmed Kubernetes and MicroK8s solutions which are fully compliant with the upstream Kubernetes project. While Charmed Kubernetes is suitable for large-scale deployments in data centers or public clouds, MicroK8s was designed for workstation and edge appliances. You can install MicroK8s on your laptop at no cost by following this quick tutorial. If you’re on Windows or Mac you may need to follow the Multipass guide first to get a VM with Ubuntu.

Apart from Kubernetes, we will also need GitLab – a web-based DevOps lifecycle tool. GitLab has the ability to store up to 10 GB in a container registry for projects. You can incorporate the building of these containers into your own CI/CD pipeline or you can use Gitlab’s own CI/CD functionality to do this for you.

Setting up the container registry

Creating the container registry on GitLab involves completing the following steps:

  • Create a project – you can create a new project or use an existing one.
  • Create a Dockerfile – create a Dockerfile for an image to be built and stored in GitLab.
  • Enable Container Registry – enable Container Registry feature in GitLab’s settings.
  • Build an image – build an image from the Dockerfile; make sure you can successfully launch a container from this image.
  • Push the image – push the image to the project’s repository in GitLab.
  • Create a token – create a token that will be used by Kubernetes when pulling the image from GitLab.
  • Pull the image – at this point, you can start using images stored in GitLab when creating deployments in Kubernetes.

This is now as simple as executing the following command:

kubectl create deployment gitlabrepositories<YOUR_USERNAME>/gitlabregistries

As the whole process requires a bunch of manual steps, we decided to create a detailed tutorial that you can follow step-by-step to get your container registry for Kubernetes created in GitLab.

Take The Tutorial


Using GitLab as a container registry for Kubernetes allows you to streamline your application deployments. You can check out GitLab’s documentation on how to take your newly learned skills and apply them to your own CI/CD or create one in GitLab.

kubernetes logo

What is Kubernetes?

Kubernetes, or K8s for short, is an open source platform pioneered by Google, which started as a simple container orchestration tool but has grown into a platform for deploying, monitoring and managing apps and services across clouds.

Learn more about Kubernetes ›

Newsletter signup

Select topics you're
interested in

In submitting this form, I confirm that I have read and agree to Canonical's Privacy Notice and Privacy Policy.

Related posts

Kubernetes for Finservs – Unlocking success in digital transformations

The global health crisis has accelerated the digital transformation within the financial services industry. A McKinsey report highlights that “In a...

Application composability – a cloud computing perspective

Let’s remember the time in the 2000s when companies introduced their cloud computing offerings at a large scale. New services were put into the popular IaaS,...

Kubernetes infographic: usage of cloud native technology in 2021

2021 has been an interesting year for the Kubernetes and cloud native ecosystem.  Due to the pandemic, cloud adoption saw a big spike in adoption. As the year...