若是使用正式的 k8s,那咱們可能須要花不少錢買服務器才能夠,因此咱們選擇一個簡單易用的,輕量的,能夠在本地環境全量試驗 k8s 的環境。
網上有不少種,我選擇 kind,它知足我以上說的全部要求,使用 docker 運行,其餘的 minikube 較重使用虛擬機構建,k3s 合併了不少功能,不能方便的體現 k8s 的各類概念。node
官方推薦 4 種方式git
1.在macOS / Linux上:github
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.6.0/kind-$(uname)-amd64 chmod +x ./kind mv ./kind /some-dir-in-your-PATH/kind
2.在Mac上經過Homebrew:docker
brew install kind
3.在Windows上:shell
curl.exe -Lo kind-windows-amd64.exe https://github.com/kubernetes-sigs/kind/releases/download/v0.6.0/kind-windows-amd64 Move-Item .\kind-windows-amd64.exe c:\some-dir-in-your-PATH\kind.exe
4.Chocolatey (https://chocolatey.org/packag...windows
choco install kind
5.使用網頁或者下載程序下載
我推薦第 5 種,由於牆的緣由,不少時候咱們用命令會下載不成功,或者下載回來的,不是正確的程序,我下載回來後一直執行錯誤,cat kind
一看,原來文件是空的。最後經過瀏覽器下載回來,移動到 /usr/local/bin
目錄,安裝成功。api
➜ kind kind kind creates and manages local Kubernetes clusters using Docker container 'nodes' Usage: kind [command] Available Commands: build Build one of [base-image, node-image] completion Output shell completion code for the specified shell (bash or zsh) create Creates one of [cluster] delete Deletes one of [cluster] export exports one of [kubeconfig, logs] get Gets one of [clusters, nodes, kubeconfig] help Help about any command load Loads images into nodes version prints the kind CLI version Flags: -h, --help help for kind --loglevel string DEPRECATED: see -v instead -q, --quiet silence all stderr output -v, --verbosity int32 info log verbosity --version version for kind Use "kind [command] --help" for more information about a command.
➜ kind kind create cluster --name kind-1 Creating cluster "kind" ... ✓ Ensuring node image (kindest/node:v1.16.3) 🖼 ✓ Preparing nodes 📦 ✓ Writing configuration 📜 ✓ Starting control-plane 🕹️ ✓ Installing CNI 🔌 ✓ Installing StorageClass 💾 Set kubectl context to "kind-kind-1" You can now use your cluster with: kubectl cluster-info --context kind-kind-1 Have a nice day! 👋
若是不指定 --name kind-1
默認名稱爲 kind
。瀏覽器
➜ kind kind get clusters kind-1
獲取全部集羣bash
➜ kind kubectl cluster-info --context kind-kind-1 Kubernetes master is running at https://127.0.0.1:61230 KubeDNS is running at https://127.0.0.1:61230/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'. ➜ kind kind delete cluster
kind delete cluster --name kind-kind-2 Deleting cluster "kind-kind-2" ...
若是不指定,默認刪除 kind-kind
。服務器