k8s 学习笔记

这篇文章(5afd7ecef496bb0018d2e144)是从 Teambition 迁移过来的

安装 kubectl

启用命令自动补完 Zsh

官方文档: https://kubernetes.io/docs/tasks/tools/install-kubectl/

If you are using zsh edit the ~/.zshrc file and add the following code to enable kubectl autocompletion:

if [ $commands[kubectl] ]; then
  source <(kubectl completion zsh)
fi

Or when using Oh-My-Zsh, edit the ~/.zshrc file and update the plugins= line to include the kubectl plugin.

source <(kubectl completion zsh)

安装 minikube

官方文档:https://kubernetes.io/docs/tasks/tools/install-minikube/#install-minikube

因为网络的原因,国内安装要用阿里改过的版本,参考:

Mac 上安装 hyperkit driver

minikube 默认使用 virtualbox 起虚拟机,我的 mac 上装过 docker,所有可以使用 hyperkit,注意启动时需要加 --vm-driver hyperkit 参数

https://github.com/kubernetes/minikube/blob/master/docs/drivers.md#hyperkit-driver

如果出现错误可以尝试清除数据重新开始 rm -rf ~/.minikube

启动 minikube (使用 hyperkit)

如果不指定 –vm-driver 默认使用 virtualbox 启动

minikube start --registry-mirror=https://registry.docker-cn.com --vm-driver hyperkit

启动 Dashboard

minikube dashboard