Using the Registry Aliases Addon

Registry Aliases Addon

An addon to minikube that can help push and pull from the minikube registry using custom domain names. The custom domain names will be made resolveable from with in cluster and at minikube node.

How to use ?

Start minikube

  1. minikube start -p demo

This addon depends on registry addon, it need to be enabled before the alias addon is installed:

Enable internal registry

  1. minikube addons enable registry

Verifying the registry deployment

  1. watch kubectl get pods -n kube-system
  1. NAME READY STATUS RESTARTS AGE
  2. coredns-6955765f44-kpbzt 1/1 Running 0 16m
  3. coredns-6955765f44-lzlsv 1/1 Running 0 16m
  4. etcd-demo 1/1 Running 0 16m
  5. kube-apiserver-demo 1/1 Running 0 16m
  6. kube-controller-manager-demo 1/1 Running 0 16m
  7. kube-proxy-q8rb9 1/1 Running 0 16m
  8. kube-scheduler-demo 1/1 Running 0 16m
  9. *registry-4k8zs* 1/1 Running 0 40s
  10. registry-proxy-vs8jt 1/1 Running 0 40s
  11. storage-provisioner 1/1 Running 0 16m
  1. kubectl get svc -n kube-system
  1. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  2. kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 17m
  3. registry ClusterIP 10.97.247.75 <none> 80/TCP 94s

NOTE: Please make a note of the CLUSTER-IP of registry service

Enable registry aliases addon

  1. minikube addons enable registry-aliases
  2. 🌟 The 'registry-aliases' addon is enabled

You can check the mikikube vm’s /etc/hosts file for the registry aliases entries:

  1. watch minikube ssh -- cat /etc/hosts
  1. 127.0.0.1 localhost
  2. 127.0.1.1 demo
  3. 10.97.247.75 example.org
  4. 10.97.247.75 example.com
  5. 10.97.247.75 test.com
  6. 10.97.247.75 test.org

The above output shows that the Daemonset has added the registryAliases from the ConfigMap pointing to the internal registry’s CLUSTER-IP.

Update CoreDNS

The coreDNS would have been automatically updated by the patch-coredns. A successful job run will have coredns ConfigMap updated like:

  1. apiVersion: v1
  2. data:
  3. Corefile: |-
  4. .:53 {
  5. errors
  6. health
  7. rewrite name example.com registry.kube-system.svc.cluster.local
  8. rewrite name example.org registry.kube-system.svc.cluster.local
  9. rewrite name test.com registry.kube-system.svc.cluster.local
  10. rewrite name test.org registry.kube-system.svc.cluster.local
  11. kubernetes cluster.local in-addr.arpa ip6.arpa {
  12. pods insecure
  13. upstream
  14. fallthrough in-addr.arpa ip6.arpa
  15. }
  16. prometheus :9153
  17. proxy . /etc/resolv.conf
  18. cache 30
  19. loop
  20. reload
  21. loadbalance
  22. }
  23. kind: ConfigMap
  24. metadata:
  25. name: coredns

To verify it run the following command:

  1. kubectl get cm -n kube-system coredns -o yaml

Once you have successfully patched you can now push and pull from the registry using suffix example.com, example.org,test.com and test.org.

The successful run will show the following extra pods (Daemonset, Job) in kube-system namespace:

  1. NAME READY STATUS RESTARTS AGE
  2. registry-aliases-hosts-update-995vx 1/1 Running 0 47s
  3. registry-aliases-patch-core-dns-zsxfc 0/1 Completed 0 47s

Verify with sample application

You can verify the deployment end to end using the example application.

  1. git clone https://github.com/kameshsampath/minikube-registry-aliases-demo
  2. cd minikube-registry-aliases-demo

Make sure you set the docker context using eval $(minikube -p demo docker-env)

Deploy the application using Skaffold:

  1. skaffold dev --port-forward

Once the application is running try doing curl localhost:8080 to see the Hello World response

You can also update skaffold.yaml and app.yaml, to use test.org, test.com or example.org as container registry urls, and see all the container image names resolves to internal registry, resulting in successful build and deployment.

NOTE:

You can also update skaffold.yaml and app. yaml, to use test.org, test.com or > example.org as container registry urls, and see all the > container image names resolves to internal registry, resulting in successful build and deployment.

Last modified July 7, 2023: Add addon readmes to website (cf976f6dd)