当前位置: 首页 > article >正文

在RockyLinux9.4上安装Microk8s

在线安装Microk8s

1、安装snap

yum install -y epel-release
yum install -y snapd
systemctl enable --now snapd.socket
systemctl start snapd
ln -s /var/lib/snapd/snap /snap

2、安装microk8s

snap install microk8s --classic # 在RockyLinux9.4上, 默认下载Microk8s 1.31版本
snap install microk8s --classic --channel=1.31/stable # --channnel参数可以指定Microk8s的版本
snap alias microk8s.kubectl kubectl

3、安装microk8s插件(addons)

microk8s enable dns ingress metrics-server

成功安装后,通过kubectl查看Pod和Image

# kubectl get pods -A
kube-system   calico-node-srvfr                         1/1     Running   0          11m
kube-system   calico-kube-controllers-5b577d865-xwqjh   1/1     Running   0          11m
kube-system   coredns-64c6478b6c-fcvkk                  1/1     Running   0          23s
ingress       nginx-ingress-microk8s-controller-rqtj2   1/1     Running   0          32s
kube-system   metrics-server-679c5f986d-vb6z7           1/1     Running   0          53m

microk8s.ctr i list | grep -vw DIGEST | grep -v ^sha256 | grep -v @sha256 | awk '{print $1}'
coredns/coredns:1.10.1
docker.io/calico/cni:v3.25.1
docker.io/calico/kube-controllers:v3.25.1
docker.io/calico/node:v3.25.1
docker.io/coredns/coredns:1.10.1
registry.k8s.io/ingress-nginx/controller:v1.11.2
registry.k8s.io/metrics-server/metrics-server:v0.6.3
registry.k8s.io/pause:3.7

在线安装可能遇到的问题

问题1: pod启动失败, 通过kubectl -n kube-system describe pod 查到失败原因是下载镜像失败
解决方法: 使用microk8s.ctr从国内源下载镜像,再给镜像打个tag,需要下载的镜像如下:

k8s.gcr.io/pause:3.7
docker.io/calico/cni:v3.25.1
docker.io/calico/node:v3.25.1
docker.io/calico/kube-controllers:v3.25.1
docker.io/coredns/coredns:1.10.1
registry.k8s.io/ingress-nginx/controller:v1.11.2
registry.k8s.io/metrics-server/metrics-server:v0.6.3

从国内源下载镜像,再给镜像打tag

microk8s.ctr images pull swr.cn-north-4.myhuaweicloud.com/ddn-k8s/registry.k8s.io/pause:3.7
microk8s.ctr images tag  swr.cn-north-4.myhuaweicloud.com/ddn-k8s/registry.k8s.io/pause:3.7  registry.k8s.io/pause:3.7

microk8s.ctr images pull swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/calico/cni:v3.25.1
microk8s.ctr images tag  swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/calico/cni:v3.25.1  docker.io/calico/cni:v3.25.1

microk8s.ctr images pull swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/calico/node:v3.25.1
microk8s.ctr images tag  swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/calico/node:v3.25.1  docker.io/calico/node:v3.25.1

microk8s.ctr images pull swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/calico/kube-controllers:v3.25.1
microk8s.ctr images tag  swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/calico/kube-controllers:v3.25.1  docker.io/calico/kube-controllers:v3.25.1

microk8s.ctr images pull swr.cn-north-4.myhuaweicloud.com/ddn-k8s/registry.k8s.io/coredns/coredns:v1.10.1
microk8s.ctr images tag  swr.cn-north-4.myhuaweicloud.com/ddn-k8s/registry.k8s.io/coredns/coredns:v1.10.1  docker.io/coredns/coredns:1.10.1

microk8s.ctr images pull swr.cn-north-4.myhuaweicloud.com/ddn-k8s/registry.k8s.io/ingress-nginx/controller:v1.11.2
microk8s.ctr images tag  swr.cn-north-4.myhuaweicloud.com/ddn-k8s/registry.k8s.io/ingress-nginx/controller:v1.11.2  registry.k8s.io/ingress-nginx/controller:v1.11.2

