如何知道CoreDNS在kubernetes pod中生效 [英] how to know the CoreDNS take effect in kubernetes pod

查看:136
本文介绍了如何知道CoreDNS在kubernetes pod中生效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am deploy coredns (running in 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操作时,它失败了:

when I ping domain from pods(running in node-01), it failed:

# 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:

and I want to install curl in pod in node-01:

/ # 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中执行此命令时,它工作正常.我应该怎么做才能找出问题所在?

when I execute this command in Node-03,it works fine.what should I do to figure out where is going wrong?

[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版本:

this is kubernetes version:

 [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

推荐答案

如我所见,您将openjdk:8-jre-alpine用于docker容器,因此:

As I see, you are using openjdk:8-jre-alpine for docker container, so:

使用此命令行进行安装:

Using this comand line for installing :

RUN apk update首先或

删除缓存:

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

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

这篇关于如何知道CoreDNS在kubernetes pod中生效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