Skip to content

Setup kubectl#

kubectl works against your project's virtual API endpoint exactly as it would against any Kubernetes cluster. You need a kubeconfig file and a working kubectl installation.


Prerequisites#

  • kubectl installed (official install guide)
  • Access to a project (granted by your organisation administrator)
  • Your project kubeconfig (downloaded from the console or provided by your administrator)

Step 1: Install kubectl#

# macOS
brew install kubectl

# Linux
curl -LO "https://dl.k8s.io/release/$(curl -sL https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl && sudo mv kubectl /usr/local/bin/

# Windows
choco install kubernetes-cli

Verify:

kubectl version --client

Step 2: Download Your Project kubeconfig#

  1. Log in to the SCO console
  2. Navigate to your project
  3. Click Settings or Access
  4. Click Download kubeconfig

Save the file, for example as ~/.kube/my-project.yaml.


Step 3: Use the kubeconfig#

Option A: Environment variable#

export KUBECONFIG=~/.kube/my-project.yaml
kubectl get virtualmachines

Option B: Merge into existing config#

KUBECONFIG=~/.kube/config:~/.kube/my-project.yaml kubectl config view --flatten > ~/.kube/merged.yaml
mv ~/.kube/merged.yaml ~/.kube/config
kubectl config use-context my-project

Option C: Per-command flag#

kubectl --kubeconfig ~/.kube/my-project.yaml get virtualmachines

Step 4: Verify Access#

kubectl cluster-info
kubectl api-resources | grep cloud.stakater.com
kubectl get virtualmachines

Working with Multiple Projects#

Keep separate kubeconfig files per project and switch with the KUBECONFIG environment variable, or merge them and use context switching:

kubectl config get-contexts
kubectl config use-context proj-backend

Authentication#

Your project kubeconfig uses OIDC authentication. When the token expires, kubectl prompts you to re-authenticate via your organisation's login page. Install the oidc-login plugin to handle this automatically:

kubectl krew install oidc-login

What's Next?#