阿里云Centos7 安装 k8s 集群(使用过程中的坑)
个人备忘下面这个地址能满足大部分需求 :无坑版本 k8s centos 安装博文这个k8s集群部署讲解的很细,还有别的博文做扩展上文:5.2 的配置三台服务器都要修改 ,5.3 的命令 [root@k8s-master ~]# etcdctl mk /atomic.io/network/config '{ "Network": "10.0.0.0/16" }
个人备忘
下面这个地址能满足大部分需求 :
无坑版本 k8s centos 安装博文
上文:5.2 的配置三台服务器都要修改 ,5.3 的命令 [root@k8s-master ~]# etcdctl mk /atomic.io/network/config '{ "Network": "10.0.0.0/16" }' 只在主节点执行就行。
补充 : 10.0.0.0/16 网段开的比较大,正常该处配置项应该和 vim /etc/kubernetes/apiserver 这个中的10.254.0.0/16 保持一致,自行挑选。
访问http://kube-apiserver:port
http://192.168.234.130:8080/ 查看所有请求url
http://192.168.234.130:8080/healthz/ping 查看健康状况
补充:阿里云服务器记得开防火墙(安全组)2378,6443,10250,4001
注意: 如果你改变了 api-server 中的默认8080 端口,则在使用 kubectl 命令时 会出现,couldn't read version from server: get http://localhost:8080/version: dial tcp 127.0.0.1:8080: connection refused.
方法一: alias kubectl=" kubectl -s http://apiserver:8080" , 用改命令重新指定默认地址。
方法二:ubectl -s http://k8s-master:8081 get nodes , 加入 -s http://ip:port 指定到你设置的 端口。
etcd centos 集群配置该片博文可参考
坑一:
kubernetes创建集群资源对象, pod服务一直处于ContainerCreating状态问题。
failed to “StartContainer” for “POD” with ErrImagePull
1.查看pods状态,一直处于ContainerCreating状态
1 2 3 | [root@SZ-V-L-K8S ~]# kubectl get pods NAME READY STATUS RESTARTS AGE nginx-pod 0/1 ContainerCreating 0 15h |
2.查看pod资源的详细信息中的错信息提示
[root@SZ-V-L-K8S ~]# kubectl describe pod nginx-pod
1 2 3 4 | Events: FirstSeen LastSeen Count From SubObjectPath Type Reason Message --------- -------- ----- ---- ------------- -------- ------ ------- 15h 4m 180 {kubelet srv.node1} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull failed for registry.access.redhat.com/rhel7/pod-infrastructure:latest, this may be because there are no credentials on this request. details: (open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such file or directory)" |
3.错误分析
错误提示: failed to “StartContainer” for “POD” with ErrImagePull: “image pull failed for registry.access.redhat.com/rhel7/pod-infrastructure:latest, this may be because there are no credentials on this request. details: (open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such file or directory)”
大概出错意图是,srv.node1这个节点机,拉取Docker镜像的时候出错了,因为redhat-ca.crt这个证书文件不存在。
到srv.node1节点主机,手动执行拉取镜像试一下。
1 2 3 | [root@SZ-V-L-docker-node1 ~]# docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest Trying to pull repository registry.access.redhat.com/rhel7/pod-infrastructure ... open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such file or directory |
错误信息一样的,查看下redhat-ca.crt这个证书文件目录是否存在
1 2 | [root@SZ-V-L-docker-node1 ~]# ls -l /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt lrwxrwxrwx. 1 root root 27 Apr 18 16:05 /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt -> /etc/rhsm/ca/redhat-uep.pem |
是个软件链接到/etc/rhsm/ca/redhat-uep.pem这个文件,而且这个文件目录不存在。
问题找到了。
4.错误解决
跟rhsm这个有关,全称Red Hat Subscription Manager。 跟RedHat查关服务,直接用yum安装下rhsm相关的组件。
1 2 3 4 5 | [root@SZ-V-L-docker-node1 ~]# yum install *rhsm* Downloading packages: (1/3): python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm | 41 kB 00:00:00 (2/3): python-dateutil-1.5-7.el7.noarch.rpm | 85 kB 00:00:01 (3/3): python-rhsm-1.19.10-1.el7_4.x86_64.rpm |
再手动执行拉取镜像文件,现在可以拉取镜像文件了,问题解决。
1 2 3 4 | [root@SZ-V-L-docker-node1 ~]# docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest Trying to pull repository registry.access.redhat.com/rhel7/pod-infrastructure ... latest: Pulling from registry.access.redhat.com/rhel7/pod-infrastructure 26e5ed6899db: Downloading [=> ] 2.107 MB/74.87 MB |
5.重新集群资源对象
返回到master主节点,删除集群资源对象再重新创建。
1 2 3 4 5 6 7 8 9 10 11 12 13 | [root@ZSZ-V-L-K8S ~]# kubectl delete pod nginx-pod
[root@SZ-V-L-K8S ~]# kubectl get pods No resources found.
[root@SZ-V-L-K8S ~]# kubectl create -f /data/app/docker_nginx/nginx-pod.yaml |
6.重还有一种情况
我们node 上有/etc/rhsm/ca/ 目录, 但是没有 redhat-uep.pem 文件,这时候需要我们执行两个命令:
(2)rpm2cpio python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm | cpio -iv --to-stdout ./etc/rhsm/ca/redhat-uep.pem | tee /etc/rhsm/ca/redhat-uep.pem
这两个命令会生成/etc/rhsm/ca/redhat-uep.pem文件.
顺得的话会得到下面的结果。
[root@localhost]# docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest
Trying to pull repository registry.access.redhat.com/rhel7/pod-infrastructure ...
latest: Pulling from registry.access.redhat.com/rhel7/pod-infrastructure
26e5ed6899db: Pull complete
此时在,删除原来的pod , 重新 kubectl create -f xxx.yaml ,再次查看pods 的状态,发现 该pod 为 Running.
更多推荐
所有评论(0)