kubectl是一个命令行工具,可以使用它来部署和管理 Kubernetes 集群。
安装说明 https://v1-29.docs.kubernetes.io/zh-cn/docs/tasks/tools/install-kubectl-linux/
查看最新静态版本
https://storage.googleapis.com/kubernetes-release/release/stable.txt
https://dl.k8s.io/release/stable.txt
https://cdn.dl.k8s.io/release/stable.txt
安装说明 https://v1-29.docs.kubernetes.io/zh-cn/docs/tasks/tools/install-kubectl-linux/
apt-get update && apt-get install -y apt-transport-https
curl -fsSL https://mirrors.aliyun.com/kubernetes-new/core/stable/v1.29/deb/Release.key |
gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://mirrors.aliyun.com/kubernetes-new/core/stable/v1.29/deb/ /" |
tee /etc/apt/sources.list.d/kubernetes.list
apt-get update
#apt-get install -y kubelet kubeadm kubectl
apt-cache madison kebuctl
apt-get install -y kubectl=1.29.6-1.1
#centos
yum install -y kubectl
https://storage.googleapis.com/kubernetes-release/release/v1.29.3/bin/linux/amd64/kubectl
https://dl.k8s.io/release/v1.29.3/bin/linux/amd64/kubectl
#手工安装
#curl https://storage.googleapis.com/kubernetes-release/release/v1.29.3/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl
wget https://storage.googleapis.com/kubernetes-release/release/v1.29.3/bin/linux/amd64/kubectl
cp kubectl /usr/local/bin/kubectl
chmod +x /usr/local/bin/kubectl
安装说明:
https://v1-29.docs.kubernetes.io/zh-cn/docs/tasks/tools/install-kubectl-windows/
下载
https://storage.googleapis.com/kubernetes-release/release/v1.29.3/bin/windows/amd64/kubectl.exe
https://dl.k8s.io/release/v1.29.3/bin/windows/amd64/kubectl.exe
下载完后,将二进制文件添加到PATH中即可
#自动选择版本
curl https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/windows/amd64/kubectl.exe
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
将下载的文件重命名为kubectl.exe
将 kubectl.exe 添加到系统路径中
#验证安装是否成功
kubectl version --client来
brew install kubectl
https://v1-29.docs.kubernetes.io/zh-cn/docs/tasks/tools/install-kubectl-windows/
为了kubectl 能发现并访问 Kubernetes 集群,你需要一个 kubeconfig 文件
#检查是否已恰当地配置了 kubectl
kubectl cluster-info
#调试检查配置信息
kubectl cluster-info dump
https://v1-29.docs.kubernetes.io/zh-cn/docs/tasks/tools/install-kubectl-linux/
#安装 bash-completion
apt-get install bash-completion
或
yum install bash-completion
source /usr/share/bash-completion/bash_completion
echo 'source <(kubectl completion bash)' >>~/.bashrc
echo 'alias k=kubectl' >>~/.bashrc
echo 'alias kb=k0s kubectl' >>~/.bashrc #命令待测试
source ~/.bashrc