Ubuntu 20.04
Sponsored Link

MicroK8s : Enable Registry2020/08/04

 
To enable MicroK8s built-in Registry, Configure like follows.
[1] Enable built-in Registry on primary Node.
After enabling, [kube-proxy] listens on [0.0.0.0:32000].
# enable registry with backend storage size 30G

# default size is 20G if it's not specified

# possible to specify the size on MicroK8s 1.18.3 or later

root@dlp:~#
microk8s enable registry:size=30Gi

Enabling default storage class
deployment.apps/hostpath-provisioner created
storageclass.storage.k8s.io/microk8s-hostpath created
serviceaccount/microk8s-hostpath created
clusterrole.rbac.authorization.k8s.io/microk8s-hostpath created
clusterrolebinding.rbac.authorization.k8s.io/microk8s-hostpath created
Storage will be available soon
Enabling the private registry
Applying registry manifest
namespace/container-registry created
persistentvolumeclaim/registry-claim created
deployment.apps/registry created
service/registry created
The registry is enabled
The size of the persistent volume is 30Gi

# [registry] pod starts

root@dlp:~#
microk8s kubectl get pods -A

NAMESPACE            NAME                                        READY   STATUS    RESTARTS   AGE
container-registry   registry-7cf58dcdcc-bbdz2                   1/1     Running   1          127m
kube-system          coredns-588fd544bf-g9frb                    1/1     Running   2          20h
kube-system          dashboard-metrics-scraper-59f5574d4-67tjr   1/1     Running   2          20h
kube-system          hostpath-provisioner-75fdc8fccd-nzld5       1/1     Running   1          127m
kube-system          kubernetes-dashboard-6d97855997-p5hzj       1/1     Running   2          20h
kube-system          metrics-server-c65c9d66-zzdl6               1/1     Running   2          20h
[2] After enabling Registry, it's possible to use it with common operation.
root@dlp:~#
docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
httpd               latest              9d2a0c6e5b57        12 days ago         166MB

# tag and push

root@dlp:~#
docker tag 9d2a0c6e5b57 localhost:32000/httpd:registry

root@dlp:~#
docker push localhost:32000/httpd

The push refers to repository [localhost:32000/httpd]
4e6cfff37f35: Pushed
6078e6411b20: Pushed
a292ec64305a: Pushed
38b213d315e5: Pushed
95ef25a32043: Pushed
registry: digest: sha256:015cb5ae6306ed3d96d21409fd9cd6303666edc93f5b6e26b97af00cf3a9045b size: 1367

root@dlp:~#
docker images

REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
httpd                   latest              9d2a0c6e5b57        12 days ago         166MB
localhost:32000/httpd   registry            9d2a0c6e5b57        12 days ago         166MB
[3] To use Registry from other Nodes, add [insecure registry].
root@node02:~#
vi /etc/docker/daemon.json
{
    "insecure-registries" : ["10.0.0.30:32000"]
}

root@node02:~#
systemctl restart docker
root@node02:~#
docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              8cf1bfb43ff5        12 days ago         132MB

root@node02:~#
docker tag 8cf1bfb43ff5 10.0.0.30:32000/nginx:registry

root@node02:~#
docker push 10.0.0.30:32000/nginx

The push refers to repository [10.0.0.30:32000/nginx]
98b4c818e603: Pushed
1698c1b7e3e6: Pushed
227442bb48dc: Pushed
d899691659b0: Pushed
95ef25a32043: Pushed
registry: digest: sha256:deb724a427ea79face617392a5a471fdcb4cdb57f971ee6b7e492b90fecb199f size: 1362

root@node02:~#
docker images

REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
10.0.0.30:32000/nginx   registry            8cf1bfb43ff5        12 days ago         132MB
nginx                   latest              8cf1bfb43ff5        12 days ago         132MB
Matched Content