安装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,由于国内的网络原因,这个image下载不了,从而直接导致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
创建httpd服务
$ kubectl run httpd --image=centos/httpd --port=80
$ kubectl expose deployment httpd --type=NodePort
检查服务
使用默认浏览器打开
$ minikube service httpd
或者使用--url属性获取url
$ minikube service httpd --url
http://192.168.99.100:31730