Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Deploying an internal container registry with Minikube add-ons

July 11, 2019
Kamesh Sampath
Related topics:
ContainersKubernetes
Related products:
Red Hat OpenShift Container Platform

Share:

    Minikube has a feature called add-ons, which help in adding extra components and features to Minikube’s Kubernetes cluster.

    The registry add-on will deploy an internal registry, which can then be used to push and pull Linux container images. But at times, we might wish to mimic push and pull to different registries (i.e., using aliases for container registry). In this article, I will walk you through the steps required to achieve the same.

    What do we need?

    • Minikube, preferred version is v1.1.1
    • Git to clone the sources
    • kubectl
    • kubens
    • tkn CLI

    What we will do?

    As part of this exercise we will:

    • Enable registry via Minikube add-on.
    • Update the Minikube node’s etc/hosts for the domains dev.local, example.com to resolve to the internal registry.
    • Update CoreDNS to rules that will allow pods to push images( typical case of CI/CD) to the registry using aliases.

    Deploy container registry

    As described previously, we can use Minikube add-ons to deploy and enable the internal registry. The internal registry by default gets deployed in kube-system namespace.

    minikube profile demo
    minikube start -p demo --memory=8192 --cpus=6 --disk-size=50g

    Note: If you like to use cri-o, then adjust the above command to be like:

    minikube profile demo
    minikube start -p demo --memory=8192 --cpus=6 --container-runtime=crio
    

    With Minikube running, the next step is to deploy the registry.

    minikube addons enable registry

    Once the registry is enabled, you will see a registry pod kubectl -n kube-system get pod and a corresponding service kubectl -n kube-system get svc in the kube-system namespace.

    The minkube-helper repo in GitHub has the sources along with the example application to test the configuration. Clone the sources and navigate to the registry sub-folder. For easier reference, we will call the sources folder as $PROJECT_HOME:

    git clone https://github.com/kameshsampath/minikube-helpers && \
    cd minikube-helpers/registry

    Create aliases ConfigMap

    The alias names that we want to use for the registry are configured via the ConfigMap, called registry-aliases:

    apiVersion: v1
    data:
      # Add additonal hosts seperated by new-line
      registryAliases: >-
        dev.local
        example.com
      # default registry address in minikube when enabled via minikube addons enable registry
      registrySvc: registry.kube-system.svc.cluster.local
    kind: ConfigMap
    metadata:
      name: registry-aliases
      namespace: kube-system
    
    kubectl apply -f registry-aliases-config.yaml

    Update Minikube /etc/hosts file

    To make the aliases resolve to the registry service in kube-system namespace, we need to add the aliases entries in the Minkube VM’s /etc/hosts file. We will use DaemonSet to update the etc/hosts file inside the Minikube VM.

    kubectl apply -f node-etc-hosts-update.yaml

    As it will take few minutes for the DaemonSet to be running, you can watch the status using the command:

    kubectl -n kube-system get pods --watch

    Once the DaemonSet is successfully running, you can check the Minkube VM's /etc/hosts file, which will now be updated to point to CLUSTER-IP of the registry service.

    minikube ssh -- cat /etc/hosts

    Tips

    • You can use CTRL+C to terminate the watch.
    • You can check the CLUSTER-IP of the registry service using the command kubectl -n kube-system get svc registry -o jsonpath='{.spec.clusterIP}'.

    Patch CoreDNS

    The configurations and other settings we applied in the previous section are good enough for the container runtime to push and pull the images. A typical CI/CD scenario will be something like a Kubernetes pod doing a build, e.g., Jenkins, Tekton and pushing the container image to the registry post as part of the pipeline.

    To make the pod resolve the aliases like dev.local, example.com, we need to have the CoreDNS rules configured. For our alias configuration to work, we will use the CoreDNS rewrite rules.

    Running the following command will have the CoreDNS patched with the rewrite rules.

    ./patch-coredns.sh

    The CoreDNS patch can be queried to see the updates. A successful update will show output for the command kubectl -n kube-sytem configmap coredns -oyaml as shown below:

    apiVersion: v1
    data:
      Corefile: |-
        .:53 {
            errors
            health
        rewrite name dev.local  registry.kube-system.svc.cluster.local
        rewrite name example.com  registry.kube-system.svc.cluster.local
            kubernetes cluster.local in-addr.arpa ip6.arpa {
               pods insecure
               upstream
               fallthrough in-addr.arpa ip6.arpa
            }
            prometheus :9153
            forward . /etc/resolv.conf
            cache 30
            loop
            reload
            loadbalance
        }
    kind: ConfigMap
    metadata:
      name: coredns
      namespace: kube-system

    Test the configuration

    I found the real need of this registry hack was when I was trying to deploy Tekton pipelines. Tekton is Kubernetes' native way of declaring CI/CD pipelines.

    As part of my pipeline (see example), I want to build and deploy a simple Hello World application.

    Deploy Tekton pipelines

    kubectl apply --filename https://storage.googleapis.com/tekton-releases/latest/release.yaml

    The status of Tekton pipelines can be watched using:

    kubectl get pods --namespace tekton-pipelines -w

    Deploy application pipeline

    kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/golang/build.yaml \
      --filename example/build.yaml

    As it will take some time for the pipeline to complete, you can watch the status using the command:

    tkn taskrun logs -f -a hello-world

    A successful pipeline build will have the Hello World application deployed. You can use the following Minikube shortcut:

    curl $(minikube service helloworld --url)

    to call the service, which returns a “Hello World” as the response.

    Note: When you see tkn logs -f -a hello-world showing a blank screen, it might be that it's pulling the required images. To know what's happening, you can use kubectl get events -w.

    I hope this article will help with similar development environment use cases that you might have. Next time, we will take a deep dive into Tekton. Until then, happy Kubernetes hacking!

    Last updated: February 11, 2024

    Recent Posts

    • Meet the Red Hat Node.js team at PowerUP 2025

    • How to use pipelines for AI/ML automation at the edge

    • What's new in network observability 1.8

    • LLM Compressor: Optimize LLMs for low-latency deployments

    • How to set up NVIDIA NIM on Red Hat OpenShift AI

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue