From 519e7bd3998bc6ce952564a34ef6680ec798685f Mon Sep 17 00:00:00 2001 From: Jeffery Date: Fri, 6 Mar 2026 02:53:45 +0000 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20Service=EF=BC=9Ak3d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Service%EF%BC%9Ak3d.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Service%EF%BC%9Ak3d.md diff --git a/Service%EF%BC%9Ak3d.md b/Service%EF%BC%9Ak3d.md new file mode 100644 index 0000000..4d687e2 --- /dev/null +++ b/Service%EF%BC%9Ak3d.md @@ -0,0 +1,29 @@ +# 安裝 kubectl & k3d + +```bash +apt update \ +&& apt install -y curl \ +&& wget "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" -O /usr/local/bin/kubectl \ +&& chmod +x /usr/local/bin/kubectl \ +&& curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash +``` + +# 建立 1 個伺服器 2 個代理 + +```bash +k3d cluster create ct \ +--servers 1 \ +--agents 2 \ +--port 80:80@loadbalancer \ +--port 443:443@loadbalancer \ +--k3s-arg '--kubelet-arg=feature-gates=KubeletInUserNamespace=true@server:*' \ +--k3s-arg '--kubelet-arg=feature-gates=KubeletInUserNamespace=true@agent:*' \ +--volume /var/run/docker.sock:/var/run/docker.sock \ +--registry-create k3d-ct-registry:5000 +``` + +# 驗證節點 + +```bash +kubectl get nodes +``` \ No newline at end of file