天天一点 Kubernetes(k8s)--1

天天一点 Kubernetes(k8s)--1

环境搭建

若是使用正式的 k8s,那咱们可能须要花不少钱买服务器才能够,因此咱们选择一个简单易用的,轻量的,能够在本地环境全量试验 k8s 的环境。
网上有不少种,我选择 kind,它知足我以上说的全部要求,使用 docker 运行,其余的 minikube 较重使用虚拟机构建,k3s 合并了不少功能,不能方便的体现 k8s 的各类概念。node

下载 kind

官方推荐 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服务器

相关文章
相关标签/搜索