centos7.5部署k8s环境

学习参照链接:https://www.cnblogs.com/caoxb/p/11243472.html
参照该链接,利用空闲的时间,花费快一周才部署成功,比较详细步骤参照该链接就好,此篇博客主要镜像相关遇到问题补充和记录。

虚拟机: VMware® Workstation 15 Pro15.5.0 build-14665864
操作系统:CentOS Linux release 7.5.1804 (Core)

  1. 部署环境时,需要用到3个虚拟机环境,所以可以装完第一个centos后,直接将装完的第一个centos硬克隆两个。
  2. 安装docker、安装kubectl、kubeadm、kubelet、cri-tools,需要进行相关yum源的准备,如果未准备好,会导致安装失败,
  3. yum源的准备:
    1)基础源
    [root@k8s-master yum.repos.d]# cat CentOS-Base.repo
    # CentOS-Base.repo
    [base]
    name=CentOS- r e l e a s e v e r − B a s e − m i r r o r s . a l i y u n . c o m f a i l o v e r m e t h o d = p r i o r i t y b a s e u r l = h t t p : / / m i r r o r s . a l i y u n . c o m / c e n t o s / releasever - Base - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/ releaseverBasemirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/releasever/os/ b a s e a r c h / h t t p : / / m i r r o r s . a l i y u n c s . c o m / c e n t o s / basearch/ http://mirrors.aliyuncs.com/centos/ basearch/http://mirrors.aliyuncs.com/centos/releasever/os/ b a s e a r c h / h t t p : / / m i r r o r s . c l o u d . a l i y u n c s . c o m / c e n t o s / basearch/ http://mirrors.cloud.aliyuncs.com/centos/ basearch/http://mirrors.cloud.aliyuncs.com/centos/releasever/os/$basearch/
    gpgcheck=1
    gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS- r e l e a s e v e r − U p d a t e s − m i r r o r s . a l i y u n . c o m f a i l o v e r m e t h o d = p r i o r i t y b a s e u r l = h t t p : / / m i r r o r s . a l i y u n . c o m / c e n t o s / releasever - Updates - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/ releaseverUpdatesmirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/releasever/updates/ b a s e a r c h / h t t p : / / m i r r o r s . a l i y u n c s . c o m / c e n t o s / basearch/ http://mirrors.aliyuncs.com/centos/ basearch/http://mirrors.aliyuncs.com/centos/releasever/updates/ b a s e a r c h / h t t p : / / m i r r o r s . c l o u d . a l i y u n c s . c o m / c e n t o s / basearch/ http://mirrors.cloud.aliyuncs.com/centos/ basearch/http://mirrors.cloud.aliyuncs.com/centos/releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS- r e l e a s e v e r − E x t r a s − m i r r o r s . a l i y u n . c o m f a i l o v e r m e t h o d = p r i o r i t y b a s e u r l = h t t p : / / m i r r o r s . a l i y u n . c o m / c e n t o s / releasever - Extras - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/ releaseverExtrasmirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/releasever/extras/ b a s e a r c h / h t t p : / / m i r r o r s . a l i y u n c s . c o m / c e n t o s / basearch/ http://mirrors.aliyuncs.com/centos/ basearch/http://mirrors.aliyuncs.com/centos/releasever/extras/ b a s e a r c h / h t t p : / / m i r r o r s . c l o u d . a l i y u n c s . c o m / c e n t o s / basearch/ http://mirrors.cloud.aliyuncs.com/centos/ basearch/http://mirrors.cloud.aliyuncs.com/centos/releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS- r e l e a s e v e r − P l u s − m i r r o r s . a l i y u n . c o m f a i l o v e r m e t h o d = p r i o r i t y b a s e u r l = h t t p : / / m i r r o r s . a l i y u n . c o m / c e n t o s / releasever - Plus - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/ releaseverPlusmirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/releasever/centosplus/ b a s e a r c h / h t t p : / / m i r r o r s . a l i y u n c s . c o m / c e n t o s / basearch/ http://mirrors.aliyuncs.com/centos/ basearch/http://mirrors.aliyuncs.com/centos/releasever/centosplus/ b a s e a r c h / h t t p : / / m i r r o r s . c l o u d . a l i y u n c s . c o m / c e n t o s / basearch/ http://mirrors.cloud.aliyuncs.com/centos/ basearch/http://mirrors.cloud.aliyuncs.com/centos/releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#contrib - packages by Centos Users
