k3d#
rancher/k3d

常用命令#
k3d cluster create yewang-test-1 --subnet "172.27.1.0/24" --api-port 10.173.199.27:8701 --servers 1 --agents 2
k3d cluster create yewang-test-2 --subnet "172.27.2.0/24" --api-port 10.173.199.27:8702
k3d cluster delete cluster-1
k3d cluster delete cluster-2
cat << 'EOF' > k3d-config-cluster-1.yaml
apiVersion: k3d.io/v1alpha5
kind: Simple
metadata:
name: cluster-1
servers: 1
agents: 2
registries:
create:
name: registry-1
host: "127.0.0.1"
config: |
mirrors:
"docker.io":
endpoint:
- https://hub.kingye.me
"ghcr.io":
endpoint:
- https://ghcr.kingye.me
subnet: "172.27.1.0/24"
kubeAPI:
hostIP: "10.173.199.27"
hostPort: "8701"
EOF
k3d cluster create --config k3d-config-cluster-1.yaml --verbose
cat << 'EOF' > k3d-config-cluster-2.yaml
apiVersion: k3d.io/v1alpha5
kind: Simple
metadata:
name: cluster-2
servers: 1
agents: 2
registries:
create:
name: registry-2
host: "127.0.0.1"
config: |
mirrors:
"docker.io":
endpoint:
- https://hub.kingye.me
"ghcr.io":
endpoint:
- https://ghcr.kingye.me
subnet: "172.27.2.0/24"
kubeAPI:
hostIP: "10.173.199.27"
hostPort: "8702"
EOF
k3d cluster create --config k3d-config-cluster-2.yaml --verbose
k3d kubeconfig get cluster-1 > cluster-1-kubeconfig.yaml
k3d kubeconfig get cluster-2 > cluster-2-kubeconfig.yaml
k3d kubeconfig get cluster-3 > cluster-3-kubeconfig.yaml
k3d kubeconfig get cluster-4 > cluster-4-kubeconfig.yaml
k3d kubeconfig get cluster-5 > cluster-5-kubeconfig.yaml
export KUBECONFIG=~/.kube/config:cluster-1-kubeconfig.yaml:cluster-2-kubeconfig.yaml
kubectl config view --merge --flatten > ~/.kube/config
unset KUBECONFIG
kubectl config get-contexts
# k ctx
安装配置#
叶王 © 2013-2026 版权所有。如果本文档对你有所帮助,可以请作者喝饮料。