• Minikube
    • 在Mac上安装xhyve-driver
    • 安装kubectl
    • 启动Minikube
    • 停止Minikube
    • 参考

    Minikube

    Minikube用于在本地运行kubernetes环境,用来开发和测试。

    在Mac上安装xhyve-driver

    1. brew install docker-machine-driver-xhyve
    2. # docker-machine-driver-xhyve need root owner and uid
    3. sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
    4. sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve

    到 https://github.com/kubernetes/minikube/releases 下载 minikube,我安装的是minikube v0.22.3

    下载完成后修改文件名为minikube,然后chmod +x minikube,移动到$PATH目录下:

    1. mv ~/Download/minikube-darwin-adm64 /usr/loal/bin/
    2. chmod +x /usr/local/bin/minikube

    安装kubectl

    参考Install and Set Up kubectl,直接使用二进制文件安装即可。

    1. curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/darwin/amd64/kubectl
    2. 或者:
    3. 先访问https://storage.googleapis.com/kubernetes-release/release/stable.txt
    4. 得到返回值,假设为:v1.9.1,然后拼接网址,直接在浏览器访问:
    5. https://storage.googleapis.com/kubernetes-release/release/v1.9.1/bin/darwin/amd64/kubectl
    6. 直接下载kubectl文件。

    若第一种方式访问多次超时,可以使用上述的第二种方式访问。

    启动Minikube

    假设使用xhyve-driver虚拟技术,则需要在minikube start加入参数 --vm-driver=xhyve

    1. minikube start --vm-driver=xhyve
    2. Starting local Kubernetes v1.7.5 cluster...
    3. Starting VM...
    4. Downloading Minikube ISO
    5. 139.09 MB / 139.09 MB [============================================] 100.00% 0s
    6. Getting VM IP address...
    7. Moving files into cluster...
    8. Setting up certs...
    9. Connecting to cluster...
    10. Setting up kubeconfig...
    11. Starting cluster components...
    12. Kubectl is now configured to use the cluster.

    这将生成默认的~/.kube/config文件,自动指向minikube。

    停止Minikube

    1. minikube stop

    参考

    Running Kubernetes Locally via Minikube

    Install minikube

    Driver plugin installation - xhyve-driver