华为云云耀云服务器L实例评测 | minikube部署和使用

### 1 安装Docker

按照官网[Docker docs](https://docs.docker.com/engine/install/centos/)指引安装:
``` shell
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依赖很多二进制,对于特定的操作系统,有些依赖可能已经安装,可以使用`yum install conntrack-tools --downloadonly --downloaddir=.`下载二进制,然后使用`rpm -ivh *.rpm`命令尝试安装,安装过程中会提示缺失的依赖,缺失的依赖包可以通过repotrack命令下载。


### 3 下载二进制: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。

### 4 准备镜像

下载下列镜像:

```
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
```

### 5 启动minikube

``` shell
minikube start --kubernetes-version=v1.21.11 --driver=none --cache-images=true
```

### 6 简单测试

``` shell
kubectl create deployment nginx --image=nginx
```

华为云云耀云服务器L实例评测 | minikube部署和使用_第1张图片

你可能感兴趣的:(服务器,运维,k8s)