Kubernetes KinD add extra host to cluster

88 views Asked by At

It is possible to add a DNS entry to the KinD Cluster configuration? The background is I use my own Docker registry with the address docker-registry. If I use my own images it doesn't work because the cluster can't resolve "docker-registry". My workaround is, add a host e.g. "10.5.0.6 docker-registry" to each node in the cluster. But I hope I can do this in the cluster configuration yaml file.

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
containerdConfigPatches:
- |-
  [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker-registry:5000"]
    endpoint = ["http://docker-registry:5000"]
nodes:
- role: control-plane
  kubeadmConfigPatches:
  - |
    kind: InitConfiguration
    nodeRegistration:
      kubeletExtraArgs:
        node-labels: "ingress-ready=true"
  extraPortMappings:
  - containerPort: 80
    hostPort: 80
    protocol: TCP
  - containerPort: 443
    hostPort: 443
    protocol: TCP
- role: worker

Workaround after the cluster has initialized:

docker exec my-cluster-control-plane bash -c "echo '10.5.0.6    docker-registry' >> /etc/hosts"
docker exec my-cluster-worker bash -c "echo '10.5.0.6    docker-registry' >> /etc/hosts"
0

There are 0 answers