-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DNS issue when deploying a Knative service from the insecure in-cluster registry #15744
Comments
Hi @metacoma,
The above error indicates that kubelet cannot have access to that DNS name. Kubelet needs to be able to resolve that so it can pull the image. |
hey @skonto thank you for help,
Yes, you are right. It was my misunderstanding that Docker resolves registry address from the "host" system. For lurkers, here are short snippets on how to fix it in a single-node k3s cluster. I tested it on Ubuntu 24.04.
---
apiVersion: operator.knative.dev/v1beta1
kind: KnativeServing
metadata:
annotations:
name: knative-serving
namespace: knative-serving
spec:
config:
deployment:
registries-skipping-tag-resolving: zot-int.zot.svc.cluster.local:5000,zot-int.zot:5000,127.0.0.1:30001
---
apiVersion: v1
kind: Service
metadata:
name: dns-expose
namespace: kube-system
spec:
type: NodePort
ports:
- name: dns-tcp
port: 53
targetPort: 53
protocol: TCP
nodePort: 30002
- name: dns-udp
port: 53
targetPort: 53
protocol: UDP
nodePort: 30002
selector:
k8s-app: kube-dns
.ONESHELL: docker_insecure_registry
docker_insecure_registry:
INSECURE_REGISTRY="zot-int.zot.svc.cluster.local:5000"
DOCKER_CONFIG="/etc/docker/daemon.json"
if [[ ! -f "$$DOCKER_CONFIG" ]]; then
echo "{}" | sudo tee "$$DOCKER_CONFIG" > /dev/null
fi
if ! jq -e ".\"insecure-registries\" | index(\"$$INSECURE_REGISTRY\")" "$$DOCKER_CONFIG" > /dev/null; then
TMP_FILE=/tmp/daemon.json
jq --arg reg "$$INSECURE_REGISTRY" '
.["insecure-registries"] += [$$reg] // { "insecure-registries": [$$reg] }
' "$$DOCKER_CONFIG" > "$$TMP_FILE" && sudo mv "$$TMP_FILE" "$$DOCKER_CONFIG"
sudo systemctl restart docker
fi
.ONESHELL: forward_dns_cluster_local
forward_dns_cluster_local:
(test -d /etc/systemd/resolved.conf.d || sudo mkdir -p /etc/systemd/resolved.conf.d)
cat<<EOF | sudo tee /etc/systemd/resolved.conf.d/k8s-dns.conf
[Resolve]
DNS=127.0.0.1:30002
Domains=~svc.cluster.local
EOF
sudo systemctl restart systemd-resolved
|
Nice! On my side I used a private registry on Minikube on my linux box like this:
|
For kind you can see how to patch the containerd setup here |
@skonto, thank you for your snippets — they’re very useful! |
Ask your question here:
Is it possible to use in-cluster DNS names in the .spec.containers[].image field?
I have an insecure registry deployed inside the cluster. The full registry URL is
zot-int.zot.svc.cluster.local:5000
The following Knative Serving manifest:
leads to the following deployment error:
However, the FQDN
zot-int.zot.svc.cluster.local
resolves correctly:Additionally, this registry is listed in
registries-skipping-tag-resolving
within theconfig-deployment
ConfigMap:The host's
/etc/docker/daemon.json
also includes the registry in the insecure-registries list:ugly workaround
If I change the DNS host in registry_url to the IP address in image service definition, like
Everything works as expected
The HostAliases solution (as described here knative-extensions/kn-plugin-quickstart#429) doesn't work for me because the registry IP address may change
env:
The text was updated successfully, but these errors were encountered: