Kubernetes Minikube
CentOS7 安装 Minikube,用于学习使用,可以在一台节点上很方便的部署 K8S 集群环境
一、先决条件
安装Docker
安装kubelet kubeadm kubectl
安装升级Kubernetes基础组件kubelet kubeadm kubectl
二、安装 Minikube
https://minikube.sigs.k8s.io/docs/start/
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
三、启动
默认为单节点,可添加节点,https://minikube.sigs.k8s.io/docs/commands/node
minikube start
bash
minikube node list
minikube node add

访问:http://10.74.2.71:8888/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/#/overview?namespace=_all
minikube dashboard --url # 让其它 IP 可以访问
kubectl proxy --port=8888 --address='0.0.0.0' --accept-hosts='^.*'
四、部署应用与访问应用
kubectl create deployment nginx --image=nginx
kubectl expose deployment nginx --port=80 --type=NodePort
# 获取访问地址
minikube service --url nginx
# 也可以通过 kubectl proxy 拼接 url 访问,https://kubernetes.io/zh/docs/tasks/access-application-cluster/access-cluster/#manually-constructing-apiserver-proxy-urls
# http://10.74.2.71:8888/api/v1/namespaces/default/services/nginx:80/proxy/
bash
# 新开窗口运行
minikube tunnel --cleanup=true
# 重新部署
kubectl delete deployment nginx
kubectl delete service nginx
kubectl create deployment nginx --image=nginx
kubectl expose deployment nginx --port=80 --type=LoadBalancer
# 查看外部地址
kubectl get svc

五、卸载
https://minikube.sigs.k8s.io/docs/commands/delete
minikube stop
minikube delete --all
docker rmi kicbase/stable:v0.0.25
rm -rf ~/.kube ~/.minikube
sudo rm -rf /usr/local/bin/kubectl /usr/local/bin/minikube
docker system prune -a