This post covers how to -
- Setup a local Docker registry with Kubernetes on Windows
- How to push/pull images to/from the registry
Prerequisites
- You have Kubernetes installed
- You have Docker installed
Architecture
1A - Steps - Setting up the registry
- Start the cluster and allow insecure registries
minikube start --insecure-registry "10.0.0.0/24"
- Tell minikube to start a registry inside a pod in the Kubernetes cluster
minikube addons enable registry
- Get the name of the registry pod, in my case it is, (the official docs didn't explain this) registry-s4h7n
kubectl get pods --namespace kube-system
- Forward all traffic to the registry, run the two commands in separate terminals
kubectl port-forward --namespace kube-system registry-s4h7n 5000:5000
- Continued -
docker run --rm -it --network=host alpine ash -c "apk add socat && socat TCP-LISTEN:5000,reuseaddr,fork TCP:host.docker.internal:5000"
- Done. Now, visit.
http://localhost:5000/v2/_catalog
1B - Steps - Testing the Setup
git clone https://github.com/CT83/ping-google.git
-
docker build -t ping-google .
- Make sure it works
docker run ping-google
- Tag it and prepare for push to our newly created registry
docker tag ping-google localhost:5000/ping-google
Push it
docker push localhost:5000/ping-google
Pull it back down on Kubernetes
kubectl create deployment ping-google --image=localhost:5000/ping-google
Ensure it's running
kubectl get pods
NAME READY STATUS RESTARTS AGE
ping-google-7666ff8964-w5h44 1/1 Running 0 17s
kubectl logs ping-google-7666ff8964-w5h44
PING ns1.google.com (216.239.34.10) 56(84) bytes of data.
64 bytes from ns2.google.com (216.239.34.10): icmp_seq=1 ttl=97 time=73.0 ms
Conclusion
That's basically it, this should greatly simplify your development workflow.
Top comments (0)