Skip to content

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

bash
clanker k8s <subcommand> [flags]

Subcommands

SubcommandDescription
create eksCreate an Amazon EKS cluster
create kubeadmCreate a kubeadm cluster on EC2 instances
create gkeCreate a Google Kubernetes Engine (GKE) cluster
deployDeploy an application to the cluster
resourcesFetch all Kubernetes resources for visualization
logsGet logs from a pod
stats nodesGet node metrics
stats podsGet pod metrics
stats podGet metrics for a specific pod
stats clusterGet cluster-wide metrics
listList Kubernetes clusters
deleteDelete a Kubernetes cluster
kubeconfigGet kubeconfig for a cluster
askAsk natural language questions about your cluster

create eks

Create a new Amazon EKS cluster.

Usage

bash
clanker k8s create eks [cluster-name] [flags]

Flags

FlagTypeDefaultDescription
--nodesint1Number of worker nodes
--node-typestring"t3.small"EC2 instance type for worker nodes
--versionstring"1.29"Kubernetes version
--planboolfalseShow the execution plan without applying
--applyboolfalseApply the plan without prompting for confirmation

Examples

bash
# 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 --apply

create 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

bash
clanker k8s create kubeadm [cluster-name] [flags]

Flags

FlagTypeDefaultDescription
--workersint1Number of worker nodes
--node-typestring"t3.small"EC2 instance type for all nodes (control plane and workers)
--key-pairstring""AWS key pair name for SSH access. Auto-creates as clanker-<name>-key if not specified.
--ssh-keystring""Path to SSH private key. Defaults to ~/.ssh/<key-pair>
--versionstring"1.29"Kubernetes version
--planboolfalseShow the execution plan without applying
--applyboolfalseApply the plan without prompting for confirmation

Examples

bash
# 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 --apply

create gke

Create a new Google Kubernetes Engine (GKE) cluster.

Usage

bash
clanker k8s create gke [cluster-name] [flags]

Flags

FlagTypeDefaultDescription
--gcp-projectstringrequiredGCP project ID
--gcp-regionstring"us-central1"GCP region for the cluster
--nodesint1Number of worker nodes
--node-typestring"e2-standard-2"GCE machine type for worker nodes
--versionstring""Kubernetes version (uses GKE default if empty)
--preemptibleboolfalseUse preemptible (spot) VMs for worker nodes to reduce cost
--planboolfalseShow the execution plan without applying
--applyboolfalseApply the plan without prompting for confirmation

Examples

bash
# 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 --apply

deploy

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

bash
clanker k8s deploy [image] [flags]

Flags

FlagTypeDefaultDescription
--namestring""Deployment name. Defaults to the image name (without registry prefix or tag).
--portint80Container port to expose
--replicasint1Number of pod replicas
--namespacestring"default"Kubernetes namespace to deploy into
--planboolfalseShow the execution plan without applying
--applyboolfalseApply the plan without prompting for confirmation

Examples

bash
# 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 --apply

resources

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

bash
clanker k8s resources [flags]

Flags

FlagTypeDefaultDescription
--clusterstring""Cluster name. Uses the current kubectl context if not specified.
-o, --outputstring"json"Output format: json or yaml

Examples

bash
# 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 resources

logs

Get logs from a Kubernetes pod.

Usage

bash
clanker k8s logs [pod-name] [flags]

Flags

FlagTypeDefaultDescription
-c, --containerstring""Container name (required for multi-container pods)
-f, --followboolfalseStream log output in real time
-p, --previousboolfalseShow logs from the previous terminated container instance
--tailint100Number of lines to show from the end of the logs
--sincestring""Show logs since a relative duration (for example, 1h, 30m, 5s)
--timestampsboolfalseInclude timestamps on each log line
--all-containersboolfalseShow logs from all containers in the pod
-n, --namespacestring"default"Kubernetes namespace

Examples

bash
# 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 --timestamps

stats nodes

Get CPU and memory metrics for all cluster nodes.

