kubernetes-handbook/develop/minikube.md

62 lines
1.9 KiB
Markdown
Raw Normal View History

2017-10-23 19:08:33 +08:00
# Minikube
Minikube用于在本地运行kubernetes环境用来开发和测试。
## 在Mac上安装xhyve-driver
```bash
brew install docker-machine-driver-xhyve
2017-10-23 19:08:33 +08:00
# docker-machine-driver-xhyve need root owner and uid
sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
2017-10-23 19:08:33 +08:00
```
到 https://github.com/kubernetes/minikube/releases 下载 minikube我安装的是minikube v0.22.3
下载完成后修改文件名为`minikube`,然后`chmod +x minikube`,移动到`$PATH`目录下:
```bash
mv ~/Download/minikube-darwin-adm64 /usr/loal/bin/
chmod +x /usr/local/bin/minikube
```
## 安装kubectl
参考[Install and Set Up kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/),直接使用二进制文件安装即可。
```bash
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/darwin/amd64/kubectl
```
## 启动Minikube
```bash
minikube start
Starting local Kubernetes v1.7.5 cluster...
Starting VM...
Downloading Minikube ISO
139.09 MB / 139.09 MB [============================================] 100.00% 0s
Getting VM IP address...
Moving files into cluster...
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
```
这将生成默认的`~/.kube/config`文件自动指向minikube。
## 停止Minikube
```bash
minikube stop
```
## 参考
[Running Kubernetes Locally via Minikube](https://kubernetes.io/docs/getting-started-guides/minikube/)
[Install minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/)
[Driver plugin installation - xhyve-driver](https://github.com/kubernetes/minikube/blob/master/docs/drivers.md#xhyve-driver)