Este é um RELATÓRIO DE ERRO ou SOLICITAÇÃO DE RECURSO? (escolha uma): RELATÓRIO DE ERRO
Versão do Kubernetes (use kubectl version
):
Cliente: v1.6.1
Servidor: v1.6.1+coreos.0
Ambiente :
1298.7.0
4.9.16-coreos-r1
quay.io/coreos/hyperkube:v1.6.1_coreos.0
image as systemd kubelet.service
+ manifests em /etc/kubernetes/manifests
para componentes principaisO kubelet.service
é:
# /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
O /etc/kubernetes/manifests/kube-apiserver.yml
é:
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
O que aconteceu :
kube-apiserver
Pod inicia e sai imediatamente com erro (de 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
De alguma forma o apiserver tenta resolver localhost
via DNS externo.
O que você esperava que acontecesse :
kube-apiserver
deve iniciar normalmente, como acontece nas versões 1.5 do Kubernetes.
Como reproduzi-lo (o mínimo e preciso possível):
Ao inicializar o cluster Kubernetes no CoreOS, mas para a versão v1.6.1 do Kubernetes.
Qualquer outra coisa que precisamos saber :
Como eu investiguei o ClusterFirstWithHostNet
foi adicionado ao parâmetro dnsPolicy
de PodSpec
em 1.6 . Diz:
Para definir as opções de DNS junto com hostNetwork, você deve especificar a política de DNS explicitamente como 'ClusterFirstWithHostNet'.
Tentei especificar dnsPolicy: ClusterFirstWithHostNet
explicitamente e tive um erro diferente:
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
Além disso, olhou para kube-apiserver
opções CLI e não encontrou algo relacionado a ser ajustado.
O KubeDNS na minha instalação é implantado como usual Deployment no namespace kube-system
, não como um complemento de cluster no diretório /etc/kubernetes/manifests
.
Alguma sugestão de por que apiserver
tenta resolver localhost
em 8.8.8.8
?
Dê uma olhada no /etc/hosts
do seu host e veja se ele contém localhost. Este foi o problema na minha configuração com exatamente a mesma configuração, meu /etc/hosts
continha apenas o nome do host da minha máquina e um IP, mas nenhum localhost. Quando adicionei 127.0.0.1 localhost
e reiniciei o apiserver, funcionou.
Engenho! 🤦🤦🤦🤦
Essa é exatamente a questão.
@lorenz muito obrigado!
Comentários muito úteis
Dê uma olhada no
/etc/hosts
do seu host e veja se ele contém localhost. Este foi o problema na minha configuração com exatamente a mesma configuração, meu/etc/hosts
continha apenas o nome do host da minha máquina e um IP, mas nenhum localhost. Quando adicionei127.0.0.1 localhost
e reiniciei o apiserver, funcionou.