Using Private Registry with OVHcloud Managed Kubernetes
In this tutorial we are going to guide you in using images from OVHcloud Managed Private Registry service on OVHcloud Managed Kubernetes clusters.
Before you begin
This tutorial presupposes that you already have a working OVHcloud Managed Kubernetes cluster, and some basic knowledge of how to operate it. If you want to know more on those topics, please look at the deploying a Hello World application documentation.
You also need to have a working OVHcloud Managed Private Registry and have followed the guides on creating a private registry, connecting to the UI, managing users and projects and creating and using private images.
We will specifically suppose you have followed the last one and you have a hello-ovh image on your private registry.
Create Kubernetes Secret
Kubernetes needs to have access to the private registry to pull images from it, so you need to store the private registry credentials in a Kubernetes Secret. There are 2 ways to create the registry credentials secret. Chose the solution you prefer.
1. Create a Secret based on existing Docker credentials
Log in to your OVHcloud Managed Private Registry
In order to pull a private image from your private registry, you must authenticate with it using docker login.
For my private registry:
The login process creates or updates a config.json file that holds an authorization token.
View the config.json file:
Creating the Secret
Let's create a Secret of docker-registry type.
You will use this Secret to authenticate with your private registry to pull a private image.
If you already ran docker login, you can copy that credential into Kubernetes:
For my private registry:
You can check the secret has been correctly deployed in your Kubernetes cluster:
Secrets are encoded in base64 and automatically decoded when they are attached to a Pod.
2. Create a Secret by providing credentials on the command line
Let's create a Secret of docker-registry type.
You will use this Secret to authenticate with your private registry to pull a private image:
For my private registry:
You can check the secret has been correctly deployed in your Kubernetes cluster:
Secrets are encoded in base64 and automatically decoded when they are attached to a Pod.
Deploying an image
The first step to deploy a Docker image in a Kubernetes cluster is to write a YAML manifest. Let's call it hello-ovh.yaml:
Replace [YOUR_PRIVATE_REGISTRY_URL] and [YOUR_PROJECT] with your private registry URL and your project name, for example for my private registry it will be: cx6ds30d.gra7.container-registry.ovh.net/private/hello-ovh:1.0.0
And then we can apply the file:
After applying the YAML file, a new hello-world service and the corresponding hello-world-deployment deployment are created:
Our Pod is correctly running, so Kubernetes has pulled the image from your private registry with success.
Go further
To have an overview of OVHcloud Managed Private Registry service, you can go to the OVHcloud Managed Private Registry site.
Join our community of users on https://community.ovh.com/en/.