1.kubeadm  init初使化报错

[root@k8s01 ~]# kubeadm  init --kubernetes-version=v1.13.3 --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --ignore-preflight-errors=Swap

[init] Using Kubernetes version: v1.13.3

[preflight] Running pre-flight checks

[WARNING Swap]: running with swap on is not supported. Please disable swap

[WARNING SystemVerification]: this Docker version is not on the list of validated versions: 18.09.2. Latest validated version: 18.06

[preflight] Pulling images required for setting up a Kubernetes cluster

[preflight] This might take a minute or two, depending on the speed of your internet connection

[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'

error execution phase preflight: [preflight] Some fatal errors occurred:

[ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-apiserver:v1.13.3: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

, error: exit status 1

[ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-controller-manager:v1.13.3: output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

, error: exit status 1


解决方法:

[root@k8s01 ~]# cat 12.sh 

#!/bin/bash

docker pull mirrorgooglecontainers/kube-apiserver:v1.13.3

docker pull mirrorgooglecontainers/kube-controller-manager:v1.13.3

docker pull mirrorgooglecontainers/kube-scheduler:v1.13.3

docker pull mirrorgooglecontainers/kube-proxy:v1.13.3

docker pull mirrorgooglecontainers/pause:3.1

docker pull mirrorgooglecontainers/etcd:3.2.24

docker pull coredns/coredns:1.2.6

docker tag mirrorgooglecontainers/kube-proxy:v1.13.3  k8s.gcr.io/kube-proxy:v1.13.3

docker tag mirrorgooglecontainers/kube-scheduler:v1.13.3 k8s.gcr.io/kube-scheduler:v1.13.3

docker tag mirrorgooglecontainers/kube-apiserver:v1.13.3 k8s.gcr.io/kube-apiserver:v1.13.3

docker tag mirrorgooglecontainers/kube-controller-manager:v1.13.3 k8s.gcr.io/kube-controller-manager:v1.13.3

docker tag mirrorgooglecontainers/etcd:3.2.24  k8s.gcr.io/etcd:3.2.24

docker tag coredns/coredns:1.2.6 k8s.gcr.io/coredns:1.2.6

docker tag mirrorgooglecontainers/pause:3.1  k8s.gcr.io/pause:3.1

docker rmi mirrorgooglecontainers/kube-apiserver:v1.13.3

docker rmi mirrorgooglecontainers/kube-controller-manager:v1.13.3

docker rmi mirrorgooglecontainers/kube-scheduler:v1.13.3

docker rmi mirrorgooglecontainers/kube-proxy:v1.13.3

docker rmi mirrorgooglecontainers/pause:3.1

docker rmi mirrorgooglecontainers/etcd:3.2.24

docker rmi coredns/coredns:1.2.6:q

[root@k8s01 ~]#  ./12.sh


2.关闭swap交换分区

Unfortunately, an error has occurred:

timed out waiting for the condition

This error is likely caused by:

- The kubelet is not running

- The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)

If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:

- 'systemctl status kubelet'

- 'journalctl -xeu kubelet'


解决方法:

[root@k8s1 ~]# echo "KUBELET_EXTRA_ARGS=--fail-swap-on=false" > /etc/sysconfig/kubelet

[root@k8s1 ~]# vim /etc/fstab 

#UUID=c5f6d686-6b5a-48ae-92c0-df2f44b6402b swap      swap    defaults        0 0     --注释swap

[root@k8s1 ~]# 


3.k8s从节点pod不能显示

[root@k8s2 ~]# kubectl  get pods

The connection to the server localhost:8080 was refused - did you specify the right host or port?

[root@k8s2 ~]# 


解决方法:

[root@k8s1 ~]# scp -r /etc/kubernetes/admin.conf root@k8s2:/etc/kubernetes/    --将admin.conf文件拷贝到其它从节点

[root@k8s2 ~]# vim /root/.bash_profile       --在各个从节点添加环境变量

export KUBECONFIG=/etc/kubernetes/admin.conf

[root@k8s2 ~]# source  /root/.bash_profile 


4.使用Harbor上传镜像报错

[root@node1 ~]# docker login http://192.168.8.10

Username: admin

Password: 

Error response from daemon: Get https://192.168.8.10/v2/: dial tcp 192.168.8.10:443: connect: connection refused


解决方法:

[root@node1 harbor]# vim /usr/lib/systemd/system/docker.service     --修改参数

ExecStart=/usr/bin/dockerd -H fd:// --insecure-registry=192.168.8.10

[root@node1 harbor]# systemctl daemon-reload

[root@node1 harbor]# systemctl restart docker

[root@node1 harbor]# ps -ef | grep -i docker

root      808561    1884  0 16:08 ?        00:00:00 containerd-shim -namespace moby -workdir /var/lib/containerd/io.containerd.runtime.v1.linux/moby/5f13be571995f00b5ec00b8941f612bbf0b5429ae183ab0553e579d31c43f300 -address /run/containerd/containerd.sock -containerd-binary /usr/bin/containerd -runtime-root /var/run/docker/runtime-runc

root      874547       1  6 16:50 ?        00:00:00 /usr/bin/dockerd -H fd:// --insecure-registry=192.168.8.10

[root@node1 harbor]# docker-compose ps

       Name                     Command               State                                Ports                              

------------------------------------------------------------------------------------------------------------------------------

harbor-adminserver   /harbor/start.sh                 Up                                                                      

harbor-core          /harbor/start.sh                 Up                                                                      

harbor-db            /entrypoint.sh postgres          Up      5432/tcp                                                        

harbor-jobservice    /harbor/start.sh                 Up                                                                      

harbor-log           /bin/sh -c /usr/local/bin/ ...   Up      127.0.0.1:1514->10514/tcp                                       

harbor-portal        nginx -g daemon off;             Up      80/tcp                                                          

nginx                nginx -g daemon off;             Up      0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp, 0.0.0.0:80->80/tcp

redis                docker-entrypoint.sh redis ...   Up      6379/tcp                                                        

registry             /entrypoint.sh /etc/regist ...   Up      5000/tcp                                                        

registryctl          /harbor/start.sh                 Up                                                                      

[root@node1 harbor]# docker login 192.168.8.10

Username: admin

Password: 

WARNING! Your password will be stored unencrypted in /root/.docker/config.json.

Configure a credential helper to remove this warning. See

https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

[root@node1 harbor]#


5.在kubernetes添加节点后提示CNI问题

[root@k8s1 ~]# kubectl describe pods ecs-web-desktop-7cbc98dcdb-nw4fw -n ecs-local-area

  Normal   SuccessfulMountVolume   8h      kubelet, ecsnode03  MountVolume.SetUp succeeded for volume "volume-data"
  Normal   SuccessfulMountVolume   8h      kubelet, ecsnode03  MountVolume.SetUp succeeded for volume "setenv-sh"
  Normal   SuccessfulMountVolume   8h      kubelet, ecsnode03  MountVolume.SetUp succeeded for volume "default-token-69l45"
  Warning  FailedCreatePodSandBox  8h (x11 over 8h)   kubelet, ecsnode03  Failed create pod sandbox: rpc error: code = Unknown desc = NetworkPlugin cni failed to set up pod "ecs-web-desktop-7cbc98dcdb-nw4fw_ecs-local-area" network: could not initialize etcdv3 client: open /etc/cni/etcd/pki/calico-etcd-client.crt: no such file or directory
  Normal   SandboxChanged          8h (x123 over 8h)  kubelet, ecsnode03  Pod sandbox changed, it will be killed and re-created.
  Normal   Scheduled               7m                 default-scheduler   Successfully assigned ecs-web-desktop-7cbc98dcdb-nw4fw to ecsnode03


解决方法:

是因为master节点etcd没有新节点数据信息,过5分钟就可以了。



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25854343/viewspace-2636166/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/25854343/viewspace-2636166/

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