使用hostNetwork时,无法使用Kubernetes内部DNS:
/ test# nslookup echo
Server: 10.96.0.10
Address 1: 10.96.0.10
nslookup: can't resolve 'echo'不使用hostNetwork
/ test# nslookup echo
Server: 10.96.0.10
Address 1: 10.96.0.10 kube-dns.kube-system.svc.cluster.local
Name: echo
Address 1: 10.98.232.198 echo.default.svc.cluster.local裸机上的Kubernetes 1.18.5未升级(全新安装)。
完全配置:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: test
labels:
app: test
spec:
selector:
matchLabels:
app: test
template:
metadata:
labels:
app: test
spec:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
containers:
- image: busybox:1.28
command:
- sleep
- "3600"
imagePullPolicy: IfNotPresent
name: busybox
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: echo
spec:
replicas: 1
selector:
matchLabels:
app: echo
template:
metadata:
labels:
app: echo
spec:
containers:
- name: echo
image: jmalloc/echo-server
ports:
- name: http-port
containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: echo
spec:
ports:
- name: http-port
port: 80
targetPort: http-port
protocol: TCP
selector:
app: echo发布于 2020-11-12 17:20:39
Kubernetes 1.19.0的全新安装解决了这个问题。
https://stackoverflow.com/questions/64770587
复制相似问题