因为网上关于如何搭建kubernetes的文章很多(刘天斯大神的很不错 链接:http://blog.liuts.com/post/247/)
所以具体过程我就不再叙述了,我只说我在搭建过程中遇到的问题。
我的集群主机系统版本为:centos7
我使用的etcd版本为:etcd-0.4.6-7.el7.centos.x86_64.rpm
kubernetes版本为:kubernetes-1.1.0-0.4.git2bfa9a1.el7.x86_64.rpm
配置参考文档为:https://github.com/kubernetes/kubernetes/blob/a676b118b9ecb5f1f1797531ba6f555e82d58201/docs/getting-started-guides/centos/centos_manual_config.md
1.错误提示信息
Unable to listen for secure (open /var/run/kubernetes/apiserver.crt: no such file or directory)
解决方案:
创建 目录/var/run/kubernetes/
# vim /usr/lib/systemd/system/kube-apiserver.service
Service下增加如下内容:
PermissionsStartOnly=true
ExecStartPre=/usr/bin/chown -R kube:kube /var/run/kubernetes/
2.官方的配置文档以及gitHub上的kubernetes的配置文档中有一些参数不正确,还请各位仔细观察,下面列出错误的参数:
误:KUBELET_PORT="--kubelet-port=10250"
正:KUBELET_PORT="--kubelet_port=10250"
误:KUBE_ETCD_SERVERS="--etcd-servers=http://centos-master:4001"
正:KUBE_ETCD_SERVERS="--etcd_servers=http://centos-master:4001"
误:KUBE_ALLOW_PRIV="--allow-privileged=false"
正:KUBE_ALLOW_PRIV="--allow_privileged=false"
误:KUBELET_HOSTNAME="--hostname-override=centos-minion172"
正:KUBELET_HOSTNAME="--hostname_override=centos-minion172"
误:KUBELET_API_SERVER="--api-servers=http://centos-master:8080"
正:KUBELET_API_SERVER="--api_servers=http://centos-master:8080"
3.如果执行kubectl get nodes时得到的集群主机状态为NotReady
请检查防火墙firewalld.service iptables.service
systemctl stop iptables.service
systemctl disable iptables.service
systemctl stop firewalld.service
systemctl disable firewalld.service
4.如果执行kubectl get pods -o wide时得到的结果中,READY始终为0/1,而RESTARTS数量却为>1的情况
那么是由于你创建POD或者replication的时候使用的镜像不正确
镜像的根目录下一定要有一个run.sh文件,这样启动的容器才会是一直running的状态
5.集群node主机上的kubelet配置文件最后一项请修改为:
KUBELET_ARGS="--pod-infra-container-image={私有仓库地址}/pause:0.8.0"
提前在本地私有仓库准备好此镜像或者指定可以下载到的镜像地址
6.起来master主机上的服务时,遇到类似如下错误:
No cloud provider specified.
Failed to start service controller: ServiceController should not be run without a cloudprovider.
此类错误,目前未发现会影响具体哪些功能,待后面发现再进行解决
欢迎各位指正,遇到新的情况,我会继续补充。
下面贴出我的配置文件,供各位参考
config (master和node一样)
apiserver (只配置master)
kubelet (只配置node)
下面是我创建的RC和SERVICE
顺利贴出来我的两个yaml文件 供参考