这是K8S集群中的两个节点,node21和node22,集群中交付了一个coredns服务,调度在node22上了,pod地址是10.64.22.5,同时映射了一个service,地址是172.64.0.2,按道理,所有的节点和pod,都是以172.64.0.2做为域名解析的,但是现在有个很奇怪的现象:
1. 在物理节点node21和node22上,直接使用10.64.22.5做解析,是能解析到的
2. 在物理节点22上,使用service 地址172.64.0.2做解析,也是能解析到的
3. 在node上的任意pod,使用172.64.0.2做解析,也是能解析到的
4. 唯独在node21上,使用service 172.64.0.2做解析,一直反馈是超时
虽然说不影响整个集群运行,但是一直不知道是为啥原因,已经重新部署过多次也不能解决此问题,还请大神们指教一二。谢谢了。
service.yaml
apiVersion: v1 kind: Service metadata: name: coredns namespace: kube-system annotations: prometheus.io/port: "9153" prometheus.io/scrape: "true" labels: k8s-app: coredns kubernetes.io/cluster-service: "true" addonmanager.kubernetes.io/mode: Reconcile kubernetes.io/name: "CoreDNS" spec: selector: k8s-app: coredns clusterIP: 172.64.0.2 ports: - name: dns port: 53 protocol: UDP - name: dns-tcp port: 53 protocol: TCP - name: metrics port: 9153 protocol: TCP
dp.yaml
apiVersion: apps/v1 kind: Deployment metadata: name: coredns namespace: kube-system labels: k8s-app: coredns kubernetes.io/cluster-service: "true" addonmanager.kubernetes.io/mode: Reconcile kubernetes.io/name: "CoreDNS" spec: # replicas: not specified here: # 1. In order to make Addon Manager do not reconcile this replicas parameter. # 2. Default is 1. # 3. Will be tuned in real time if DNS horizontal auto-scaling is turned on. strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 1 selector: matchLabels: k8s-app: coredns template: metadata: labels: k8s-app: coredns spec: serviceAccountName: coredns tolerations: - key: node-role.kubernetes.io/master effect: NoSchedule - key: "CriticalAddonsOnly" operator: "Exists" containers: - name: coredns image: harbor.cmcc.com/public/coredns:v1.6.1 imagePullPolicy: IfNotPresent resources: requests: cpu: 100m memory: 70Mi args: [ "-conf", "/etc/coredns/Corefile" ] volumeMounts: - name: config-volume mountPath: /etc/coredns readOnly: true ports: - containerPort: 53 name: dns protocol: UDP - containerPort: 53 name: dns-tcp protocol: TCP - containerPort: 9153 name: metrics protocol: TCP livenessProbe: httpGet: path: /health port: 8080 scheme: HTTP initialDelaySeconds: 60 timeoutSeconds: 5 successThreshold: 1 failureThreshold: 5 readinessProbe: httpGet: path: /ready port: 8181 scheme: HTTP securityContext: allowPrivilegeEscalation: false capabilities: add: - NET_BIND_SERVICE drop: - all readOnlyRootFilesystem: true dnsPolicy: Default volumes: - name: config-volume configMap: name: coredns items: - key: Corefile path: Corefile
config.yaml
apiVersion: v1 kind: ConfigMap metadata: name: coredns namespace: kube-system labels: addonmanager.kubernetes.io/mode: EnsureExists data: Corefile: | .:53 { errors health ready kubernetes cluster.local 172.64.0.0/16 prometheus :9153 forward . 192.168.64.11 cache 30 loop reload loadbalance }