文章目录
- 前言
- 1、相关文档
- 2、环境说明
- 3、部署
-
- [3.1、安装 yum 工具包](#3.1、安装 yum 工具包)
- [3.2、安装 docker](#3.2、安装 docker)
- [3.3、安装 kubeadm,kubelet 和 kubectl](#3.3、安装 kubeadm,kubelet 和 kubectl)
- [3.4、安装 minikube](#3.4、安装 minikube)
前言
学习 Kubernetes 但是搭建集群太麻烦。怎么办? MiniKube 是个简单的好办法!
1、相关文档
2、环境说明
操作系统:Centos 7.6.1810
Docker 版本:25.0.1
kubelet 版本:v1.28.2
minikube 版本:v1.32.0
3、部署
注意:minikube 需要 docker、kvm2、podman、qemu2、virtualbox ,否则会提示如下信息
shell
minikube start
* minikube v1.32.0 on Centos 7.6.1810 (amd64)
* Unable to pick a default driver. Here is what was considered, in preference order:
* Alternatively you could install one of these drivers:
- docker: Not installed: exec: "docker": executable file not found in $PATH
- kvm2: Not installed: exec: "virsh": executable file not found in $PATH
- podman: Not installed: exec: "podman": executable file not found in $PATH
- qemu2: Not installed: exec: "qemu-system-x86_64": executable file not found in $PATH
- virtualbox: Not installed: unable to find VBoxManage in $PATH
X Exiting due to DRV_NOT_DETECTED: No possible driver was detected. Try specifying --driver, or see https://minikube.sigs.k8s.io/docs/start/
3.1、安装 yum 工具包
shell
yum install -y yum-utils
3.2、安装 docker
shell
# 配置源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# 验证配置是否成功
cd /etc/yum.repos.d && more docker-ce.repo
# 通过 yum 安装 docker
yum install docker-ce -y
# 启动 docker
systemctl start docker
# 开机启动
systemctl enable docker
# 验证 docker 是否启动
systemctl status docker
docker images
3.3、安装 kubeadm,kubelet 和 kubectl
shell
# 配置源
cat > /etc/yum.repos.d/kubernetes.repo << EOF
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
# 验证配置是否成功
cd /etc/yum.repos.d && more kubernetes.repo
# 安装
# 指定版本号
# yum install -y kubelet-1.23.0 kubeadm-1.23.0 kubectl-1.23.0
# 最新版
yum install -y kubelet kubeadm kubectl
# 启动
systemctl start kubelet
# 开机启动
systemctl enable kubelet
# 重启服务器
3.4、安装 minikube
shell
# 下载安装包
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-latest.x86_64.rpm
# 安装
rpm -Uvh minikube-latest.x86_64.rpm
# 普通账户启动
# minikube start
# root 账号使用 Docker
minikube start --force
# 第一次启动时间稍微有点长,需要 Downloading Kubernetes v1.28.3
# 验证
minikube status
# 说明:没有开机自启动,所以每次开机需要手动启动