Requires the Kubernetes Metrics Server to be installed in the cluster.

Usage

bash
clanker k8s stats nodes [flags]

Flags

FlagTypeDefaultDescription
--sort-bystring""Sort results by cpu or memory
-o, --outputstring"table"Output format: table, json, or yaml

Examples

bash
# 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 yaml

stats pods

Get CPU and memory metrics for pods.

Requires the Kubernetes Metrics Server to be installed in the cluster.

Usage

bash
clanker k8s stats pods [flags]

Flags

FlagTypeDefaultDescription
-n, --namespacestring"default"Kubernetes namespace
-A, --all-namespacesboolfalseShow pods from all namespaces
--sort-bystring""Sort results by cpu or memory
-o, --outputstring"table"Output format: table, json, or yaml

Examples

bash
# 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 json

stats 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

bash
clanker k8s stats pod [pod-name] [flags]

Flags

FlagTypeDefaultDescription
-n, --namespacestring"default"Kubernetes namespace
--containersboolfalseShow per-container metrics breakdown
-o, --outputstring"table"Output format: table, json, or yaml

Examples

bash
# 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 json

stats cluster

Get aggregated CPU and memory metrics for the entire cluster.

This command summarizes node-level metrics into cluster-wide averages.

Usage

bash
clanker k8s stats cluster [flags]

Flags

FlagTypeDefaultDescription
-o, --outputstring"table"Output format: table, json, or yaml

Examples

bash
# 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 yaml

list

List Kubernetes clusters of a specific type.

Usage

bash
clanker k8s list [cluster-type] [flags]

The cluster-type argument defaults to eks. Supported types: eks, gke, kubeadm.

Flags

FlagTypeDefaultDescription
--gcp-projectstring""GCP project ID (required for gke type)
--gcp-regionstring""GCP region (used with gke type)

Examples

bash
# 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 kubeadm

delete

Delete an existing Kubernetes cluster.

This command displays a plan of what will be deleted and prompts for confirmation before proceeding.

Usage

bash
clanker k8s delete [cluster-type] [cluster-name] [flags]

Supported cluster types: eks, gke, kubeadm.

Flags

FlagTypeDefaultDescription
--gcp-projectstring""GCP project ID (required for gke type)
--gcp-regionstring""GCP region (used with gke type)

Examples

bash
# 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-cluster

kubeconfig

Retrieve and configure kubeconfig for a cluster.

After running this command, you can use kubectl to interact with the cluster.

Usage

bash
clanker k8s kubeconfig [cluster-type] [cluster-name] [flags]

Supported cluster types: eks, gke, kubeadm.

Flags

FlagTypeDefaultDescription
--gcp-projectstring""GCP project ID (required for gke type)
--gcp-regionstring""GCP region (used with gke type)

Examples

bash
# 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 -A

ask

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

bash
clanker k8s ask [question] [flags]

Flags

FlagTypeDefaultDescription
--clusterstring""Kubernetes cluster name (EKS or GKE cluster name). Updates kubeconfig automatically.
--profilestring""AWS profile for EKS clusters
--kubeconfigstring""Path to kubeconfig file (default: ~/.kube/config)
--contextstring""kubectl context to use (overrides --cluster)
-n, --namespacestring""Default namespace for queries. Defaults to all namespaces when empty.
--ai-profilestring""AI profile to use for LLM queries
--debugboolfalseEnable debug output
--gcpboolfalseUse GKE cluster instead of EKS
--gcp-projectstring""GCP project ID for GKE clusters
--gcp-regionstring""GCP region for GKE clusters

Examples

bash
# 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:

  1. 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.

  2. 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).

  3. 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:

ToolRequired For
aws CLIEKS cluster operations, kubeadm on EC2
gcloud CLIGKE cluster operations
kubectlAll cluster interaction (deploy, logs, stats, ask, resources)
eksctlEKS cluster creation
helmHelm-based deployments
Metrics Serverstats subcommands (must be installed in the cluster)

See Also