一、先要安装docker,官网(https://docs.docker.com/engine/install/)有教程,一步步操作即可,或者直接用以下命令直接自动安装
1 |
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun |
二、按照minikube官网(https://minikube.sigs.k8s.io/docs/start/#install-a-hypervisor)的教程安装minikube
1 2 |
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 sudo install minikube-linux-amd64 /usr/local/bin/minikube |
完成后执行启动命令
minikube start
后续操作见官网教程,这里不再赘述
三、常见报错
1、Exiting due to RSRC_INSUFFICIENT_CORES: Requested cpu count 2 is greater than the available cpus of 1
服务器最低要求:2 CPUs or more,2GB of free memory
2、安装完docker, 安装完minikube, 依然不能启动
报错内容为
Exiting due to DRV_AS_ROOT: The “docker” driver should not be used with root privileges
所以要创建新的非 root 用户
1 2 3 |
adduser g paswd g visudo |
在 allow root 那一栏添加 username ALL=(ALL) ALL
从 root 切换普通用户为 su – g 启动docker
3、报错unable to do port forwarding: socat not found
1 |
yum install -y socat |
4、如果查看Pod的状态,发现状态为 ErrImagePull 或者 ImagePullBackOff:
1 |
kubectl get pods |
NAME READY STATUS RESTARTS AGE
fail-1034443984-jerry 0/1 ImagePullBackOff 0 2m
可以使用describe命令查看这个失败的Pod的明细:
1 |
kubectl describe pod fail-1034443984-jerry |
我这里是发现虚拟机无法连接k8s.gcr.io/echoserver:1.4相应的网址,应该是国内安全上网原因,换成国外云机就可以了,或者自行修改对应的国内源
5、Minikube启动Dashboard后默认只能localhost访问,如果需要开放外部访问需要添加一层代理
启动Dashbord
1 |
minikube dashboard |
使用proxy代理到虚拟机的指定端口
1 |
kubectl proxy --port=7080 --address=‘172.19.0.6’ --accept-hosts=’^.*’ & |
启动后外部访问链接:
1 |
http://172.19.0.6:7080/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/#/overview?namespace=default |