KVMandDock

从上图可以看出什么来吗?

kind,kubernetes in docker。kind基于 Docker 而不是虚拟化(对比Minikube),不是打包一个虚拟化镜像,而是直接将k8s 组件运行在 Docker。

带来了什么好处呢?

  1. 不需要运行 GuestOS 占用资源更低。
  2. 不基于虚拟化技术,可以在 VM 中使用。
  3. 文件更小,更利于移植。

NOTE:kind does not require kubectl,but you will not be able to perform some of the examples in our docs without it。

kubectl:The Kubernetes command-line tool,allows you to run commands against Kubernetes clusters。You can use kubectl to deploy applications,inspect and manage cluster resources,and view logs。

继续上kind的运行架构图,加深理解

我的主机环境:


 

步骤一、安装Docker 

Step 1: 更换国内软件源

Step 2: 安装必要工具

sudo apt-get install apt-transport-https ca-certificates software-properties-common curl

Step 3: 安装GPG证书(密钥),并且添加Docker-ce软件源信息

官方源(很慢不推荐):

curl -fsSL https://download.docker.com/linux/ubuntu/gpg|sudo apt-key add -

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

阿里云软件源(推荐)

curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

Step 4: 更新并安装Docker-ce

sudo apt-get update
sudo apt-get install docker-ce

Step 5: 测试运行

sudo docker run hello-world

Step 6: 将当前用户添加到 docker 组,可以不用sudo运行docker

# 将当前用户添加到 docker 组
sudo gpasswd -a ${USER} docker

# 重新登录或者用以下命令切换到docker组
newgrp - docker

# 重启docker服务
sudo service docker restart

# 不加sudo直接执行docker命令检查效果
docker ps

步骤二、安装kubectl(可选)

snap install kubectl --classic

# 查看kubectl版本
kubectl version --client

步骤二、安装kind

curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.10.0/kind-linux-amd64
chmod +x ./kind

# 我把kind给mv到${HOME}/.local/bin了
mv ./kind /some-dir-in-your-PATH/kind

创建一个单节点的k8s环境

kind create cluster

创建成功

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