Kubernetes 环境搭建 – MacOS

  • A+
所属分类:mac虚拟机

Kubernetes 环境搭建 - MacOS

准备工作

1、Mac 环境需求

Minikube 要求在 BIOS 中启用 VT-x / AMD-v 虚拟化, 要检查这是否在OSX / macOS上运行,请执行以下操作:

  1. sysctl -a | grep machdep.cpu.features | grep VMX

如果有输出,那你很棒棒!

2、【推荐】使用清华的 brew 景象源

  1. cd "$(brew --repo)"

  2. git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

  3. cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"

  4. git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

  5. brew update

相关软件安装

  • kubectl

  • docker (for Mac)

  • minikube

  • virtualbox

  1. brew update && brew install kubectl && brew cask install docker minikube virtualbox

校验软件版本信息

  1. docker --version                # Docker version 18.03.1-ce, build 9ee9f40

  2. docker-compose --version        # docker-compose version 1.21.1, build 5a3f1a3

  3. docker-machine --version        # docker-machine version 0.14.0, build 89b8332

  4. minikube version                # minikube version: v0.26.1

  5. kubectl version --client        # Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.1", GitCommit:"d4ab47518836c750f9949b9e0d387f20fb92260b", GitTreeState:"clean", BuildDate:"2018-04-13T22:28:25Z", GoVersion:"go1.9.5", Compiler:"gc", Platform:"darwin/amd64"}

开始

1、启动 kubernetes 集群

  1. minikube start --bootstrapper=localkube

一会后,会有如下输出

  1. Starting local Kubernetes v1.10.0 cluster...

  2. Starting VM...

  3. Downloading Minikube ISO

  4. 150.53 MB / 150.53 MB [============================================] 100.00% 0s

  5. Getting VM IP address...

  6. WARNING: The localkube bootstrapper is now deprecated and support for it

  7. will be removed in a future release. Please consider switching to the kubeadm bootstrapper, which

  8. is intended to replace the localkube bootstrapper. To disable this message, run

  9. [minikube config set ShowBootstrapperDeprecationNotification false]

  10. Moving files into cluster...

  11. Downloading localkube binary

  12. 173.54 MB / 173.54 MB [============================================] 100.00% 0s

  13. 0 B / 65 B [----------------------------------------------------------]   0.00%

  14. 65 B / 65 B [======================================================] 100.00% 0sSetting up certs...

  15. Connecting to cluster...

  16. Setting up kubeconfig...

  17. Starting cluster components...

  18. Kubectl is now configured to use the cluster.

  19. Loading cached images from config file.

恭喜!Minikube 为你启动了一个虚拟机,并在该虚拟机中运行了 Kubernetes 集群。

2、查看集群节点信息

  1.  ~ kubectl get nodes

  2. NAME       STATUS    ROLES     AGE       VERSION

  3. minikube   Ready     <none>    15m       v1.10.0

常见问题及解决办法

1、kubectl 安装失败

  1. brew install kubectl

  2. Updating Homebrew...

  3. ==> Auto-updated Homebrew!

  4. Updated 2 taps (caskroom/cask, homebrew/core).

  5. ==> Updated Formulae

  6. pandoc-citeproc                                                   php                                                               php@7.0

  7. Error: Failed to link all completions, docs and manpages:

  8.  Permission denied @ rb_file_s_symlink - (../../../Homebrew/completions/zsh/_brew, /usr/local/share/zsh/site-functions/_brew)

  9. Warning: kubernetes-cli 1.10.1 is already installed, it's just not linked

  10. You can use `brew link kubernetes-cli` to link this version.

解决办法

  1. sudo chown -R $(whoami) /usr/local/share/

  2. brew link kubernetes-cli


推荐:

上一篇:




最好的赞赏

就是你的关注

Kubernetes 环境搭建 - MacOS


avatar

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: