前言

KinD:单机测试K8s集群
源码:https://github.com/kubernetes-sigs/kind
官方文档:https://kind.sigs.k8s.io/docs/user/quick-start/


一、Linux安装

(base) destiny@destiny:~$ mkdir kind
(base) destiny@destiny:~$ cd kind
(base) destiny@destiny:~/kind$ curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.16.0/kind-linux-amd64
(base) destiny@destiny:~/kind$ chmod +x ./kind
(base) destiny@destiny:~/kind$ sudo mv ./kind /usr/local/bin/kind

验证安装:
输入kind version显示kind v0.16.0 go1.19.1 linux/amd64即可

二、安装docker

sudo apt-get update
sudo apt-get remove docker docker-engine docker.io
sudo apt install docker.io
sudo systemctl start docker

验证安装:
输入docker --version显示Docker version 24.0.5, build 24.0.5-0ubuntu1~22.04.1即可
输入docker images若报错

permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/json": dial unix /var/run/docker.sock: connect: permission denied

解决方法为:
添加docker的用户组,把当前用户加入组中。

sudo groupadd docker               #添加用户组
sudo gpasswd -a username docker    #将当前用户添加至用户组
newgrp docker                      #更新用户组

三、创建单节点集群

(base) destiny@destiny:~$ kind create cluster
Creating cluster "kind" ...
⢎⠁ Ensuring node image (kindest/node:v1.25.2) 🖼
 ✓ Ensuring node image (kindest/node:v1.25.2) 🖼
 ✓ Preparing nodes 📦
 ✓ Writing configuration 📜
 ✓ Starting control-plane 🕹️
 ✓ Installing CNI 🔌
 ✓ Installing StorageClass 💾
Set kubectl context to "kind-kind"
You can now use your cluster with:

kubectl cluster-info --context kind-kind

Have a nice day! 👋
(base) destiny@destiny:~$
(base) destiny@destiny:~$ kind get nodes
kind-control-plane
(base) destiny@destiny:~$ docker images
REPOSITORY     TAG       IMAGE ID       CREATED         SIZE
kindest/node   <none>    434e3cca4019   17 months ago   910MB

四、kubectl安装

Ubuntu:

snap install kubectl --classic
kubectl version --client

总结

X64 Ubuntu22.04关于docker,KinD,kubectl安装

Logo

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

更多推荐