Skip to main content
πŸ“¬ Get weekly Production AI insights Practical notes on Kubernetes, AI infrastructure and platform engineering. No spam. Subscribe free
DevOps

Install kubectl on Rocky Linux 9: Complete Guide (2026)

Step-by-step guide to install kubectl on Rocky Linux 9. Repository setup, installation, configuration, and verification.

Luca Berton

Β· AI Advisor & Architect

Published Β· 1 min read

Here is how to install kubectl on Rocky Linux 9. Tested and verified.

Prerequisites

  • Rocky Linux 9 installed and updated
  • Root or sudo access
  • Internet connection

Step 1: Update System

sudo dnf update -y

Step 2: Add Official Repository

kubectl should be installed from the official Kubernetes package repository so you get the latest stable version and security updates.

# Create the Kubernetes repository definition
# This overwrites any existing configuration in /etc/yum.repos.d/kubernetes.repo
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v1.36/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.36/rpm/repodata/repomd.xml.key
EOF

v1.36 selects the Kubernetes 1.36 package repository, the current stable minor version at the time of writing. To track a different minor version, replace v1.36 in both the baseurl and gpgkey lines, then re-run dnf update.

Step 3: Install kubectl

sudo dnf install -y kubectl

dnf reads the gpgkey URL from the repo file and imports/trusts the signing key automatically during install.

Step 4: Verify Installation

kubectl version --client

Expected output should show the installed client version.

Step 5: Enable Shell Completion

kubectl is a standalone CLI binary β€” it has no daemon and nothing to enable or start with systemd. Instead, set up Bash completion so you get tab-completion for commands, flags, and resource names.

# Install bash-completion if it isn't already present
sudo dnf install -y bash-completion

# Enable kubectl completion for the current user
echo 'source <(kubectl completion bash)' >> ~/.bashrc
echo 'alias k=kubectl' >> ~/.bashrc
echo 'complete -o default -F __start_kubectl k' >> ~/.bashrc
source ~/.bashrc

Troubleshooting

GPG Key Import Failed

If dnf install reports a GPG key retrieval or signature error, confirm the repo file has the correct key URL and re-import the key manually:

cat /etc/yum.repos.d/kubernetes.repo
sudo rpm --import https://pkgs.k8s.io/core:/stable:/v1.36/rpm/repodata/repomd.xml.key
sudo dnf install -y kubectl

Package Not Found

If dnf reports Failed to synchronize cache for repo 'kubernetes' or No match for argument: kubectl, clear the cache, refresh metadata, and confirm the package is visible:

sudo dnf clean all
sudo dnf makecache
dnf repolist
dnf list kubectl --showduplicates

If kubernetes.repo is missing, redo Step 2.

Uninstall

sudo dnf remove -y kubectl

About the Author

I am Luca Berton, AI and Cloud Advisor. Book a consultation to get help with your infrastructure setup.

Free 30-min Production AI consultation

Book Now