石小疯 发表于 2024-9-5 19:19:38

虚拟机使用minikube搭建k8s集群

一、安装docker(目前登录的是root用户)

1、下载 https://download.docker.com/linux/centos/7/x86_64/stable/Packages/

本次使用 20.10.9版本
2、解压

tar xfz docker-20.10.9.tgz3、复制到 /usr/bin

cp -rf docker/* /usr/bin/4、将docker注册为系统服务

vi /usr/lib/systemd/system/docker.service写入内容
点击查看内容
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target

Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by do cker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=onfailure
StartLimitBurst=3
StartLimitInterval=60s

WantedBy=multi-user.target保存
5、添加文件权限

chmod u+x /usr/lib/systemd/system/docker.service6、重载unit配置文件

systemctl daemon-reload7、启动docker

systemctl enable docker8、查看docker状态

systemctl status docker二、安装kubectl v1.30.0

1、新建用户

useradd kube2、给予权限

vi /etc/sudoers在这两行下面
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL添加内容
kube   ALL=(ALL)       NOPASSWD:ALL保存,这里必要强制保存 wq!
3、切换用户

su kube接下来所有操纵都是kube用户
4、新建组docker,kube用户加入docker组

sudo groupadd docker
sudo usermod -aG docker $USER && newgrp docker5、下载

curl -LO https://dl.k8s.io/release/v1.30.0/bin/linux/amd64/kubectl6、安装 kubectl

sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl7、测试是否安装成功

kubectl version --client三、安装minikube

1、下载(如果不能下载去阿里云下载)

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd642、安装

sudo install minikube-linux-amd64 /usr/local/bin/minikube && rm minikube-linux-amd643、测试是否安装成功

minikube version4、启动

minikube start启动过程大抵如下,会自动拉取镜像
https://img2024.cnblogs.com/blog/1486494/202409/1486494-20240905103250134-1703757945.png

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: 虚拟机使用minikube搭建k8s集群