k3d创建k3s集群
安装go
wget https://golang.google.cn/dl/go1.21.3.linux-amd64.tar.gz
tar zxvf go1.15.3.linux-amd64.tar.gz
mv go /usr/local/
vim /etc/profile在最结尾添加
export HOME=/root
export GOROOT=/usr/local/go
export GOPATH=/opt/idcus/go
export PATH=$PATH:$GOPATH/bin:$GOROOT/bin
source /etc/profile
go version #查看是否生效
go env -w GOPROXY=https://goproxy.cn,direct #go设置镜像源
安装k3d
安装k3d
go install github.com/k3d-io/k3d/v5@latest
查看版本
root@BZD27274:~# k3d --version
k3d version v5-dev
k3s version v1.21.7-k3s1 (default)
使用k3d
由于我使用的是wsl2,提前在windows上安装了dockerdesktop,因此自带kubectl
创建/删除demo集群
k3d cluster create demo
k3d cluster delete demo
k3d cluster list
root@BZD27274:~# k3d cluster create demo
INFO[0000] Prep: Network
INFO[0000] Created network 'k3d-demo'
INFO[0000] Created image volume k3d-demo-images
INFO[0000] Starting new tools node...
INFO[0001] Creating node 'k3d-demo-server-0'
INFO[0003] Pulling image 'ghcr.io/k3d-io/k3d-tools:latest'
INFO[0005] Pulling image 'docker.io/rancher/k3s:v1.21.7-k3s1'
INFO[0203] Creating LoadBalancer 'k3d-demo-serverlb'
INFO[0206] Pulling image 'ghcr.io/k3d-io/k3d-proxy:latest'
INFO[0842] Starting Node 'k3d-demo-tools'
INFO[1307] Using the k3d-tools node to gather environment information
INFO[1307] Starting new tools node...
INFO[1307] Starting Node 'k3d-demo-tools'
INFO[1309] Starting cluster 'demo'
INFO[1309] Starting servers...
INFO[1309] Starting Node 'k3d-demo-server-0'
INFO[1316] All agents already running.
INFO[1316] Starting helpers...
INFO[1317] Starting Node 'k3d-demo-serverlb'
INFO[1324] Injecting records for hostAliases (incl. host.k3d.internal) and for 3 network members into CoreDNS configmap...
INFO[1326] Cluster 'demo' created successfully!
INFO[1326] You can now use it like this:
kubectl cluster-info
获取k3s节点
root@BZD27274:~# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k3d-demo-server-0 Ready control-plane,master 2m17s v1.21.7+k3s1
每个人都有潜在的能量,只是很容易被习惯所掩盖,被时间所迷离,被惰性所消磨~