【问题标题】:how to know the CoreDNS take effect in kubernetes pod [duplicate]如何知道CoreDNS在kubernetes pod中生效[重复]
【发布时间】:2020-02-12 15:16:24
【问题描述】:

我正在部署 coredns(在 node-01 中运行):

{
  "kind": "Deployment",
  "apiVersion": "extensions/v1beta1",
  "metadata": {
    "name": "coredns",
    "namespace": "kube-system",
    "selfLink": "/apis/extensions/v1beta1/namespaces/kube-system/deployments/coredns",
    "uid": "5d470d90-6cdf-4ef1-be00-6774d70fcb54",
    "resourceVersion": "14708222",
    "generation": 18,
    "creationTimestamp": "2019-09-22T06:28:28Z",
    "labels": {
      "addonmanager.kubernetes.io/mode": "Reconcile",
      "k8s-app": "kube-dns",
      "kubernetes.io/cluster-service": "true",
      "kubernetes.io/name": "CoreDNS"
    },
    "annotations": {
      "deployment.kubernetes.io/revision": "6"
    }
  },
  "spec": {
    "replicas": 1,
    "selector": {
      "matchLabels": {
        "k8s-app": "kube-dns"
      }
    },
    "template": {
      "metadata": {
        "creationTimestamp": null,
        "labels": {
          "k8s-app": "kube-dns"
        },
        "annotations": {
          "seccomp.security.alpha.kubernetes.io/pod": "docker/default"
        }
      },
      "spec": {
        "volumes": [
          {
            "name": "config-volume",
            "configMap": {
              "name": "coredns",
              "items": [
                {
                  "key": "Corefile",
                  "path": "Corefile"
                }
              ],
              "defaultMode": 420
            }
          }
        ],
        "containers": [
          {
            "name": "coredns",
            "image": "gcr.azk8s.cn/google-containers/coredns:1.3.1",
            "args": [
              "-conf",
              "/etc/coredns/Corefile"
            ],
            "ports": [
              {
                "name": "dns",
                "containerPort": 53,
                "protocol": "UDP"
              },
              {
                "name": "dns-tcp",
                "containerPort": 53,
                "protocol": "TCP"
              },
              {
                "name": "metrics",
                "containerPort": 9153,
                "protocol": "TCP"
              }
            ],
            "resources": {
              "limits": {
                "memory": "70Mi"
              },
              "requests": {
                "cpu": "100m",
                "memory": "70Mi"
              }
            },
            "volumeMounts": [
              {
                "name": "config-volume",
                "readOnly": true,
                "mountPath": "/etc/coredns"
              }
            ],
            "livenessProbe": {
              "httpGet": {
                "path": "/health",
                "port": 8080,
                "scheme": "HTTP"
              },
              "initialDelaySeconds": 60,
              "timeoutSeconds": 5,
              "periodSeconds": 10,
              "successThreshold": 1,
              "failureThreshold": 5
            },
            "readinessProbe": {
              "httpGet": {
                "path": "/health",
                "port": 8080,
                "scheme": "HTTP"
              },
              "timeoutSeconds": 1,
              "periodSeconds": 10,
              "successThreshold": 1,
              "failureThreshold": 3
            },
            "terminationMessagePath": "/dev/termination-log",
            "terminationMessagePolicy": "File",
            "imagePullPolicy": "IfNotPresent",
            "securityContext": {
              "capabilities": {
                "add": [
                  "NET_BIND_SERVICE"
                ],
                "drop": [
                  "all"
                ]
              },
              "readOnlyRootFilesystem": true,
              "allowPrivilegeEscalation": false
            }
          }
        ],
        "restartPolicy": "Always",
        "terminationGracePeriodSeconds": 30,
        "dnsPolicy": "Default",
        "nodeSelector": {
          "beta.kubernetes.io/os": "linux"
        },
        "serviceAccountName": "coredns",
        "serviceAccount": "coredns",
        "securityContext": {},
        "schedulerName": "default-scheduler",
        "tolerations": [
          {
            "key": "CriticalAddonsOnly",
            "operator": "Exists"
          }
        ],
        "priorityClassName": "system-cluster-critical"
      }
    },
    "strategy": {
      "type": "RollingUpdate",
      "rollingUpdate": {
        "maxUnavailable": 1,
        "maxSurge": "25%"
      }
    },
    "revisionHistoryLimit": 10,
    "progressDeadlineSeconds": 600
  },
  "status": {
    "observedGeneration": 18,
    "replicas": 1,
    "updatedReplicas": 1,
    "readyReplicas": 1,
    "availableReplicas": 1,
    "conditions": [
      {
        "type": "Available",
        "status": "True",
        "lastUpdateTime": "2019-09-22T06:28:28Z",
        "lastTransitionTime": "2019-09-22T06:28:28Z",
        "reason": "MinimumReplicasAvailable",
        "message": "Deployment has minimum availability."
      },
      {
        "type": "Progressing",
        "status": "True",
        "lastUpdateTime": "2020-02-12T14:54:06Z",
        "lastTransitionTime": "2020-01-23T16:14:05Z",
        "reason": "NewReplicaSetAvailable",
        "message": "ReplicaSet \"coredns-89764d78c\" has successfully progressed."
      }
    ],
    "collisionCount": 1
  }
}

