This is a demo repository to support my Image proxy cache using Harbor blog post. The idea is to use Harbor to proxy-cache images and reduce calls to DockerHub.
Make sure you have devbox and docker installed.
- Create a Docker network for the Kind cluster
docker network create --subnet 172.100.0.0/16 custom-kind-network
- Install dependencies
devbox run init
This will create a Kind cluster, and install Metallb, Ingress NGINX and Harbor. This will take a few minutes because it waits for all these tools to get ready.
- Configure Harbor project
devbox run proxy-cache
- Create Kubernetes secrets for registry credentials
kubectl create secret -n default docker-registry regcred-harbor \
--docker-server=harbor.ingress.local \
--docker-username=admin \
--docker-password=admin
- Allow insecure registries
SSH into the Kubernetes node
docker exec -it kind-worker bash
Then run
apt-get update
apt install vim -y
vim /etc/containerd/config.toml
Add the following lines to the file
[plugins."io.containerd.grpc.v1.cri".registry]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."harbor.ingress.local"]
endpoint = ["https://harbor.ingress.local"]
[plugins."io.containerd.grpc.v1.cri".registry.configs."harbor.ingress.local".tls]
insecure_skip_verify = true
[plugins."io.containerd.grpc.v1.cri".registry.configs."harbor.ingress.local".auth]
username = "admin"
password = "admin"
Finally restart containerd
systemctl restart containerd
exit
- Deploy an application that uses Kustomize
devbox run app-with-kustomize
- Deploy an application that uses Helm Chart
devbox run app-with-helm
- Add Harbor URL to /etc/hosts
INGRESS_LB_IP=$(kubectl get svc ingress-nginx-controller -n ingress-nginx -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo "$INGRESS_LB_IP harbor.ingress.local" | sudo tee -a /etc/hosts
- Access Harbor UI
Access https://harbor.ingress.local
and use admin
as username and admin
as password. Notice that a project called proxy_cache
was created and have 2 repositories caches.
- Destroy everything
devbox run destroy