| name | use-kube-dc-cli |
| description | Use the kube-dc CLI for authentication, context switching, and namespace management. Covers login, use, ns, config, and kubectl integration. |
Use Kube-DC CLI
The kube-dc CLI provides browser-based OAuth authentication and context management for Kube-DC clusters. It integrates as a kubectl exec credential plugin.
Installation
sudo curl -sL https://github.com/kube-dc/kube-dc-public/releases/latest/download/kube-dc_linux_amd64 -o /usr/local/bin/kube-dc && sudo chmod +x /usr/local/bin/kube-dc
sudo curl -sL https://github.com/kube-dc/kube-dc-public/releases/latest/download/kube-dc_linux_arm64 -o /usr/local/bin/kube-dc && sudo chmod +x /usr/local/bin/kube-dc
sudo curl -sL https://github.com/kube-dc/kube-dc-public/releases/latest/download/kube-dc_darwin_arm64 -o /usr/local/bin/kube-dc && sudo chmod +x /usr/local/bin/kube-dc
sudo curl -sL https://github.com/kube-dc/kube-dc-public/releases/latest/download/kube-dc_darwin_amd64 -o /usr/local/bin/kube-dc && sudo chmod +x /usr/local/bin/kube-dc
Commands
Login
kube-dc login --domain kube-dc.cloud --org {org-name}
kube-dc login --domain stage.kube-dc.com --org {org-name}
kube-dc login --domain internal.example.com --org {org-name} --ca-cert /path/to/ca.crt
Opens browser for Keycloak OAuth login. Tokens cached for ~30 days with auto-refresh.
Switch Context (org/project)
kube-dc use {org}/{project}
kube-dc use
Context names follow pattern: kube-dc/{domain}/{org}/{project}
List / Switch Namespace
kube-dc ns
kube-dc ns {namespace}
Show Configuration
kube-dc config show
kube-dc config get-contexts
Logout
kube-dc logout
kube-dc logout --all
Determine Current Context
Before creating resources, always check the current context:
kubectl config current-context
kube-dc config show
kube-dc ns
The namespace tells you the project: namespace {org}-{project} → org={org}, project={project}.
How kubectl Integration Works
After kube-dc login, the CLI configures kubectl with an exec credential plugin:
users:
- name: kube-dc@{org}
user:
exec:
apiVersion: client.authentication.k8s.io/v1
command: kube-dc
args: ["credential", "--server", "https://kube-api.{domain}:6443"]
Every kubectl command automatically:
- Returns cached token if valid
- Refreshes token using refresh_token if expired
- Prompts re-login only when refresh_token expires (~30 days)
kubectx / kubens Compatibility
kubectx
kubectx kube-dc/shalb/demo
File Locations
| Path | Purpose |
|---|
~/.kube/config | Kubeconfig (Kube-DC entries merged, never overwrites others) |
~/.kube-dc/config.yaml | CLI configuration |
~/.kube-dc/credentials/ | Cached OAuth tokens (0600 permissions) |
Verification
After CLI operations:
After Login
kube-dc config show
kubectl get ns
After Context Switch
kubectl config current-context
kubectl config view --minify -o jsonpath='{.contexts[0].context.namespace}'
After Namespace Switch
kube-dc ns
Success: Config shows valid tokens, kubectl commands return data.
Failure:
- "not logged in": run
kube-dc login --domain {domain} --org {org}
- "session expired": refresh token expired (~30 days), re-run login
- "Forbidden": user doesn't have access to the requested namespace/resource
Safety
- The CLI never stores passwords — only OAuth tokens with auto-refresh
- Tokens are cached with 0600 permissions (owner-read-only)
- Never log or display token contents in chat output
- If token is expired, suggest
kube-dc login rather than trying to extract tokens manually