当我从 pod(在 node-01 中运行)ping 域时,它失败了:

# access external domain
/ # ping baidu.com
ping: bad address 'baidu.com'

# access oneself
/ # ping eureka-0
PING eureka-0 (172.30.208.2): 56 data bytes
64 bytes from 172.30.208.2: seq=0 ttl=64 time=0.054 ms

# access other pod
/ # ping zuul-service
ping: bad address 'zuul-service'

我想在 node-01 的 pod 中安装 curl:

/ # apk add curl
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.9/main: temporary error (try again later)
WARNING: Ignoring APKINDEX.b89edf6e.tar.gz: No such file or directory
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.9/community: temporary error (try again later)
WARNING: Ignoring APKINDEX.737f7e01.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
  curl (missing):
    required by: world[curl]

当我在 Node-03 中执行此命令时,它工作正常。我应该怎么做才能找出问题所在?

[root@ops001 ~]# kubectl get pods --namespace=kube-system -l k8s-app=kube-dns
NAME                      READY   STATUS    RESTARTS   AGE
coredns-89764d78c-zmz27   1/1     Running   0          90m

这是 Kubernetes 版本:

 [root@ops001 ~]# kubectl get nodes -o wide
NAME            STATUS   ROLES    AGE    VERSION   INTERNAL-IP      EXTERNAL-IP   OS-IMAGE                KERNEL-VERSION              CONTAINER-RUNTIME
azshara-k8s01   Ready    <none>   144d   v1.15.2   172.19.104.231   <none>        CentOS Linux 7 (Core)   3.10.0-957.5.1.el7.x86_64   docker://19.3.1
azshara-k8s02   Ready    <none>   144d   v1.15.2   172.19.104.230   <none>        CentOS Linux 7 (Core)   3.10.0-957.5.1.el7.x86_64   docker://18.9.6
azshara-k8s03   Ready    <none>   144d   v1.15.2   172.19.150.82    <none>        CentOS Linux 7 (Core)   3.10.0-957.5.1.el7.x86_64   docker://18.9.6

【问题讨论】:

  • 嗨,您的coredns pod 是否具有Running 状态?使用命令kubectl get pods --namespace=kube-system -l k8s-app=kube-dns 列出coredns pod 并查看状态。
  • 它正在运行@PiotrMalec
  • 您使用什么版本的 kubernetes?您在任何节点上都有不同的版本吗?您可以通过kubectl get nodes -o wide 进行检查。

标签: kubernetes coredns


【解决方案1】:

正如我所见,您正在使用openjdk:8-jre-alpine 作为 docker 容器,所以:

使用此命令行进行安装:

RUN apk update 第一个或

删除缓存:

RUN rm -rf /var/cache/apk/* && \
    rm -rf /tmp/*

RUN apk --no-cache add curl 替换为apk add curl

【讨论】:

  • CentOS 是主机,我在 Pod 中执行命令,Pod 使用 alpine @Thanh Nguyen Van
  • 好的,我明白了,让我编辑答案
  • 你能分享你正在使用的容器的图像吗?
  • 是openjdk:8-jre-alpine 对吧?
  • 是的,它是 openjdk:8-jre-alpine
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-06-16
  • 2021-04-11
  • 2018-11-14
  • 2019-06-25
  • 2019-05-02
相关资源
最近更新 更多