Cloud Command Line Tools¶
Kubernetes CLI (kubectl)¶
-
Using Homebrew (recommended):
-
Manual installation:
-
Make kubectl executable
-
Move kubectl to a directory in your PATH
-
Using package manager (Ubuntu/Debian): ```{ .sh .copy } # Add Kubernetes apt repository sudo apt-get update sudo apt-get install -y apt-transport-https ca-certificates curl curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.29/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list sudo apt-get update sudo apt-get install -y kubectl
-
Make kubectl executable
Move kubectl to a directory in your PATH¶
-
Using Chocolatey (recommended):
-
Manual installation:
-
Download kubectl
-
Move kubectl to the created directory
-
Add to PATH
OpenShift CLI (oc)¶
-
Using web console:
- Log into your OpenShift web console
- Click ? icon in the top right
- Select "Command Line Tools"
- Download Windows oc client
- Extract the archive
-
Create directory for OpenShift CLI
-
Move oc.exe to the created directory
-
Add to PATH
-
Using Homebrew:
-
Manual installation:
- Log into your OpenShift web console
- Click ? icon in the top right
- Select "Command Line Tools"
- Download macOS oc client
-
Extract the downloaded archive
- Manual installation:
- Log into your OpenShift web console
- Click ? icon in the top right
- Select "Command Line Tools"
- Download Linux oc client
- Extract the downloaded archive
Verification and Configuration¶
Verify the installations:
kubectl Configuration¶
# Create kubectl config directory if it doesn't exist
mkdir -p ~/.kube
# Set KUBECONFIG environment variable
export KUBECONFIG=~/.kube/config
OpenShift Login¶
# Login to OpenShift cluster
oc login --token=<token> --server=https://api.cluster-url:6443
# View available projects
oc projects
# Switch to a specific project
oc project <project-name>
Tip
Store your OpenShift login token securely. You can get a new token from the OpenShift web console under your profile → Copy login command.
Shell Completion¶
Common Issues and Troubleshooting¶
Warning
If you're behind a corporate proxy, you might need to configure proxy settings for both kubectl and oc.
Common troubleshooting steps:
# Check kubectl context
kubectl config current-context
# Check oc login status
oc whoami
# View cluster info
kubectl cluster-info
oc cluster-info
# Check connection to cluster
kubectl get nodes
oc get nodes
Tip
Keep your CLI tools up to date with the cluster version to avoid compatibility issues. You can check the required versions in your cluster's documentation.