记录下ubuntu部署K8S集群遇到的各种坑(非教程)

太久不用ubuntu了,今天准备在Ubuntu上搭个K8S集群,把遇到的问题记录一下,以后再看,先搭了再说

**

Master节点

**

1.之前一直为科学上网头疼,结果买了个美国的服务器,全解决~

2.写入文件

cat <<EOF> /etc/apt/sources.list.d/kubernetes.list
> deb http://apt.kubernetes.io/ kubernetes-xenial main
> EOF
this version of kubeadm only supports deploying clusters with the control plane version >= 1.19.0. Current version: v1.17.0
To see the stack trace of this error execute with --v=5 or higher

看到版本不对,我就把K8S赶紧换成1.19.0,结果pre-flight checks报错,要求至少要双核,唉, 重新来吧。

4.类似这样的错,需要apt-get install kubelet=1.11.3-00 (相应的版本, 我的是1.19)

[ERROR KubeletVersion]: the kubelet version is higher than the control plane version. This is not a supported version skew and may lead to a malfunctional cluster. Kubelet version: "1.12.0-rc.1" Control plane version: "1.11.3"

之后果然生成了

kubeadm join 10.200.0.12:6443 --token ***** \
    --discovery-token-ca-cert-hash sha256:*****

5.为什么是not ready呢?

root@VM-0-12-ubuntu:~# kubectl get nodes
NAME             STATUS     ROLES                  AGE     VERSION
vm-0-12-ubuntu   NotReady   control-plane,master   4m20s   v1.19.0
kubectl describe node vm-0-12-ubuntu
  Ready            False   Sat, 20 Mar 2021 06:55:57 +0800   Sat, 20 Mar 2021 06:50:31 +0800   KubeletNotReady              runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
root@VM-0-12-ubuntu:~# kubectl get pods -n kube-system
NAME                                     READY   STATUS    RESTARTS   AGE
coredns-74ff55c5b-9dq5n                  0/1     Pending   0          9m6s
coredns-74ff55c5b-g44sh                  0/1     Pending   0          9m6s
etcd-vm-0-12-ubuntu                      1/1     Running   0          9m5s
kube-apiserver-vm-0-12-ubuntu            1/1     Running   0          9m5s
kube-controller-manager-vm-0-12-ubuntu   1/1     Running   0          9m5s
kube-proxy-2z68q                         1/1     Running   0          9m6s
kube-scheduler-vm-0-12-ubuntu            1/1     Running   0          9m5s

安装下网络插件

kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
root@VM-0-12-ubuntu:~# kubectl get pods -n kube-system
NAME                                     READY   STATUS    RESTARTS   AGE
coredns-74ff55c5b-9dq5n                  0/1     Pending   0          11m
coredns-74ff55c5b-g44sh                  0/1     Pending   0          11m
etcd-vm-0-12-ubuntu                      1/1     Running   0          11m
kube-apiserver-vm-0-12-ubuntu            1/1     Running   0          11m
kube-controller-manager-vm-0-12-ubuntu   1/1     Running   0          11m
kube-proxy-2z68q                         1/1     Running   0          11m
kube-scheduler-vm-0-12-ubuntu            1/1     Running   0          11m
weave-net-7gnc5                          2/2     Running   1          20s

好像coredns还是没起来呢?
不过====了一会, 全都running了。果然是需要时间一步一步启动的。话说weave的pod要两个。

**

子节点

**

先安装docker和kubeadm
然后把刚才的node join跑一下

kubectl describe node VM-0-7-ubuntu

这些需要在主节点上看。

Taints:             node-role.kubernetes.io/master:NoSchedule

我在master运行了如下,反倒是把node的taints加上了
(自己试了一下,加上taints的话,比如master节点,之后再create deployment就会一直pending)

kubectl taint nodes --all node-role.kubernetes.io/master:NoSchedule

原来需要加个-号

kubectl taint nodes --all node-role.kubernetes.io/master:NoSchedule-

还报错refuse了
把配置文件复制下

安装完就可以看各个pod的状态了,不过没啥区别。多了个proxy的pod???

kubectl get pods -n kube-system

接下来挂载—这里涉及到了一个分布式存储知识Ceph
安装时报错:

error: unable to recognize "https://raw.githubusercontent.com/rook/rook/master/cluster/examples/kubernetes/ceph/cluster.yaml": no matches for kind "CephCluster" in version "ceph.rook.io/v1"

在github上找到解决方案 :github 传送门
首先使用 Rook 可以轻松实现在 Kubernetes 上部署并运行 Ceph 存储系统。Rook Operator 负责启动并监控整个底层存储系统,例如 Ceph Pod、Ceph OSD 等,同时它还管理 CRD、对象存储、文件体统。cephcluster 是一个 CRD 自定义资源类型,通过它来创建一些列 ceph 的 mgr、osd 等。所以创建cephcluster 之前,要先创建CRD。

可是我部署完hook为啥查不到NS呢?

root@VM-0-12-ubuntu:~# kubectl get pods -n rook-ceph-system
No resources found in rook-ceph-system namespace.

rook ceph倒是正常

root@VM-0-12-ubuntu:~# kubectl get pods -n rook-ceph
NAME                                          READY   STATUS    RESTARTS   AGE
csi-cephfsplugin-fbbf6                        3/3     Running   0          9m45s
csi-cephfsplugin-provisioner-bc5cff84-jh9qt   6/6     Running   0          9m44s
csi-cephfsplugin-provisioner-bc5cff84-xkknq   6/6     Running   0          9m44s
csi-cephfsplugin-xqd8g                        3/3     Running   0          9m45s
csi-rbdplugin-7srvw                           3/3     Running   0          9m45s
csi-rbdplugin-fnhfg                           3/3     Running   0          9m45s
csi-rbdplugin-provisioner-97957587f-7sspq     6/6     Running   0          9m45s
csi-rbdplugin-provisioner-97957587f-nz2fs     6/6     Running   0          9m45s
rook-ceph-operator-84c85574d9-d7t8l           1/1     Running   6          19m

这样,一个基于 Rook 持久化存储集群就以容器的方式运行起来了,而接下来在 Kubernetes 项目上创建的所有 Pod 就能够通过 Persistent Volume(PV)和 Persistent Volume Claim(PVC)的方式,在容器里挂载由 Ceph 提供的数据卷了。(I wish)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值