[英]Kubernetes Pod DNS Policy Settings
我想了解 kube.netes 中 Pod 的 .network 配置概念。 我可能誤解了這個概念,因此尋求一些建議和幫助。 以下是我的 Pod 規范,其中我將 dnspolicy=true 和 dnsPolicy 設置為 ClusterFirstWithHostNet
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: nginx
name: nginx
spec:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
containers:
- image: nginx
name: nginx
我可以看到我的 pod 和主機現在具有相同的 IP。
**k get pod -o wide**
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx 0/1 ContainerCreating 0 13s 172.25.0.31 controlplane <none> <none>
**k get node -o wide**
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
controlplane Ready control-plane,master 5m30s v1.23.3+k3s1 172.25.0.31 <none> Alpine Linux v3.15 5.4.0-1069-gcp containerd://1.5.9-k3s1
所以我的問題是,為什么當我檢查主機和 pod 上的 dns 配置時,它們會給出不同的結果。 我的理解是他們都應該顯示相同的結果?
controlplane ~ ➜ cat /etc/resolv.conf
nameserver 172.25.0.1
options ndots:0
從 POD
controlplane ~ ➜ k exec -it nginx -- cat /etc/resolv.conf
search default.svc.cluster.local svc.cluster.local cluster.local
nameserver 10.43.0.10
options ndots:5
My understanding is that they both should show the same results?
因為您設置dnsPolicy: ClusterFirstWithHostNet
,它在集群中使用了 coredns ( 10.43.0.10 )。 如果您設置為dnsPolicy: Default
pod 將使用 172.25.0。 1與您的主機相同,但您將無法解析集群中部署的服務名稱。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.