[contrib]
name=CentOS- r e l e a s e v e r − C o n t r i b − m i r r o r s . a l i y u n . c o m f a i l o v e r m e t h o d = p r i o r i t y b a s e u r l = h t t p : / / m i r r o r s . a l i y u n . c o m / c e n t o s / releasever - Contrib - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/ releaseverContribmirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/releasever/contrib/ b a s e a r c h / h t t p : / / m i r r o r s . a l i y u n c s . c o m / c e n t o s / basearch/ http://mirrors.aliyuncs.com/centos/ basearch/http://mirrors.aliyuncs.com/centos/releasever/contrib/ b a s e a r c h / h t t p : / / m i r r o r s . c l o u d . a l i y u n c s . c o m / c e n t o s / basearch/ http://mirrors.cloud.aliyuncs.com/centos/ basearch/http://mirrors.cloud.aliyuncs.com/centos/releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

2).docker-ce.repo
[root@k8s-master yum.repos.d]# cat docker-ce.repo
[docker-ce-stable]
name=Docker CE Stable - b a s e a r c h b a s e u r l = h t t p s : / / m i r r o r s . a l i y u n . c o m / d o c k e r − c e / l i n u x / c e n t o s / 7 / basearch baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/ basearchbaseurl=https://mirrors.aliyun.com/dockerce/linux/centos/7/basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo b a s e a r c h b a s e u r l = h t t p s : / / m i r r o r s . a l i y u n . c o m / d o c k e r − c e / l i n u x / c e n t o s / 7 / d e b u g − basearch baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/debug- basearchbaseurl=https://mirrors.aliyun.com/dockerce/linux/centos/7/debugbasearch/stable
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/source/stable
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-edge]
name=Docker CE Edge - b a s e a r c h b a s e u r l = h t t p s : / / m i r r o r s . a l i y u n . c o m / d o c k e r − c e / l i n u x / c e n t o s / 7 / basearch baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/ basearchbaseurl=https://mirrors.aliyun.com/dockerce/linux/centos/7/basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-edge-debuginfo]
name=Docker CE Edge - Debuginfo b a s e a r c h b a s e u r l = h t t p s : / / m i r r o r s . a l i y u n . c o m / d o c k e r − c e / l i n u x / c e n t o s / 7 / d e b u g − basearch baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/debug- basearchbaseurl=https://mirrors.aliyun.com/dockerce/linux/centos/7/debugbasearch/edge
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-edge-source]
name=Docker CE Edge - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/source/edge
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-test]
name=Docker CE Test - b a s e a r c h b a s e u r l = h t t p s : / / m i r r o r s . a l i y u n . c o m / d o c k e r − c e / l i n u x / c e n t o s / 7 / basearch baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/ basearchbaseurl=https://mirrors.aliyun.com/dockerce/linux/centos/7/basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo b a s e a r c h b a s e u r l = h t t p s : / / m i r r o r s . a l i y u n . c o m / d o c k e r − c e / l i n u x / c e n t o s / 7 / d e b u g − basearch baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/debug- basearchbaseurl=https://mirrors.aliyun.com/dockerce/linux/centos/7/debugbasearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/source/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-nightly]
name=Docker CE Nightly - b a s e a r c h b a s e u r l = h t t p s : / / m i r r o r s . a l i y u n . c o m / d o c k e r − c e / l i n u x / c e n t o s / 7 / basearch baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/ basearchbaseurl=https://mirrors.aliyun.com/dockerce/linux/centos/7/basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-nightly-debuginfo]
name=Docker CE Nightly - Debuginfo b a s e a r c h b a s e u r l = h t t p s : / / m i r r o r s . a l i y u n . c o m / d o c k e r − c e / l i n u x / c e n t o s / 7 / d e b u g − basearch baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/debug- basearchbaseurl=https://mirrors.aliyun.com/dockerce/linux/centos/7/debugbasearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-nightly-source]
name=Docker CE Nightly - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/7/source/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

