DropVPS Team
Writer: Cooper Reagan
How to install kubectl on CentOS 9

Table of Contents
kubectl is the essential command-line tool for managing Kubernetes clusters. Installing it on CentOS Stream 9 only takes a few steps using the official Kubernetes repository.
Step 1: Update System Packages
Start by updating your CentOS 9 server:
sudo dnf update -y
Step 2: Install Required Dependencies
Ensure your system can access HTTPS repositories:
sudo dnf install -y curl ca-certificates
Step 3: Add the Kubernetes Repository
Create the Kubernetes repo file:
sudo tee /etc/yum.repos.d/kubernetes.repo <<EOF
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/repodata/repomd.xml.key
EOF
Update repo list:
sudo dnf makecache
Step 4: Install kubectl
Install the latest stable kubectl release:
sudo dnf install -y kubectl
Verify installation:
kubectl version --client
You should see something like:
Client Version: v1.30.x
Step 5: Enable Command Auto-Completion (Optional)
For Bash:
echo "source <(kubectl completion bash)" >> ~/.bashrc
source ~/.bashrc
For Zsh:
echo "source <(kubectl completion zsh)" >> ~/.zshrc
source ~/.zshrc
Step 6: Test kubectl (Optional)
If your kubeconfig is already set:
kubectl get nodes
If nodes appear, kubectl is fully connected.
U
Loading...