Is this a BUG REPORT or FEATURE REQUEST? (choose one): BUG REPORT
Kubernetes version (use kubectl version
):
Client: v1.6.1
Server: v1.6.1+coreos.0
Environment:
1298.7.0
4.9.16-coreos-r1
quay.io/coreos/hyperkube:v1.6.1_coreos.0
image as systemd kubelet.service
+ manifests in /etc/kubernetes/manifests
for core componentsThe kubelet.service
is:
# /etc/systemd/system/kubelet.service
[Unit]
Description=Kubelet service of Kubernetes
[Service]
# Mounting /etc/hosts is required for kubelet to be able to resolve
# nodes via its aliases (which may be not DNS routable).
Environment="RKT_RUN_ARGS= \
--volume=etc-hosts,kind=host,source=/etc/hosts --mount volume=etc-hosts,target=/etc/hosts \
--volume=var-log,kind=host,source=/var/log --mount volume=var-log,target=/var/log \
--volume=dns,kind=host,source=/etc/resolv.conf --mount volume=dns,target=/etc/resolv.conf \
--uuid-file-save=/var/run/kubelet-pod.uuid"
Environment=KUBELET_IMAGE_URL=quay.io/coreos/hyperkube
Environment=KUBELET_IMAGE_TAG=v1.6.1_coreos.0
ExecStartPre=/usr/bin/mkdir -p /etc/kubernetes/manifests
ExecStartPre=/usr/bin/mkdir -p /var/log/containers
ExecStartPre=-/usr/bin/rkt rm --uuid-file=/var/run/kubelet-pod.uuid
# Specifying all node labels here is required for kubelet
# to let it know its node state for correct recovery/restarts
# before sychronization with kube-apiserver happens.
ExecStart=/usr/lib/coreos/kubelet-wrapper \
--port=10250 \
--tls-cert-file=/etc/kubernetes/ssl/kubelet.crt \
--tls-private-key-file=/etc/kubernetes/ssl/kubelet.key \
--kubeconfig=/etc/kubernetes/kubeconfig-kubelet.yaml \
--require-kubeconfig \
--register-node=true \
--allow-privileged=true \
--pod-manifest-path=/etc/kubernetes/manifests \
--hostname-override=n1.myhost.net \
--cluster-dns=10.3.0.10 \
--cluster-domain=cluster.local \
--node-labels=role/apiserver=true,role/application=true \
--network-plugin= \
--sync-frequency=30s
ExecStop=-/usr/bin/rkt stop --uuid-file=/var/run/kubelet-pod.uuid
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
The /etc/kubernetes/manifests/kube-apiserver.yml
is:
kind: Pod
apiVersion: v1
metadata:
name: kube-apiserver
namespace: kube-system
spec:
hostNetwork: true
containers:
- name: kube-apiserver
image: quay.io/coreos/hyperkube:v1.6.1_coreos.0
command:
- /hyperkube
- apiserver
- --bind-address=0.0.0.0
- --secure-port=8443
- --insecure-port=8081
- --advertise-address=<public ip>
- --external-hostname=n1.myhost.net
- --client-ca-file=/etc/kubernetes/ssl/ca.crt
- --tls-cert-file=/etc/kubernetes/ssl/apiserver.crt
- --tls-private-key-file=/etc/kubernetes/ssl/apiserver.key
- --service-account-key-file=/etc/kubernetes/ssl/apiserver.key
- --service-cluster-ip-range=10.3.0.0/24
- --etcd-servers=http://n1.myhost.net:4001
- --etcd-cafile=/etc/ssl/etcd/ca.crt
- --etcd-certfile=/etc/ssl/etcd/client.crt
- --etcd-keyfile=/etc/ssl/etcd/client.key
- --storage-backend=etcd2
- --storage-media-type=application/json
- --kubelet-https=true
- --kubelet-certificate-authority=/etc/kubernetes/ssl/ca.crt
- --kubelet-client-certificate=/etc/kubernetes/ssl/apiserver.crt
- --kubelet-client-key=/etc/kubernetes/ssl/apiserver.key
- --allow-privileged=true
- --anonymous-auth=false
- --admission-control=NamespaceLifecycle,LimitRanger,ServiceAccount,ResourceQuota
- --runtime-config=extensions/v1beta1=true,extensions/v1beta1/thirdpartyresources=true
ports:
- name: https
containerPort: 8443
hostPort: 8443
- name: local
containerPort: 8081
hostPort: 8081
volumeMounts:
- name: ssl-certs-kubernetes
mountPath: /etc/kubernetes/ssl
readOnly: true
- name: ssl-certs-etcd
mountPath: /etc/ssl/etcd
readOnly: true
- name: ssl-certs-host
mountPath: /etc/ssl/certs
readOnly: true
volumes:
- name: ssl-certs-kubernetes
hostPath:
path: /etc/kubernetes/ssl
- name: ssl-certs-etcd
hostPath:
path: /etc/ssl/etcd
- name: ssl-certs-host
hostPath:
path: /usr/share/ca-certificates
What happened:
kube-apiserver
Pod starts and immediately exits with error (from docker logs
):
F0408 09:01:03.289906 1 controller.go:128] Unable to perform initial IP allocation check: unable to refresh the service IP block: Get https://localhost:8443/api/v1/services: dial tcp: lookup localhost on 8.8.8.8:53: no such host
Somehow apiserver tries to resolve localhost
via external DNS.
What you expected to happen:
kube-apiserver
should start normally as it does on 1.5 Kubernetes versions.
How to reproduce it (as minimally and precisely as possible):
By booting up Kubernetes cluster on CoreOS but for v1.6.1 Kubernetes version.
Anything else we need to know:
As i've investigated the ClusterFirstWithHostNet
value was added to dnsPolicy
parameter of PodSpec
in 1.6. It says:
To have DNS options set along with hostNetwork, you have to specify DNS policy explicitly to 'ClusterFirstWithHostNet'.
I tried to specify dnsPolicy: ClusterFirstWithHostNet
explicitly, and had a different error:
F0408 08:57:52.675808 1 controller.go:128] Unable to perform initial IP allocation check: unable to refresh the service IP block: Get https://localhost:8443/api/v1/services: dial tcp: lookup localhost on 10.3.0.10:53: write udp <public ip>:37836->10.3.0.10:53: write: operation not permitted
Also, looked at kube-apiserver
CLI options and did not found something related to be tuned up.
The KubeDNS in my installation is deployed as usual Deployment in kube-system
namespace, not as a cluster addon in /etc/kubernetes/manifests
dir.
Any suggestions why apiserver
tries to resolve localhost
on 8.8.8.8
?
Have a look at your host's /etc/hosts
and see if it contains localhost. This was the problem on my setup with exactly the same configuration, my /etc/hosts
contained only the hostname of my machine and an IP but no localhost. When I added 127.0.0.1 localhost
and restarted the apiserver it worked.
Engenius! 馃う馃う馃う馃う
That's exactly the issue.
@lorenz thanks a lot!
Most helpful comment
Have a look at your host's
/etc/hosts
and see if it contains localhost. This was the problem on my setup with exactly the same configuration, my/etc/hosts
contained only the hostname of my machine and an IP but no localhost. When I added127.0.0.1 localhost
and restarted the apiserver it worked.