These steps walk you through setting up a password protected Docker Registry and Nginx Ingress controller on your laptop or workstation. You'll need a Docker client, Minikube, Helm and Kubernetes client (kubectl).
minikube start --cpus 4 --disk-size 100g --memory 6000 --insecure-registry registry.minikube.st81ess.com:80
Requests to registry.minikube.st81ess.com will resolve to your
local Minikube ingress address, 192.168.99.100, and
Nginx ingress controller will route the request to a backing
registry service using the hostname provided.
helm repo add lakowske https://lakowske.github.io/charts
#After adding the repo, update your index.
helm repo update
helm init ; kubectl rollout status -w deployment/tiller-deploy --namespace=kube-system
Create a username and password for your registry. In this case,
we'll create a user named admin, but feel free to call it what you
want. Next, add the secret to the cluster.
htpasswd -c auth admin
kubectl create secret generic registry-auth --from-file=auth
Start a private local registry deployment that Kubernetes keeps
alive even if the container dies. It's sitting behind an Nginx ingress
controller that provides basic authentication. Basic authentication
is helpful tool when deploying services like a registry over
the public internet. In those cases, we also need to be sure to
use https connection. I often use kube-lego, or Kubernetes Let's
Encrypt for this purpose. In this case, all the traffic is local,
so we'll stick to http. The minikube-registry is a parent chart
that contains Nginx ingress controller, a Docker registry and a
dashboard. The chart doesn't have any resources of its own, it
simply depends on sub-charts that do. We are reusing the building
blocks on the
excellent kubernetes
charts repo.
helm install lakowske/minikube-registry
To import the Docker environment into your current shell.
eval $(minikube docker-env)
Build an image and tag it.
git clone https://bitbucket.org/seth_lakowske/hello-node.git
cd hello-node
docker build -t hello-node .
docker tag hello-node registry.minikube.st81ess.com:80/hello-node
Push the image to your local registry.
docker push registry.minikube.st81ess.com:80/hello-node
Now run a deployment in Kubernetes using the image located on your
local registry.
kubectl run hello-node --image=registry.minikube.st81ess.com:80/hello-node --port=8888
You should now have a deployment of your image, in my case hello-node, running using your private local registry, Kubernetes and Docker. You can verify by running
kubectl get deployments
- or -