3) kubernetes.repo
[root@k8s-master yum.repos.d]# cat kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

4)epel.repo
[root@k8s-master yum.repos.d]# cat epel.repo
[epel]
name=EPEL for redhat/centos $releasever - b a s e a r c h b a s e u r l = h t t p : / / m i r r o r s . c l o u d . t e n c e n t . c o m / e p e l / basearch baseurl=http://mirrors.cloud.tencent.com/epel/ basearchbaseurl=http://mirrors.cloud.tencent.com/epel/releasever/$basearch/
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=http://mirrors.cloud.tencent.com/epel/RPM-GPG-KEY-EPEL-7

  1. 在master节点安装kubectl、kubeadm、kubelet、cri-tools,
    1) 版本可以指定,但是有些时候,可能版本过老,会导致安装时,无法找到相关的包,可以不指定版本直接安装最新的即可
    2)安装时,需要指定参数 --nogpgcheck,不然会安装失败
    yum install -y kubectl-1.18.1-0.x86_64 --nogpgcheck
    yum install -y cri-tools-1.13.0-0.x86_64 --nogpgcheck
    yum install -y kubeadm-1.18.1-0.x86_64 --nogpgcheck
    yum install -y kubelet-1.18.1-0.x86_64 --nogpgcheck

  2. 在master执行kubeadm init初始化之前需要配置daemon.json,不然也会出现问题
    1)daemon.json的内容和路径
    [root@k8s-master docker]# cat /etc/docker/daemon.json
    {
    “exec-opts”: [“native.cgroupdriver=systemd”],
    “log-driver”: “json-file”,
    “log-opts”: {
    “max-size”: “100m”
    },
    “storage-driver”: “overlay2”,
    “registry-mirrors”:[
    “https://kfwkfulq.mirror.aliyuncs.com”,
    “https://2lqq34jg.mirror.aliyuncs.com”,
    “https://pee6w651.mirror.aliyuncs.com”,
    “http://hub-mirror.c.163.com”,
    “https://docker.mirrors.ustc.edu.cn”,
    “https://registry.docker-cn.com”
    ]
    }
    2)配置完毕后,执行
    systemctl daemon-reload
    systemctl restart docker

  3. master和node节点的kubectl等组件部署完毕后,需要在master部署CNI节点
    1)下载calico.yaml ,执行
    curl https://docs.projectcalico.org/manifests/calico.yaml -O
    kubectl apply -f calico.yaml
    2)如果下载不可用可以在下面链接查看最新的下载路径
    https://docs.projectcalico.org/getting-started/kubernetes/self-managed-onprem/onpremises

  4. 部署完毕后,执行kubectl get pods -n kube-system后,pod节点不是running状态
    1) CrashLoopBackOff 解释和解决–重启node节点的docker服务解决(问题解释pod反复产生拉起该容器,但是一值未拉起成功)
    2)ImagePullBackOff 去相关node节点手动拉取相关镜像文件(相关镜像拉取失败)
    例如:
    calico-node-6wfc5 0/1 Init:ImagePullBackOff
    使用kubectl describe pod -n kube-system calico-node-6wfc5
    查看,能够查看到是哪个node节点,哪个镜像,哪个版本拉取失败,执行docker pull 相关镜像,可以拉取下来

20210521重新通过kubeadm部署k8s遇到了新的问题,进行分享记录:

  1. kubeadm init 初始化失败,提示的错误信息如下:
