Push docker image to registry installed using microk8s addon Push docker image to registry installed using microk8s addon kubernetes kubernetes

Push docker image to registry installed using microk8s addon


After you enable registry on the microk8s, run this script

kubectl get svc -n container-registry

you can see that microk8s has redirect registry service's port 32000 to 5000, then I use ingress to expose via https.

First, you have to enable ingress on microk8s:

microk8s.enable ingress

then, you have to create a tls sceret if you want to use https :

openssl genrsa -aes128 -out server.key 2048openssl req -newkey rsa:2048 -nodes -keyout server.key -x509 -days 3650 -out server.crtkubectl create secret tls registry-secret-tls --cert=server.crt --key=server.key -n container-registry

then use kubectl apply -f to create an ingress for revese proxy of registry service.

apiVersion: extensions/v1beta1kind: Ingressmetadata:  name: registry  namespace: container-registry  annotations:    nginx.ingress.kubernetes.io/ingress.class: nginx    nginx.ingress.kubernetes.io/proxy-body-size: "500m"    nginx.ingress.kubernetes.io/proxy-pass-headers: "Location"spec:  tls:  - hosts:    - ingress.local    secretName: registry-secret-tls  rules:  - host: ingress.local    http:      paths:      - path: /        backend:          serviceName: registry          servicePort: 5000

then, add 127.0.0.1 ingress.local to /etc/hosts file. At last, use buildah push docker images to ingress.local.

buildah push --tls-verify=false 44c92e82c220 docker://ingress.local/datacenter-school

This time, it looks everything is ok. But when I try list images in microk8s, I can't find the image that I just pushed.

microk8s.ctr images ls -q |grep datacenter-school

That's quiet weird!