kubernetes.default:名称无法解析

时间:2017-01-14 22:03:47

标签: jenkins kubernetes openshift-origin

我正在运行OpenShift。

  • OpenShift Master:v3.3.1.7
  • Kubernetes Master:v1.3.0 + 52492b4

但是我在尝试在Jenkins中运行构建时遇到了问题(在pod中运行)。这不是我正在尝试构建的java代码的问题,但是在Kubernetes / Openshift设置中存在问题。

构建失败:

Caused by: java.net.UnknownHostException: kubernetes.default: Name does not resolve
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
    at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
    at java.net.InetAddress.getAllByName0(InetAddress.java:1276)
    at java.net.InetAddress.getAllByName(InetAddress.java:1192)
    at java.net.InetAddress.getAllByName(InetAddress.java:1126)
    at okhttp3.Dns$1.lookup(Dns.java:39)
    ...

有谁知道如何解决这个问题?

2 个答案:

答案 0 :(得分:0)

首先确认DNS实际上正在使用:

› kubectl run -i -t busybox --image=busybox --restart=Never 
Waiting for pod default/busybox to be running, status is Pending, pod ready: false
If you don't see a command prompt, try pressing enter.

/ # nslookup kubernetes.default
Server:    192.168.60.10
Address 1: 192.168.60.10 kube-dns.kube-system.svc.cluster.local

Name:      kubernetes.default
Address 1: 192.168.60.1 kubernetes.default.svc.cluster.local

如果这不起作用,请检查DNS pod是否正在运行:

kubectl get pods --namespace=kube-system -l k8s-app=kube-dns

会像......一样回复:

NAME                 READY     STATUS    RESTARTS   AGE
kube-dns-v14-3u5zi   3/3       Running   36         166d

最后检查相关日志值得一试:

kubectl logs --namespace=kube-system $(kubectl get pods --namespace=kube-system -l k8s-app=kube-dns -o name) -c kube-dns
kubectl logs --namespace=kube-system $(kubectl get pods --namespace=kube-system -l k8s-app=kube-dns -o name) -c dnsmasq
kubectl logs --namespace=kube-system $(kubectl get pods --namespace=kube-system -l k8s-app=kube-dns -o name) -c healthz

可在kubernetes.io

上找到完整说明

答案 1 :(得分:0)

请检查manage jenkins -> Configure Global Security -> Agent port is 50000 and Fixed