[root@master kubelet.service.d]# kubeadm init --apiserver-advertise-address=192.168.229.149 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.21.1 --service-cidr=10.1.0.0/16 --pod-network-cidr=10.244.0.0/16
[init] Using Kubernetes version: v1.21.1
[preflight] Running pre-flight checks
	[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
	[WARNING Hostname]: hostname "k8s-master" could not be reached
	[WARNING Hostname]: hostname "k8s-master": lookup k8s-master on 114.114.114.114:53: no such host
[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 registry.aliyuncs.com/google_containers/coredns/coredns:v1.8.0: output: Error response from daemon: pull access denied for registry.aliyuncs.com/google_containers/coredns/coredns, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
, error: exit status 1
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

1.) 解决方法说明:因为昨天初始化的时候,已经将相关的images镜像已经下载到本地了,所以百度查询资料后,通过修改镜像的tag标志解决该问题,如下:

1) 镜像信息如下:
root@k82-master ~]# docker images
REPOSITORY                                                        TAG        IMAGE ID       CREATED         SIZE
registry.aliyuncs.com/google_containers/kube-apiserver            v1.21.1    771ffcf9ca63   8 days ago      126MB
registry.aliyuncs.com/google_containers/kube-scheduler            v1.21.1    a4183b88f6e6   8 days ago      50.6MB
registry.aliyuncs.com/google_containers/kube-proxy                v1.21.1    4359e752b596   8 days ago      131MB
registry.aliyuncs.com/google_containers/kube-controller-manager   v1.21.1    e16544fd47b0   8 days ago      120MB
calico/node                                                       v3.19.0    b0744cc52c19   3 weeks ago     153MB
calico/pod2daemon-flexvol                                         v3.19.0    a5decf77918d   3 weeks ago     21.7MB
calico/cni                                                        v3.19.0    3d17cd6307a4   3 weeks ago     146MB
calico/kube-controllers                                           v3.19.0    c51610d08fdf   3 weeks ago     60.6MB
registry.aliyuncs.com/google_containers/kube-apiserver            v1.21.0    4d217480042e   6 weeks ago     126MB
registry.aliyuncs.com/google_containers/kube-proxy                v1.21.0    38ddd85fe90e   6 weeks ago     122MB
registry.aliyuncs.com/google_containers/kube-scheduler            v1.21.0    62ad3129eca8   6 weeks ago     50.6MB
registry.aliyuncs.com/google_containers/kube-controller-manager   v1.21.0    09708983cc37   6 weeks ago     120MB
registry.aliyuncs.com/google_containers/pause                     3.4.1      0f8457a4c2ec   4 months ago    683kB
coredns/coredns                                                   1.8.0      296a6d5035e2   7 months ago    42.5MB
registry.aliyuncs.com/google_containers/etcd                      3.4.13-0   0369cf4303ff   8 months ago    253MB
registry.aliyuncs.com/google_containers/pause                     3.2        80d28bedfe5d   15 months ago   683kB
registry.aliyuncs.com/google_containers/coredns                   1.6.7      67da37a9a360   15 months ago   43.8MB
registry.aliyuncs.com/google_containers/etcd                      3.4.3-0    303ce5db0e90   19 months ago   288MB
2) 通过kubeadm config images list 查看自己所安装kubelet所对应应该安装容器版本如下:
[root@k82-master ~]# kubeadm config images list
k8s.gcr.io/kube-apiserver:v1.21.1
k8s.gcr.io/kube-controller-manager:v1.21.1
k8s.gcr.io/kube-scheduler:v1.21.1
k8s.gcr.io/kube-proxy:v1.21.1
k8s.gcr.io/pause:3.4.1
k8s.gcr.io/etcd:3.4.13-0
k8s.gcr.io/coredns/coredns:v1.8.0
3) 通过修改docker images tag的方法来解决该问题(顺利解决)需要依次进行修改。修改完毕后,可以将阿里云的镜像进行删除,解除空间占用,不删除也不影响。
docker tag registry.aliyuncs.com/google_containers/kube-apiserver:v1.21.1  k8s.gcr.io/kube-apiserver:v1.21.1
4)  修改完毕后,镜像如下:
[root@k82-master ~]# docker images 
REPOSITORY                                                        TAG        IMAGE ID       CREATED         SIZE
k8s.gcr.io/kube-apiserver                                         v1.21.1    771ffcf9ca63   8 days ago      126MB
registry.aliyuncs.com/google_containers/kube-apiserver            v1.21.1    771ffcf9ca63   8 days ago      126MB
k8s.gcr.io/kube-proxy                                             v1.21.1    4359e752b596   8 days ago      131MB
registry.aliyuncs.com/google_containers/kube-proxy                v1.21.1    4359e752b596   8 days ago      131MB
k8s.gcr.io/kube-controller-manager                                v1.21.1    e16544fd47b0   8 days ago      120MB
registry.aliyuncs.com/google_containers/kube-controller-manager   v1.21.1    e16544fd47b0   8 days ago      120MB
k8s.gcr.io/kube-scheduler                                         v1.21.1    a4183b88f6e6   8 days ago      50.6MB
registry.aliyuncs.com/google_containers/kube-scheduler            v1.21.1    a4183b88f6e6   8 days ago      50.6MB
calico/node                                                       v3.19.0    b0744cc52c19   3 weeks ago     153MB
calico/pod2daemon-flexvol                                         v3.19.0    a5decf77918d   3 weeks ago     21.7MB
calico/cni                                                        v3.19.0    3d17cd6307a4   3 weeks ago     146MB
calico/kube-controllers                                           v3.19.0    c51610d08fdf   3 weeks ago     60.6MB
registry.aliyuncs.com/google_containers/kube-apiserver            v1.21.0    4d217480042e   6 weeks ago     126MB
registry.aliyuncs.com/google_containers/kube-proxy                v1.21.0    38ddd85fe90e   6 weeks ago     122MB
registry.aliyuncs.com/google_containers/kube-scheduler            v1.21.0    62ad3129eca8   6 weeks ago     50.6MB
registry.aliyuncs.com/google_containers/kube-controller-manager   v1.21.0    09708983cc37   6 weeks ago     120MB
k8s.gcr.io/pause                                                  3.4.1      0f8457a4c2ec   4 months ago    683kB
registry.aliyuncs.com/google_containers/pause                     3.4.1      0f8457a4c2ec   4 months ago    683kB
coredns/coredns                                                   1.8.0      296a6d5035e2   7 months ago    42.5MB
k8s.gcr.io/coredns/coredns                                        v1.8.0     296a6d5035e2   7 months ago    42.5MB
k8s.gcr.io/etcd                                                   3.4.13-0   0369cf4303ff   8 months ago    253MB
registry.aliyuncs.com/google_containers/etcd                      3.4.13-0   0369cf4303ff   8 months ago    253MB
registry.aliyuncs.com/google_containers/pause                     3.2        80d28bedfe5d   15 months ago   683kB
registry.aliyuncs.com/google_containers/coredns                   1.6.7      67da37a9a360   15 months ago   43.8MB
registry.aliyuncs.com/google_containers/etcd                      3.4.3-0    303ce5db0e90   19 months ago   288MB
  1. 进行kubeadm初始化,初始化成功,如下:
