通过 minicube 安装 K8S

前置条件

1. 安装 minikube

1.1 使用 minikube 安装 K8S 服务端

参照 minikube quickstartopen in new window

# curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
# install minikube-linux-amd64 /usr/local/bin/minikube
1
2

使用非 root 账号(如 docker 账户)启动 minikube,因为 minicube 限制 docker 以 root 账户启动open in new window

❌ Exiting due to DRV_AS_ROOT: The "docker" driver should not be used with root privileges.

$ minikube start
1

如果你希望安装指定版本的 K8S,可以加上 --kubernetes-version='' The Kubernetes version that the minikube VM will use (ex: v1.2.3, 'stable' for v1.22.1, 'latest' for v1.22.2-rc.0). Defaults to 'stable'.

2.2 安装K8S客户端: kubectlopen in new window

# curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
# install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
1
2

验证下是否安装成功

$ kubectl  version
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.1", GitCommit:"632ed300f2c34f6d6d15ca4cef3d3c7073412212", GitTreeState:"clean", BuildDate:"2021-08-19T15:45:37Z", GoVersion:"go1.16.7", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.1", GitCommit:"632ed300f2c34f6d6d15ca4cef3d3c7073412212", GitTreeState:"clean", BuildDate:"2021-08-19T15:39:34Z", GoVersion:"go1.16.7", Compiler:"gc", Platform:"linux/amd64"}
1
2
3

查看已经部署的 Pod

$ kubectl get pod --all-namespaces
NAMESPACE     NAME                               READY   STATUS             RESTARTS       AGE
kube-system   coredns-78fcd69978-dhx5h           0/1     CrashLoopBackOff   15 (68s ago)   53m
kube-system   etcd-minikube                      1/1     Running            0              54m
kube-system   kube-apiserver-minikube            1/1     Running            0              54m
kube-system   kube-controller-manager-minikube   1/1     Running            0              54m
kube-system   kube-proxy-h4rnb                   1/1     Running            0              53m
kube-system   kube-scheduler-minikube            1/1     Running            0              54m
kube-system   storage-provisioner                1/1     Running            0              54m
1
2
3
4
5
6
7
8
9

FAQ

--image-repository='': Alternative image repository to pull docker images from. This can be used when you have

limited access to gcr.io. Set it to "auto" to let minikube decide one for you. For Chinese mainland users, you may use local gcr.io mirrors such as registry.cn-hangzhou.aliyuncs.com/google_containers

minikube dashboard 🤔 Verifying proxy health ...open in new window

sudo kubectl proxy --address='0.0.0.0' --accept-hosts='^*#39;

并且使用如下地址访问即可

http://xxx.xxx.xxx.xxx:8001/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy

访客IP: (, , 您的网络访问优先)