Skip to main content

Your submission was sent successfully! Close

Thank you for signing up for our newsletter!
In these regular emails you will find the latest updates from Canonical and upcoming events where you can meet our team.Close

Thank you for contacting us. A member of our team will be in touch shortly. Close

  1. Blog
  2. Article

Peter Jose De Sousa
on 8 October 2019

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.

Prerequisites

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 --image=registry.gitlab.com/<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

Conclusions

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.

Related posts


Mita Bhattacharya
6 November 2024

Meet Canonical at KubeCon + CloudNativeCon North America 2024

Cloud and server Article

We are ready to connect with the pioneers of open-source innovation! Canonical, the force behind Ubuntu, is returning as a gold sponsor at KubeCon + CloudNativeCon North America 2024.  This premier event, hosted by the Cloud Native Computing Foundation, brings together the brightest minds in open source and cloud-native technologies. From ...


Hugo Huang
5 December 2023

How to use Ubuntu in GKE on nodes and in containers

Cloud and server Article

Google Kubernetes Engine (GKE) traces its roots back to Google’s development of Borg in 2004, a Google internal system managing clusters and applications. In 2014, Google introduced Kubernetes, an open-source platform based on Borg’s principles, gaining rapid popularity for automating containerized application deployment. In 2015, Google ...


Michael C. Jaeger
29 April 2024

Kubernetes backups just got easier with the CloudCasa charm from Catalogic

Charms Article

For a native integration for Canonical’s Kubernetes platform, Juju was the perfect fit, and the charm makes consuming CloudCasa seamless for users. ...