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