kubeadm搭建K8S集群小记

概述

一时兴起,尝试下K8S集群的搭建

步骤

请查看参考链接1

Q&A

Q: raw.githubusercontent.com被墙,导致kube-flannel.yml下不来

bash 复制代码
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

The connection to the server raw.githubusercontent.com was refused - did you specify the right host or port?

A:

请查看参考链接2


Q: Worker节点加入集群报错

bash 复制代码
[root@192 ~]# kubeadm join 192.168.0.109:6443 --token 24alfb.pv5eec2dtb6vh94e \
>     --discovery-token-ca-cert-hash sha256:3c5d6820ee64d1d818bdab58a2f86a1316b09e5218258e96401ce73b3b4928b6 --node-name k8s-worker
[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-worker" could not be reached
        [WARNING Hostname]: hostname "k8s-worker": lookup k8s-worker on 192.168.1.1:53: no such host
error execution phase preflight: [preflight] Some fatal errors occurred:
        [ERROR Swap]: running with swap on is not supported. Please disable swap
[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

A: Worker主机没有关闭交换内存导致的问题,执行"swapoff -a" 临时关闭内存后,重新执行成功


Q: Worker节点查看执行kubectl get pod报错

bash 复制代码
[root@192 ~]# kubectl get nodes
The connection to the server localhost:8080 was refused - did you specify the right host or port?

A: 将master节点中的/etc/kubernetes/admin.conf文件拷贝到Worker节点相同目录,然后执行以下命令

bash 复制代码
export KUBECONFIG=/etc/kubernetes/admin.conf

#设置用户环境变量,避免每次都需要export
#echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile

Q: 运行POD容器,报以下错误

bash 复制代码
[root@192 myservice]# kubectl run -it busybox --rm=true --image=busybox:1.28.4 -- /bin/sh
If you don't see a command prompt, try pressing enter.
Error attaching, falling back to logs: error dialing backend: dial tcp 192.168.0.112:10250: connect: no route to host
pod "busybox" deleted
Error from server: Get "https://192.168.0.112:10250/containerLogs/default/busybox/busybox": dial tcp 192.168.0.112:10250: connect: no route to host

A: 经过排查,是Worker主机没有关闭防火墙引起的问题

参考链接

  1. K8s 的 kubeadm 巨细安装,亲操可行!!
  2. Kubernetes 安装flannel组件(本地 kube-flannel.yml 文件)
  3. (29)笔记:在k8s集群节点执行kubectl报错的问题
相关推荐
昌sit!13 分钟前
K8S node节点没有相应的pod镜像运行故障处理办法
云原生·容器·kubernetes
A ?Charis3 小时前
Gitlab-runner running on Kubernetes - hostAliases
容器·kubernetes·gitlab
wclass-zhengge3 小时前
Docker篇(Docker Compose)
运维·docker·容器
北漂IT民工_程序员_ZG4 小时前
k8s集群安装(minikube)
云原生·容器·kubernetes
梦魇梦狸º7 小时前
腾讯轻量云服务器docker拉取不到镜像的问题:拉取超时
docker·容器·github
南猿北者9 小时前
docker镜像仓库常用命令
运维·docker·容器
2301_8061313610 小时前
Kubernetes的基本构建块和最小可调度单元pod-0
云原生·容器·kubernetes
SilentCodeY11 小时前
containerd配置私有仓库registry
容器·kubernetes·containerd·镜像·crictl
微刻时光11 小时前
Docker镜像分成
java·运维·开发语言·docker·容器·镜像
Walden-202013 小时前
构建基于 DCGM-Exporter, Node exporter,PROMETHEUS 和 GRAFANA 构建算力监控系统
docker·容器·grafana·prometheus