> [官网安装](https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/) > > 推荐使用snap方式安装 ### 1. 二进制包方式安装 #### 1.1 下载二进制包 ```bash curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" ``` #### 1.2 安装二进制包 ```bash sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl ``` ### 2.1 包管理器安装 #### 2.1 必要组件安装 ```bash sudo apt-get update sudo apt-get install -y ca-certificates curl ``` #### 2.2 添加软件源 ```bash curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-archive-keyring.gpg echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list ``` #### 2.3 更新软件源&&安装kubectl ```bash sudo apt-get update sudo apt-get install -y kubectl ``` ### 3 snap包安装 ```bash sudo snap install kubectl --classic ```