我根据以下指南设置了 1 个主服务器和 1 个节点的集群。CentOS 手动安装
之后我只是尝试部署仪表板(或任何与此相关的内容),但我收到以下错误
kubectl get events
25m 1h 23 10.3.0.5 Node Warning MissingClusterDNS {kubelet 10.3.0.5} (events with common reason combined)
30m 1h 16 10.3.0.5 Node Warning MissingClusterDNS {kubelet 10.3.0.5} kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. pod: "kubernetes-dashboard-1975554030-cc9n1_kube-system(ebab5633-c9d1-11e6-a741-000d3af22f09)". Falling back to DNSDefault policy.
56m 56m 1 10.3.0.5 Node Warning MissingClusterDNS {kubelet 10.3.0.5} kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. pod: "busybox_default(9634cf12-c9d7-11e6-a741-000d3af22f09)". Falling back to DNSDefault policy.
26m 26m 2 10.3.0.5 Node Warning MissingClusterDNS {kubelet 10.3.0.5} kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. pod: "kubernetes-dashboard-1975554030-31rnp_kube-system(bdce120a-c9db-11e6-a741-000d3af22f09)". Falling back to DNSDefault policy.
...
另外,当我尝试进入仪表板时,我得到了这个
curl http://localhost:8001/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "no endpoints available for service \"kubernetes-dashboard\"",
"reason": "ServiceUnavailable",
"code": 503
}
其他日志和信息
kubectl cluster-info
Kubernetes master is running at http://localhost:8080
kubectl version
Client Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.0", GitCommit:"86dc49aa137175378ac7fba7751c3d3e7f18e5fc", GitTreeState:"clean", BuildDate:"2016-12-15T16:57:18Z", GoVersion:"go1.6.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.0", GitCommit:"86dc49aa137175378ac7fba7751c3d3e7f18e5fc", GitTreeState:"clean", BuildDate:"2016-12-15T16:57:18Z", GoVersion:"go1.6.3", Compiler:"gc", Platform:"linux/amd64"}
kubectl get nodes
NAME STATUS AGE
10.3.0.5 Ready 3h
kubectl get services --all-namespaces
NAMESPACE NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default kubernetes 10.254.0.1 <none> 443/TCP 1h
kube-system kubernetes-dashboard 10.254.155.149 <nodes> 80/TCP 31m
kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system kubernetes-dashboard-1975554030-1ramq 0/1 CrashLoopBackOff 10 31m
答案1
Kubernetes-dashboard 需要一个正常工作的集群 DNS 服务。
以下是您可以用来部署的清单核心DNS在具有有效 DNS 的集群中。
根据上面的一些输出,我猜测您的集群 DNS 是 10.254.0.10。
您应该能够将此代码保存在文本文件中(例如名为 k8s-dns.yaml),然后使用以下命令进行安装kubectl create -f k8s-dns.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: coredns
namespace: kube-system
data:
Corefile: |
.:53 {
log stdout
health
# Replace cluster.local with your cluster domain
kubernetes cluster.local
proxy . /etc/resolv.conf
cache 30
}
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: coredns
namespace: kube-system
labels:
k8s-app: coredns
kubernetes.io/cluster-service: "true"
kubernetes.io/name: "CoreDNS"
spec:
replicas: 1
selector:
matchLabels:
k8s-app: coredns
template:
metadata:
labels:
k8s-app: coredns
annotations:
scheduler.alpha.kubernetes.io/critical-pod: ''
scheduler.alpha.kubernetes.io/tolerations: '[{"key":"CriticalAddonsOnly", "operator":"Exists"}]'
spec:
containers:
- name: coredns
image: rothgar/coredns:004
imagePullPolicy: Always
args: [ "-conf", "/etc/coredns/Corefile" ]
volumeMounts:
- name: config-volume
mountPath: /etc/coredns
ports:
- containerPort: 53
name: dns
protocol: UDP
- containerPort: 53
name: dns-tcp
protocol: TCP
livenessProbe:
httpGet:
path: /health
port: 8080
scheme: HTTP
initialDelaySeconds: 60
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 5
dnsPolicy: Default
volumes:
- name: config-volume
configMap:
name: coredns
items:
- key: Corefile
path: Corefile
---
apiVersion: v1
kind: Service
metadata:
name: coredns
namespace: kube-system
labels:
k8s-app: coredns
kubernetes.io/cluster-service: "true"
kubernetes.io/name: "CoreDNS"
spec:
selector:
k8s-app: coredns
# Replace with your cluster DNS IP
clusterIP: 10.254.0.10
ports:
- name: dns
port: 53
protocol: UDP
- name: dns-tcp
port: 53
protocol: TCP
另外,我建议遵循kubeadm 文档因为它更为最新并且能给你一个功能齐全的集群。