k8s from server (NotFound): the server could not find the requested resource
k8s 端口暴露和查看日志,主机名配置不正确,导致访问失败。
·
学习部署k8s 时,外界访问 NodePort 端口不成功,在查看日志 kubectl logs时,报错
[root@centos7-12 application]# kubectl logs whoami-deployment-678b64444d-r29dw
Error from server (NotFound): the server could not find the requested resource ( pods/log whoami-deployment-678b64444d-r29dw)
原来是 /etc/hosts 文件的配置有错
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.1.1 centos7-12 centos7-12
192.168.1.132 vm132
192.168.1.133 vm133
192.168.1.134 vm134
我的主机名是 centos7-12,所以修改成:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.1.1 centos7-12 centos7-12
192.168.1.132 centos7-12 centos7-12
192.168.1.133 centos7-13
192.168.1.134 centos7-14
就可以了,外界可以访问了,日志也可以查看了。
参考了:
https://blog.csdn.net/u012972390/article/details/112853747
更多推荐
已为社区贡献1条内容
所有评论(0)