Install and use the private registry in the Microk8s integrator

Tram Ho

First, the system I guide in the series will deploy in a VM environment and the images will not be public to the Internet, so I use the private registry.

Activate the registry

I ssh into the VM stg-02 (10.19.2.92) to execute, the child role stg-02 is currently playing the Master role.

After successfully logging into stg-02, we proceed to activate the registry with the command

image.png

After activating the registry, the default persistent volume is 20G to store images, but you can add more to suit your application.

How to use Private Registry

  1. Install Docker Engine on ubuntu 22.04 (you can refer to the source https://docs.docker.com/engine/install/ubuntu/ )
  • Uninstall old version

Set up repository

  • Update the apt package index and install the packages to allow apt to use the repository over HTTPS: sudo apt-get update sudo apt-get install ca-certificates curl gnupg lsb-release
  • Add Docker’s official GPG key:

  • Use the command to set up the repository

Install Docker Engine

  1. Update apt packages

  1. Install Docker Engine, containerd, and Docker Compose.

Configure Insecure registry (Allow push images without SSL)

On the build machine and push machine from Docker we need to add the configuration in the file /etc/docker/daemon.json

add config snippet

image.png

Save and restart the docker service

Now we test the configuration according to the steps:

  1. Pull image Nginx

image.png

  1. tag file image nginx -> 10.19.2.92:32000/big-dog-nginx

image.png

  1. Push image 10.19.2.92:32000/big-dog-nginx to registry

image.png

Microk8s . Configuration

Microk8s 1.23 and later use separate hosts files for each image registration. For the Registry http://10.19.2.92:32000 , the configuration file will be at /var/snap/microk8s/current/args/certs.d/10.19.2.92:32000

First, create the directory and folder if it doesn’t exist:

Then edit the file you just created and make sure it’s correct as follows:

image.png

Save and restart the microk8s service

Deploy and test new image push

  1. Create file big-dog-nginx-all.yaml

  1. Run file big-dog-nginx-all.yaml

image.png

There are 2 ways to test:

  1. Go to port 30039 to check: http://10.19.2.92:30039

image.png

  1. run dashboard to check

image.png

image.png

If you find this post helpful, please give me a like and subscribe to support me. Thank you so much ♥️♥️♥️♥️

Link github for you to copy quickly

Share the news now

Source : Viblo