microk8s.ctr images pull swr.cn-north-4.myhuaweicloud.com/ddn-k8s/registry.k8s.io/metrics-server/metrics-server:v0.6.3
microk8s.ctr images tag  swr.cn-north-4.myhuaweicloud.com/ddn-k8s/registry.k8s.io/metrics-server/metrics-server:v0.6.3  registry.k8s.io/metrics-server/metrics-server:v0.6.3

问题2: metrics-server启动失败, 'dial tcp XXX:10250: connect: no route to host"
解决方法:关闭防火墙,禁用SELinux

systemctl disable firewalld --now
setenforce 0
vim /etc/selinux/config
SELINX=enforcing这行改成SELINUX=permissive

离线安装Microk8s

1、在可联网的环境下载Microk8s的snap安装包

snap download microk8s --channel=1.31/stable # 下载指定版本1.31

2、将下载好的snap包传输到目标机器上,安装microk8s

snap ack microk8s_<版本号>.assert
snap install microk8s_<版本号>.snap --classic

3、启动Microk8s服务

microk8s start

4、在可联网的环境下载Microk8s插件的Image并导出

microk8s.ctr i list | grep -vw DIGEST | grep -v ^sha256 | grep -v @sha256 | awk '{print $1}'
k8s.gcr.io/pause:3.7
docker.io/calico/cni:v3.25.1
docker.io/calico/node:v3.25.1
docker.io/calico/kube-controllers:v3.25.1
docker.io/coredns/coredns:1.10.1
registry.k8s.io/ingress-nginx/controller:v1.11.2
registry.k8s.io/metrics-server/metrics-server:v0.6.3

microk8s.ctr i export cni.tar docker.io/calico/cni:v3.25.1
microk8s.ctr i export kube-controllers.tar docker.io/calico/kube-controllers:v3.25.1
microk8s.ctr i export .....

5、将image传到目标机器上并导入

microk8s.ctr image import *.tar

6、启动microk8s插件

microk8s enable dns ingress metrics-server
microk8s status --wait-ready

7、配置kubectl访问Microk8s

microk8s.kubectl config view --raw > $HOME/.kube/config

卸载microk8s

microk8s stop 
snap remove microk8s
rm -rf /root/.kube

http://www.kler.cn/a/419482.html

相关文章:

  • 使用flex布局实现一行固定展示n个元素
  • close and shutdown?
  • 蓝桥杯第 23 场 小白入门赛
  • SnowFlake
  • 日志与线程池
  • jQuery学习建议:从入门到精通的指南
  • Neo4j启动时指定JDK版本
  • Linux-异步IO和存储映射IO
  • C++《set与map》
  • websocket企业开发中常见问题及解决方案
  • 汽车软件单元测试的重要性
  • 基于Java Springboot房屋租赁App且微信小程序
  • 【LLM】Langchain+RAG大模型学习笔记
  • 什么是事件日志管理系统?事件日志管理系统有哪些用处?
  • Ollama离线迁移模型,不联网从一台电脑复制到另一台电脑
  • Vulnhub靶场 Matrix-Breakout: 2 Morpheus 练习
  • Ubuntu Linux操作系统
  • 语音助手利器:ChatTTS让AI语音更具情感与自然感告别机械音!
  • STL:相同Size大小的vector和list哪个占用空间多?
  • 详解:HTTP/HTTPS协议
  • 精通.NET鉴权与授权
  • 操作系统、虚拟化技术与云原生01
  • mini主机通过内网穿透做成服务器
  • MySQL技巧之跨服务器数据查询:进阶篇-从A服务器的MySQ数据库复制到B服务器的SQL Server数据库的表中
  • Linux:进程间通信之system V
  • 服务器数据恢复—服务器raid0阵列硬盘指示灯显示黄颜色的数据恢复案例