目录
- 1 安装Docker
- 2 conntrack-tools
- 3 安装minikube
- 4 下载二进制:kubeadm、kubectl、kubelet
- 5 准备镜像
- 6 启动minikube
- 7 简单测试
Minikube 是一个使用golang开发的单节点kubernetes集群环境,在资源紧张的情况下,可以用于快速搭建kubernetes集群,甚至可以轻松在笔记本的虚拟机上快速拉起一个kubernetes集群,因此,非常适合用于开发和测试环境。
1 安装Docker
按照官网Docker docs指引安装:
yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
systemctl start docker
安装完成后,执行docker ps
命令有输出就说明docker安装成功。
2 conntrack-tools
conntrack-tools是一套Linux用户空间连接跟踪工具,用于系统管理员进行交互连接跟踪系统,iptables依赖该工具提供的连接跟踪能力。conntrack-tools依赖很多二进制,对于特定的操作系统,有些依赖可能已经安装,可以使用yum install conntrack-tools --downloadonly --downloaddir=.
下载二进制,然后使用rpm -ivh *.rpm
命令尝试安装,安装过程中会提示缺失的依赖,缺失的依赖包可以通过repotrack命令下载。
3 安装minikube
按照minikube安装minikube:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
install minikube-linux-amd64 /usr/local/bin/minikube
4 下载二进制:kubeadm、kubectl、kubelet
下载以下二进制文件:
- kubeadm:https://github.com/kubernetes/kubeadm/tags
- kubectl:https://github.com/kubernetes/kubectl/tags
- kubelet:https://github.com/kubernetes/kubelet/tags
下载后将二进制拷贝到~/.minikube/cache/linux/amd64/$K8S_VERSION
,这里的K8S_VERSION建议是1.21.11。
5 准备镜像
下载下列镜像:
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.21.11
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.21.11
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.21.11
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.21.11
registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.4.1
registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.4.13-0
registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:v1.8.0
registry.cn-hangzhou.aliyuncs.com/google_containers/storage-provisioner:v5
然后改为k8s.gcr.io仓库的对应镜像名:
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.21.11 k8s.gcr.io/kube-apiserver:v1.21.11
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.21.11 k8s.gcr.io/kube-scheduler:v1.21.11
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.21.11 k8s.gcr.io/kube-controller-manager:v1.21.11
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.21.11 k8s.gcr.io/kube-proxy:v1.21.11
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.4.1 k8s.gcr.io/pause:3.4.1
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.4.13-0 k8s.gcr.io/etcd:3.4.13-0
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/coredns:v1.8.0 k8s.gcr.io/coredns/coredns:v1.8.0
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/storage-provisioner:v5 gcr.io/k8s-minikube/storage-provisioner:v5
6 启动minikube
minikube start --kubernetes-version=v1.21.11 --driver=none --cache-images=true
7 简单测试
kubectl create deployment nginx --image=nginx