k3d

k3d #

rancher/k3d Github stars Github forks Language Last Tag Last commit

常用命令 #

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://docker.1panel.live
          - https://hub.rat.dev
          - https://docker.anyhub.us.kg
          - https://docker.chenby.cn
          - https://dockerhub.jobcher.com
          - https://docker.awsl9527.cn
          - https://docker.m.daocloud.io
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://docker.1panel.live
          - https://hub.rat.dev
          - https://docker.anyhub.us.kg
          - https://docker.chenby.cn
          - https://dockerhub.jobcher.com
          - https://docker.awsl9527.cn
          - https://docker.m.daocloud.io
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

安装配置 #


本文访问量

本站总访问量

本站总访客数