1、首先你必有现成的Kubernetes集群,如果现在你一无所有,请参考:
http://zlyang.blog.51cto.com/1196234/1951010
2、建议采用etcd集群,搭建过程请参考:
http://zlyang.blog.51cto.com/1196234/1951164 二、部署Kubernetes-dashboard [所有机器:Master、Node1、Node2] 1、安装flannel(flannel为管理Containers网络)
[root@k8s-master ~]# yum -y install epel-release flannel 2、配置flanel [Master]
[root@k8s-master ~]# vim /etc/sysconfig/flanneld
# Flanneld configuration options
# etcd url location. Point this to the server where etcd runs
FLANNEL_ETCD_ENDPOINTS="http://k8s-master:2379"
# etcd config key. This is the configuration key that flannel queries
# For address range assignment
FLANNEL_ETCD_PREFIX="/atomic.io/network"
# Any additional options that you want to pass
#FLANNEL_OPTIONS="" [Node]
[root@k8s-node1 ~]# vim /etc/sysconfig/flanneld
# Flanneld configuration options
# etcd url location. Point this to the server where etcd runs
FLANNEL_ETCD_ENDPOINTS="http://k8s-master:2379"
# etcd config key. This is the configuration key that flannel queries
# For address range assignment
FLANNEL_ETCD_PREFIX="/atomic.io/network"
# Any additional options that you want to pass
#FLANNEL_OPTIONS="" 3、添加Etcd网络配置 [Master]
[root@k8s-master ~]# mkdir -p /atomic.io/network/
[root@k8s-master ~]# chmod -R 777 /atomic.io
[root@k8s-master ~]# etcdctl mk /atomic.io/network/config '{"Network":"10.254.0.0/16"}'
****** 注:此IP为/etc/kubernetes/apiserver中{KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16" }填写的地址 4、启动flannel服务 [所有机器]
[root@k8s-master ~]# systemctl start flanneld.service
[root@k8s-master ~]# systemctl enable flanneld.service 5、修改Kubernetes所有Node节点kubelet设置中添加dns信息,否则会报错 [Node1/Node2]
[root@k8s-node1 ~]# vim /etc/kubernetes/kubelet
###
# kubernetes kubelet (minion) config
# The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces)
KUBELET_ADDRESS="--address=0.0.0.0"
# The port for the info server to serve on
KUBELET_PORT="--port=10250"
# You may leave this blank to use the actual hostname
KUBELET_HOSTNAME="--hostname-override=k8s-node1"
# location of the api-server
KUBELET_API_SERVER="--api-servers=http://k8s-master:8080"
# pod infrastructure container
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"
# Add your own!
#KUBELET_ARGS=""
KUBELET_ARGS="--cluster-dns=223.5.5.5 --cluster-domain=k8s-master" 6、重启Node上的服务 [Master]
for SERVICES in flanneld etcd kube-apiserver kube-controller-manager kube-scheduler; do systemctl restart $SERVICES; systemctl enable $SERVICES; systemctl status $SERVICES ; done [Node]
for SERVICES in flanneld kube-proxy kubelet docker; do systemctl restart $SERVICES; systemctl enable $SERVICES; systemctl status $SERVICES ; done 7、安装dashboard [Node1/Node2] a、导入images
***由于墙的原因,需要先导入images,如果你可以***,忽略此步骤
下载地址:链接: http://pan.baidu.com/s/1kVuthYn 密码: m2hv b、导入:
[root@k8s-node1 ~]# docker load < kubernetes-dashboard.tar.gz c、查看
[root@k8s-node1 ~]# docker images
QoS> Tolerations:
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
2m 2m 1 {default-scheduler } Normal Scheduled Successfully assigned kubernetes-dashboard-1607234690-3bnk2 to k8s-node2 三、测试 a、在测试机上添加host信息
192.168.80.130 k8s-master b、使用浏览器输入:http://k8s-master:8080/ui 四、错误 [错误1]
[root@k8s-master ~]# kubectl describe pods kubernetes-dashboard-1607234690-3bnk2 --namespace=kube-system
1s 1s 1 {kubelet k8s-node2} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "kubernetes-dashboard" with CrashLoopBackOff: "Back-off 10s restarting failed container=kubernetes-dashboard pod=kubernetes-dashboard-980055440-l9zl5_kube-system(870d02e1-7810-11e7-9517-000c296a54e8)"
再次使用kubectl logs查看具体错误信息
[root@k8s-master ~]# kubectl logs kubernetes-dashboard-1607234690-l6gfk --namespace=kube-system
No request provided. Skipping authorization header
Error while initializing connection to Kubernetes apiserver. This most likely means that the cluster is misconfigured (e.g., it has invalid apiserver certificates or service accounts configuration) or the --apiserver-host param points to a server that does not exist. Reason: Get http://k8s-master:8080/version: dial tcp: lookup k8s-master on 223.5.5.5:53: no such host
Refer to the troubleshooting guide for more information: https://github.com/kubernetes/dashboard/blob/master/docs/user-guide/troubleshooting.md [解决方案]
[root@k8s-master ~]# vim kubenetes-dashboard.yaml
- --apiserver改成ip,不要使用域名
此过程中可能会遇到很多问题,如果需要帮助,请发邮件至:DBA_Master@163.com