2025-01-12 16:41:28 +01:00
|
|
|
# kubectl
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
### Install on Debian Linux
|
|
|
|
```
|
|
|
|
sudo apt install -y apt-transport-https ca-certificates curl gnupg
|
|
|
|
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.32/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
|
|
|
|
sudo chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg # allow unprivileged APT programs to read this keyring
|
|
|
|
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.32/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
|
|
|
|
sudo chmod 644 /etc/apt/sources.list.d/kubernetes.list # helps tools such as command-not-found to work correctly
|
|
|
|
sudo apt update
|
|
|
|
sudo apt install -y kubectl
|
|
|
|
```
|
|
|
|
|
|
|
|
### Shell completion
|
|
|
|
Source the `kubectl completion bash` in the ~/.bashrc file on every login. A simple line which does it after pasting into CMd:
|
|
|
|
```
|
|
|
|
echo 'source <(kubectl completion bash)' >> ~/.bashrc
|
|
|
|
```
|
|
|
|
|
2025-04-27 16:51:01 +02:00
|
|
|
[source](https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/)
|
|
|
|
|
|
|
|
### k alias kubectl
|
|
|
|
|
|
|
|
Simply add this to `~/.bashrc`
|
|
|
|
```
|
|
|
|
alias k=kubectl
|
|
|
|
complete -F __start_kubectl k
|
|
|
|
```
|
|
|
|
|
|
|
|
[source](https://github.com/boltops-learn-docs/kubernetes-tips/blob/main/k-alias.md)
|