哪个服务在 pod 的 /etc/resolv.conf 下分配名称服务器,通常应该从主机 /etc/resolv.conf 获取,我在 pod 的 /etc/resolv.conf 下看到不同的名称服务器,kbernetes 上是否有任何配置(kubedns) 我可以配置它,以便 pod /etc/resolv.conf 具有 8.8.8.8
我在 Kubernetes 上部署 Jenkins 时遇到了同样的问题。如果您没有提到名称服务器/etc/resolv.conf显示默认名称服务器(k8s 的 ip)。
我通过修改部署文件解决了这个问题
dnsPolicy: "None"
dnsConfig:
nameservers:
- 8.8.8.8
并应用它。
apiVersion: apps/v1
kind: Deployment
metadata:
name: jenkins
namespace: jenkins
spec:
replicas: 1
selector:
matchLabels:
app: jenkins
template:
metadata:
labels:
app: jenkins
spec:
containers:
- name: jenkins
image: jenkins/jenkins:lts
ports:
- name: http-port
containerPort: 8080
- name: jnlp-port
containerPort: 50000
volumeMounts:
- name: jenkins-vol
mountPath: /var/jenkins_vol
dnsPolicy: "None"
dnsConfig:
nameservers:
- 8.8.8.8
volumes:
- name: jenkins-vol
emptyDir: {}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)