kubectl
cannot be installed via APT directly, following provider instructions we have two ways to install it:
- Via
kubectl
provider script: I don’t like this approach due tokubectl
will not automatically updated when you update APT packages normally. - Via SNAP: I don’t like using SNAP, additionally package management tool to support 🙁
So my preferred way is to add kubectl
repo to APT sources, to do that we need to add Kubernetes
archive keyring, then add Kubernetes repo APT source, finally just update APT repos & install kubectl
.
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
sudo apt update
sudo apt install kubectl
That’s all.