使用kn create service时抛出如下问题:
(base) ubuntu@master:~/Projects/socc23$ kn service create network-intensive --image docker.io/{username}/{imagename} --force
Warning: Kubernetes default value is insecure, Knative may default this to secure in a future release: spec.template.spec.containers[0].securityContext.allowPrivilegeEscalation, spec.template.spec.containers[0].securityContext.capabilities, spec.template.spec.containers[0].securityContext.runAsNonRoot, spec.template.spec.containers[0].securityContext.seccompProfile
Replacing service $imagename in namespace 'default':
0.048s Configuration $imagename does not have any ready Revision.
0.321s ...
0.362s Configuration $imagename is waiting for a Revision to become ready.
6.359s Revision $imagename"-00013" failed with message: Unable to fetch image docker.io/{username}/{imagename}: failed to resolve image to digest: Get "https://index.docker.io/v2/": dial tcp: lookup index.docker.io on 10.96.0.10:53: server misbehaving.
6.378s Configuration "network-intensive" does not have any ready Revision.
Error: RevisionFailed: Revision $imagename"-00013" failed with message: Unable to fetch image docker.io/{username}/{imagename}: failed to resolve image to digest: Get "https://index.docker.io/v2/": dial tcp: lookup index.docker.io on 10.96.0.10:53: server misbehaving.
上述问题的原因是DNS配置有问题,需要在/etc/resolv.conf添加nameserver信息,添加方式如下,添加完成后重新启动server/VM,以使/etc/resolv.conf中的内容生效。
https://www.tecmint.com/set-permanent-dns-nameservers-in-ubuntu-debian/
sudo apt update
sudo apt install resolvconf
sudo systemctl start resolvconf.service
sudo systemctl enable resolvconf.service
sudo systemctl status resolvconf.service
sudo nano /etc/resolvconf/resolv.conf.d/head #添加如下信息
nameserver 8.8.8.8
nameserver 8.8.4.4
sudo systemctl restart resolvconf.service
sudo systemctl restart systemd-resolved.service
sudo reboot