[root@k82-master ~]# kubeadm init --kubernetes-version=v1.21.1 --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12 --ignore-preflight-errors=Swap
[init] Using Kubernetes version: v1.21.1
[preflight] Running pre-flight checks
	[WARNING Hostname]: hostname "k82-master" could not be reached
	[WARNING Hostname]: hostname "k82-master": lookup k82-master on 114.114.114.114:53: no such host
[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'
[certs] Using certificateDir folder "/etc/kubernetes/pki"

[addons] Applied essential addon: CoreDNS
[addons] Applied essential addon: kube-proxy

Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

Alternatively, if you are the root user, you can run:

  export KUBECONFIG=/etc/kubernetes/admin.conf

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 192.168.229.149:6443 --token fkdwsz.2mdicz8hpxo9bg3l \
	--discovery-token-ca-cert-hash sha256:1f457fc9ebef7a05be88acb6ad058b1b42f55ca57ace0c42b7aa05716b88d32c 

该问题解决方法,参考文章链接如下:
https://blog.csdn.net/curry10086/article/details/107579113

  1. 遇到问题2:calico-node-ffcvx 容器一直未正常运行,日志提示信息如下:
[root@k82-master ~]# kubectl describe pod -n kube-system calico-node-ffcvx
  Warning  Unhealthy  24m   kubelet            Readiness probe failed: calico/node is not ready: BIRD is not ready: Error querying BIRD: unable to connect to BIRDv4 socket: dial unix /var/run/bird/bird.ctl: connect: no such file or directory
  Warning  Unhealthy  23m   kubelet            Readiness probe failed: 2021-05-21 11:49:08.357 [INFO][208] confd/health.go 180: Number of node(s) with BGP peering established = 0
calico/node is not ready: felix is not ready: Get "http://localhost:9099/readiness": dial tcp: lookup localhost on 114.114.114.114:53: no such host
  Warning  Unhealthy  23m  kubelet  Readiness probe failed: 2021-05-21 11:49:18.352 [INFO][243] confd/health.go 180: Number of node(s) with BGP peering established = 0
calico/node is not ready: felix is not ready: Get "http://localhost:9099/readiness": dial tcp: lookup localhost on 114.114.114.114:53: no such host
  Warning  Unhealthy  23m  kubelet  Readiness probe failed: 2021-05-21 11:49:28.348 [INFO][270] confd/health.go 180: Number of node(s) with BGP peering established = 0
calico/node is not ready: felix is not ready: Get "http://localhost:9099/readiness": dial tcp: lookup localhost on 114.114.114.114:53: no such host
  Warning  Unhealthy  23m  kubelet  Readiness probe failed: 2021-05-21 11:49:38.354 [INFO][305] confd/health.go 180: Number of node(s) with BGP peering established = 0
calico/node is not ready: felix is not ready: Get "http://localhost:9099/readiness": dial tcp: lookup localhost on 114.114.114.114:53: no such host
  Warning  Unhealthy  23m (x5 over 23m)  kubelet  Liveness probe failed: calico/node is not ready: Felix is not live: Get "http://localhost:9099/liveness": dial tcp: lookup localhost on 114.114.114.114:53: no such host
2) 问题原因: /etc/hosts文件中127.0.0.1和 localhostname的映射关系被我删除,导致该问题的出现,解决方法,在hosts文件中,加上映射关系,该问题解决。
[root@k82-master ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

``[root@k82-master ~]# kubectl get  pods -n kube-system 
NAME                                      READY   STATUS    RESTARTS   AGE
calico-kube-controllers-b656ddcfc-rjdhx   1/1     Running   0          25m
calico-node-ffcvx                         1/1     Running   3          25m
coredns-558bd4d5db-bd282                  1/1     Running   0          29m
coredns-558bd4d5db-hp9ht                  1/1     Running   0          29m
etcd-k82-master                           1/1     Running   0          30m
kube-apiserver-k82-master                 1/1     Running   1          30m
kube-controller-manager-k82-master        1/1     Running   0          30m
kube-proxy-2w4x7                          1/1     Running   0          29m
kube-scheduler-k82-master                 1/1     Running   0          30m

该问题解决办法查看文章链接
https://blog.csdn.net/u014554546/article/details/108793165

这篇文章是按照开头链接文章部署时,遇到的问题时,查阅资料所解决的坑。编写此文章进行记录,欢迎交流

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
对于在CentOS 7.5上安装Kubernetes (k8s),可以按照以下步骤进行操作: 1. 更新系统 ``` $ sudo yum update ``` 2. 禁用SELinux ``` $ sudo setenforce 0 $ sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config ``` 3. 关闭防火墙 ``` $ sudo systemctl stop firewalld $ sudo systemctl disable firewalld ``` 4. 安装Docker ``` $ sudo yum install -y docker $ sudo systemctl start docker $ sudo systemctl enable docker ``` 5. 添加Kubernetes仓库 ``` $ sudo tee /etc/yum.repos.d/kubernetes.repo <<EOF [kubernetes] name=Kubernetes baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg EOF ``` 6. 安装Kubernetes组件 ``` $ sudo yum install -y kubelet kubeadm kubectl $ sudo systemctl enable kubelet ``` 7. 初始化Kubernetes Master ``` $ sudo kubeadm init --pod-network-cidr=192.168.0.0/16 ``` 8. 设置kubectl配置 ``` $ mkdir -p $HOME/.kube $ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config $ sudo chown $(id -u):$(id -g) $HOME/.kube/config ``` 9. 安装网络插件(例如,Calico) ``` $ kubectl apply -f https://docs.projectcalico.org/v3.14/manifests/calico.yaml ``` 10. 加入其他节点(可选) ``` $ sudo kubeadm join <master-ip>:<master-port> --token <token> --discovery-token-ca-cert-hash <hash> ``` 安装完成后,您就可以使用kubectl命令来管理Kubernetes集群了。请注意,这只是一个基本的安装过程,具体的配置可能会根据您的需求和环境略有不同。建议您参考官方文档或其他资料以获取更多详细信息。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值