k8s
Kubernetes cluster management.
The k8s command provides a comprehensive interface for managing Kubernetes clusters and workloads. It supports creating clusters on EKS, GKE, and kubeadm, deploying applications, viewing resources and metrics, tailing logs, and asking natural language questions about your cluster.
Usage
clanker k8s <subcommand> [flags]Subcommands
| Subcommand | Description |
|---|---|
create eks | Create an Amazon EKS cluster |
create kubeadm | Create a kubeadm cluster on EC2 instances |
create gke | Create a Google Kubernetes Engine (GKE) cluster |
deploy | Deploy an application to the cluster |
resources | Fetch all Kubernetes resources for visualization |
logs | Get logs from a pod |
stats nodes | Get node metrics |
stats pods | Get pod metrics |
stats pod | Get metrics for a specific pod |
stats cluster | Get cluster-wide metrics |
list | List Kubernetes clusters |
delete | Delete a Kubernetes cluster |
kubeconfig | Get kubeconfig for a cluster |
ask | Ask natural language questions about your cluster |
create eks
Create a new Amazon EKS cluster.
Usage
clanker k8s create eks [cluster-name] [flags]Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--nodes | int | 1 | Number of worker nodes |
--node-type | string | "t3.small" | EC2 instance type for worker nodes |
--version | string | "1.29" | Kubernetes version |
--plan | bool | false | Show the execution plan without applying |
--apply | bool | false | Apply the plan without prompting for confirmation |
Examples
# Create a basic EKS cluster (prompts for confirmation)
clanker k8s create eks my-cluster
# Create with 3 worker nodes
clanker k8s create eks my-cluster --nodes 3
# Create with a specific instance type and version
clanker k8s create eks my-cluster --nodes 2 --node-type t3.medium --version 1.29
# Preview the plan without creating anything
clanker k8s create eks my-cluster --nodes 2 --plan
# Create without confirmation prompt
clanker k8s create eks my-cluster --nodes 2 --applycreate kubeadm
Create a kubeadm-based Kubernetes cluster on EC2 instances.
This creates a self-managed Kubernetes cluster using kubeadm. Clanker provisions EC2 instances for the control plane and workers, configures SSH access, installs Kubernetes components, and initializes the cluster with a CNI plugin.
Usage
clanker k8s create kubeadm [cluster-name] [flags]Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--workers | int | 1 | Number of worker nodes |
--node-type | string | "t3.small" | EC2 instance type for all nodes (control plane and workers) |
--key-pair | string | "" | AWS key pair name for SSH access. Auto-creates as clanker-<name>-key if not specified. |
--ssh-key | string | "" | Path to SSH private key. Defaults to ~/.ssh/<key-pair> |
--version | string | "1.29" | Kubernetes version |
--plan | bool | false | Show the execution plan without applying |
--apply | bool | false | Apply the plan without prompting for confirmation |
Examples
# Create a basic kubeadm cluster
clanker k8s create kubeadm my-cluster
# Create with 2 workers and a specific key pair
clanker k8s create kubeadm my-cluster --workers 2 --key-pair my-key
# Create with a larger instance type
clanker k8s create kubeadm my-cluster --workers 3 --node-type t3.medium
# Specify a custom SSH key path
clanker k8s create kubeadm my-cluster --key-pair my-key --ssh-key ~/.ssh/my-key.pem
# Preview the plan
clanker k8s create kubeadm my-cluster --workers 2 --plan
# Create without confirmation
clanker k8s create kubeadm my-cluster --workers 2 --applycreate gke
Create a new Google Kubernetes Engine (GKE) cluster.
Usage
clanker k8s create gke [cluster-name] [flags]Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--gcp-project | string | required | GCP project ID |
--gcp-region | string | "us-central1" | GCP region for the cluster |
--nodes | int | 1 | Number of worker nodes |
--node-type | string | "e2-standard-2" | GCE machine type for worker nodes |
--version | string | "" | Kubernetes version (uses GKE default if empty) |
--preemptible | bool | false | Use preemptible (spot) VMs for worker nodes to reduce cost |
--plan | bool | false | Show the execution plan without applying |
--apply | bool | false | Apply the plan without prompting for confirmation |
Examples
# Create a basic GKE cluster
clanker k8s create gke my-cluster --gcp-project my-project
# Create in a specific region with multiple nodes
clanker k8s create gke my-cluster --gcp-project my-project --gcp-region europe-west1 --nodes 3
# Create with a custom machine type
clanker k8s create gke my-cluster --gcp-project my-project --node-type e2-standard-4
# Use preemptible VMs for cost savings
clanker k8s create gke my-cluster --gcp-project my-project --nodes 3 --preemptible
# Preview the plan
clanker k8s create gke my-cluster --gcp-project my-project --plan
# Create without confirmation
clanker k8s create gke my-cluster --gcp-project my-project --applydeploy
Deploy an application (container image) to the current Kubernetes cluster.
This command generates a Kubernetes Deployment and a LoadBalancer Service, then applies them to the cluster.
Usage
clanker k8s deploy [image] [flags]Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--name | string | "" | Deployment name. Defaults to the image name (without registry prefix or tag). |
--port | int | 80 | Container port to expose |
--replicas | int | 1 | Number of pod replicas |
--namespace | string | "default" | Kubernetes namespace to deploy into |
--plan | bool | false | Show the execution plan without applying |
--apply | bool | false | Apply the plan without prompting for confirmation |
Examples
# Deploy nginx (prompts for confirmation)
clanker k8s deploy nginx
# Deploy with a custom name and port
clanker k8s deploy nginx --name my-web --port 8080
# Deploy with multiple replicas
clanker k8s deploy nginx --name my-web --port 80 --replicas 3
# Deploy to a specific namespace
clanker k8s deploy my-registry/my-app:latest --namespace staging
# Preview the plan
clanker k8s deploy nginx --plan
# Deploy without confirmation
clanker k8s deploy nginx --name my-web --port 80 --apply
# Deploy a private registry image
clanker k8s deploy 123456789012.dkr.ecr.us-east-1.amazonaws.com/my-app:v1.2.3 --port 3000 --applyresources
Fetch all Kubernetes resources from one or more clusters for visualization.
When a cluster name is specified, it fetches resources from that cluster. When no cluster is specified, it iterates over all EKS clusters in your account and fetches resources from each.
Usage
clanker k8s resources [flags]Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--cluster | string | "" | Cluster name. Uses the current kubectl context if not specified. |
-o, --output | string | "json" | Output format: json or yaml |
Examples
# Get resources from the current cluster context
clanker k8s resources
# Get resources from a specific EKS cluster
clanker k8s resources --cluster my-cluster
# Output as YAML
clanker k8s resources --cluster my-cluster -o yaml
# Get resources from all EKS clusters
clanker k8s resourceslogs
Get logs from a Kubernetes pod.
Usage
clanker k8s logs [pod-name] [flags]Flags
| Flag | Type | Default | Description |
|---|---|---|---|
-c, --container | string | "" | Container name (required for multi-container pods) |
-f, --follow | bool | false | Stream log output in real time |
-p, --previous | bool | false | Show logs from the previous terminated container instance |
--tail | int | 100 | Number of lines to show from the end of the logs |
--since | string | "" | Show logs since a relative duration (for example, 1h, 30m, 5s) |
--timestamps | bool | false | Include timestamps on each log line |
--all-containers | bool | false | Show logs from all containers in the pod |
-n, --namespace | string | "default" | Kubernetes namespace |
Examples
# Get the last 100 lines of logs from a pod
clanker k8s logs my-pod
# Stream logs in real time
clanker k8s logs my-pod -f
# Get logs from a specific container in a multi-container pod
clanker k8s logs my-pod -c sidecar
# Get logs from the previously terminated container
clanker k8s logs my-pod -p
# Get the last 500 lines
clanker k8s logs my-pod --tail 500
# Get logs from the last hour
clanker k8s logs my-pod --since 1h
# Get logs with timestamps
clanker k8s logs my-pod --timestamps
# Get logs from all containers
clanker k8s logs my-pod --all-containers
# Get logs from a pod in a specific namespace
clanker k8s logs my-pod -n kube-system
# Combine flags: stream logs from the last 30 minutes with timestamps
clanker k8s logs my-pod -f --since 30m --timestampsstats nodes
Get CPU and memory metrics for all cluster nodes.
Requires the Kubernetes Metrics Server to be installed in the cluster.
Usage
clanker k8s stats nodes [flags]Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--sort-by | string | "" | Sort results by cpu or memory |
-o, --output | string | "table" | Output format: table, json, or yaml |
Examples
# Show node metrics in table format
clanker k8s stats nodes
# Sort by CPU usage
clanker k8s stats nodes --sort-by cpu
# Sort by memory usage
clanker k8s stats nodes --sort-by memory
# Output as JSON
clanker k8s stats nodes -o json
# Output as YAML
clanker k8s stats nodes -o yamlstats pods
Get CPU and memory metrics for pods.
Requires the Kubernetes Metrics Server to be installed in the cluster.
Usage
clanker k8s stats pods [flags]Flags
| Flag | Type | Default | Description |
|---|---|---|---|
-n, --namespace | string | "default" | Kubernetes namespace |
-A, --all-namespaces | bool | false | Show pods from all namespaces |
--sort-by | string | "" | Sort results by cpu or memory |
-o, --output | string | "table" | Output format: table, json, or yaml |
Examples
# Show pod metrics in the default namespace
clanker k8s stats pods
# Show pod metrics in a specific namespace
clanker k8s stats pods -n kube-system
# Show pod metrics across all namespaces
clanker k8s stats pods -A
# Sort by memory usage
clanker k8s stats pods --sort-by memory
# Output as JSON
clanker k8s stats pods -A -o jsonstats pod
Get CPU and memory metrics for a specific pod and its containers.
Requires the Kubernetes Metrics Server to be installed in the cluster.
Usage
clanker k8s stats pod [pod-name] [flags]Flags
| Flag | Type | Default | Description |
|---|---|---|---|
-n, --namespace | string | "default" | Kubernetes namespace |
--containers | bool | false | Show per-container metrics breakdown |
-o, --output | string | "table" | Output format: table, json, or yaml |
Examples
# Show metrics for a specific pod
clanker k8s stats pod my-pod
# Show per-container metrics
clanker k8s stats pod my-pod --containers
# Show metrics for a pod in a specific namespace
clanker k8s stats pod my-pod -n kube-system
# Output as JSON
clanker k8s stats pod my-pod --containers -o jsonstats cluster
Get aggregated CPU and memory metrics for the entire cluster.
This command summarizes node-level metrics into cluster-wide averages.
Usage
clanker k8s stats cluster [flags]Flags
| Flag | Type | Default | Description |
|---|---|---|---|
-o, --output | string | "table" | Output format: table, json, or yaml |
Examples
# Show cluster-wide metrics summary
clanker k8s stats cluster
# Output as JSON
clanker k8s stats cluster -o json
# Output as YAML
clanker k8s stats cluster -o yamllist
List Kubernetes clusters of a specific type.
Usage
clanker k8s list [cluster-type] [flags]The cluster-type argument defaults to eks. Supported types: eks, gke, kubeadm.
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--gcp-project | string | "" | GCP project ID (required for gke type) |
--gcp-region | string | "" | GCP region (used with gke type) |
Examples
# List EKS clusters (default)
clanker k8s list
# List EKS clusters explicitly
clanker k8s list eks
# List GKE clusters
clanker k8s list gke --gcp-project my-project
# List GKE clusters in a specific region
clanker k8s list gke --gcp-project my-project --gcp-region europe-west1
# List kubeadm clusters
clanker k8s list kubeadmdelete
Delete an existing Kubernetes cluster.
This command displays a plan of what will be deleted and prompts for confirmation before proceeding.
Usage
clanker k8s delete [cluster-type] [cluster-name] [flags]Supported cluster types: eks, gke, kubeadm.
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--gcp-project | string | "" | GCP project ID (required for gke type) |
--gcp-region | string | "" | GCP region (used with gke type) |
Examples
# Delete an EKS cluster (prompts for confirmation)
clanker k8s delete eks my-cluster
# Delete a GKE cluster
clanker k8s delete gke my-cluster --gcp-project my-project
# Delete a GKE cluster in a specific region
clanker k8s delete gke my-cluster --gcp-project my-project --gcp-region us-west1
# Delete a kubeadm cluster
clanker k8s delete kubeadm my-clusterkubeconfig
Retrieve and configure kubeconfig for a cluster.
After running this command, you can use kubectl to interact with the cluster.
Usage
clanker k8s kubeconfig [cluster-type] [cluster-name] [flags]Supported cluster types: eks, gke, kubeadm.
Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--gcp-project | string | "" | GCP project ID (required for gke type) |
--gcp-region | string | "" | GCP region (used with gke type) |
Examples
# Get kubeconfig for an EKS cluster
clanker k8s kubeconfig eks my-cluster
# Get kubeconfig for a GKE cluster
clanker k8s kubeconfig gke my-cluster --gcp-project my-project
# Get kubeconfig for a kubeadm cluster
clanker k8s kubeconfig kubeadm my-cluster
# Typical workflow after getting kubeconfig
clanker k8s kubeconfig eks my-cluster
kubectl get nodes
kubectl get pods -Aask
Ask natural language questions about your Kubernetes cluster using AI.
The ask subcommand uses a three-stage LLM pipeline to analyze your question, execute the appropriate kubectl operations, and return a comprehensive response. Conversation history is maintained per cluster for follow-up questions.
Usage
clanker k8s ask [question] [flags]Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--cluster | string | "" | Kubernetes cluster name (EKS or GKE cluster name). Updates kubeconfig automatically. |
--profile | string | "" | AWS profile for EKS clusters |
--kubeconfig | string | "" | Path to kubeconfig file (default: ~/.kube/config) |
--context | string | "" | kubectl context to use (overrides --cluster) |
-n, --namespace | string | "" | Default namespace for queries. Defaults to all namespaces when empty. |
--ai-profile | string | "" | AI profile to use for LLM queries |
--debug | bool | false | Enable debug output |
--gcp | bool | false | Use GKE cluster instead of EKS |
--gcp-project | string | "" | GCP project ID for GKE clusters |
--gcp-region | string | "" | GCP region for GKE clusters |
Examples
# Ask about pod status in the current cluster context
clanker k8s ask "how many pods are running"
# Target a specific EKS cluster
clanker k8s ask --cluster my-cluster "show me all deployments"
# Target an EKS cluster with a specific AWS profile
clanker k8s ask --cluster prod --profile production "give me error logs for nginx pod"
# Target a GKE cluster
clanker k8s ask --gcp --gcp-project my-project --cluster my-gke-cluster "show me all pods"
# Ask about resource usage
clanker k8s ask "which pods are using the most memory"
# Troubleshoot issues
clanker k8s ask "why is my pod crashing"
# Get a cluster health overview
clanker k8s ask "tell me the health of my cluster"
# Use a specific namespace context
clanker k8s ask -n kube-system "show me all services"
# Use a specific kubeconfig file
clanker k8s ask --kubeconfig /path/to/kubeconfig "list all nodes"
# Use a specific kubectl context
clanker k8s ask --context arn:aws:eks:us-east-1:123456789012:cluster/my-cluster "show deployments"
# Use a specific AI provider
clanker k8s ask --ai-profile anthropic "analyze my cluster security"
# Enable debug output to see the LLM pipeline stages
clanker k8s ask --debug "show me pods with restart counts"How It Works
The k8s ask command follows a three-stage pipeline:
Stage 1: Query Analysis -- The LLM analyzes your question along with the current cluster status (node count, pod counts, namespaces) and determines which kubectl operations are needed.
Stage 2: Execution -- The identified kubectl operations are executed against the cluster (for example,
kubectl get pods -A,kubectl describe pod my-pod,kubectl top nodes).Stage 3: Response -- The kubectl output is combined with cluster context and conversation history, then the LLM generates a comprehensive markdown-formatted response.
Conversation history is persisted per cluster, so you can ask follow-up questions without restating context.
Prerequisites
Different subcommands require different tools to be installed:
| Tool | Required For |
|---|---|
aws CLI | EKS cluster operations, kubeadm on EC2 |
gcloud CLI | GKE cluster operations |
kubectl | All cluster interaction (deploy, logs, stats, ask, resources) |
eksctl | EKS cluster creation |
helm | Helm-based deployments |
| Metrics Server | stats subcommands (must be installed in the cluster) |
See Also
- ask -- The primary query command with K8s auto-routing
- deploy -- Deploy repositories to the cloud
- AWS Cloud Provider -- AWS-specific configuration
- GCP Cloud Provider -- GCP-specific configuration