安裝minikube
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.18.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
安裝kubectl
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
啟動minikube
$ minikube start
Starting local Kubernetes cluster...
Starting VM...
SSH-ing files into VM...
Setting up certs...
Starting cluster components...
Connecting to cluster...
Setting up kubeconfig...
Kubectl is now configured to use the cluster.
minikube在啟動時衡蚂,需要下載gcr.io/google_containers/pause-amd64:3.0的image窿克,由于國內(nèi)的網(wǎng)絡(luò)原因,這個image下載不了毛甲,從而直接導(dǎo)致minikube不能用年叮,解決辦法是從阿里云下載這個image,然后重新tag
minikube ssh
docker pull registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0
docker tag registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0 gcr.io/google_containers/pause-amd64:3.0
重啟minikube
minikube stop
minikube start
創(chuàng)建httpd服務(wù)
$ kubectl run httpd --image=centos/httpd --port=80
$ kubectl expose deployment httpd --type=NodePort
檢查服務(wù)
使用默認瀏覽器打開
$ minikube service httpd
或者使用--url屬性獲取url
$ minikube service httpd --url
http://192.168.99.100:31730