Comprehensive Kubernetes deployment and scaling for containerized applications, from simple hello-world deployments to production-grade systems with autoscaling, security, and monitoring. Use when deploying, scaling, and managing containerized applications on Kubernetes clusters, including resource management, health checks, security policies, and production best practices.
This skill provides comprehensive support for deploying and scaling containerized applications on Kubernetes, from simple hello-world deployments to production-grade systems with autoscaling, security, and monitoring.
Understanding how Kubernetes maintains desired state through its control plane components and reconciliation loop is essential for effective deployments.
The reconciliation loop is the core mechanism that ensures desired state matches actual state:
User Action → API Server → etcd (Store Desired State)
↓
Scheduler Watches → Finds Suitable Node → Updates Pod Spec
↓
Kubelet Watches → Receives Pod Assignment → Starts Containers
↓
Controller Watches → Monitors Actual State → Adjusts as Needed
↓
Status Updates → API Server → etcd (Store Current State)
The reconciliation loop follows this detailed sequence:
nodeName=""nodeName="node-1"Running and sends health informationHere's a visualization of the interactions between components during the reconciliation process:
%%{init:{"theme":"neutral"}}%%
sequenceDiagram
actor me
participant apiSrv as control plane<br><br>api-server
participant etcd as control plane<br><br>etcd datastore
participant cntrlMgr as control plane<br><br>controller<br>manager
participant sched as control plane<br><br>scheduler
participant kubelet as node<br><br>kubelet
participant container as node<br><br>container<br>runtime
me->>apiSrv: 1. kubectl create -f pod.yaml
apiSrv-->>etcd: 2. save new state
cntrlMgr->>apiSrv: 3. check for changes
sched->>apiSrv: 4. watch for unassigned pods(s)
apiSrv->>sched: 5. notify about pod w nodename=""
sched->>apiSrv: 6. assign pod to node
apiSrv-->>etcd: 7. save new state
kubelet->>apiSrv: 8. look for newly assigned pod(s)
apiSrv->>kubelet: 9. bind pod to node
kubelet->>container: 10. start container
kubelet->>apiSrv: 11. update pod status
apiSrv-->>etcd: 12. save new state
Use this skill when you need to:
Before using this skill, verify your Kubernetes setup:
# Check kubectl version
kubectl version --client
# Verify cluster access and endpoints
kubectl cluster-info
# Check available nodes and their status
kubectl get nodes
# Test basic functionality
kubectl run test-pod --image=nginx --dry-run=client -o yaml
Use these commands to verify cluster connectivity and health:
Displays the addresses of the control plane and services labeled with kubernetes.io/cluster-service=true. This command is useful for quickly getting an overview of your cluster's essential service endpoints.
# Display cluster information
kubectl cluster-info
# For more detailed debugging and diagnosis of cluster issues
kubectl cluster-info dump
# Get cluster info with specific output format
kubectl cluster-info --output wide
Checks the status of all nodes in the cluster to ensure they are healthy and ready to accept workloads.
# List all nodes and their status
kubectl get nodes
# Get detailed information about nodes
kubectl get nodes -o wide
# Check nodes with labels
kubectl get nodes --show-labels
# Get specific node information
kubectl describe node <node-name>
# Check nodes with specific label selectors
kubectl get nodes -l <label-key>=<label-value>
# Monitor nodes in real-time
kubectl get nodes --watch
Use these commands to manage cluster contexts and kubeconfig:
# Display the current context
kubectl config current-context
# List all available contexts
kubectl config get-contexts
# Switch to a specific context
kubectl config use-context <context-name>
# Get current context with namespace
kubectl config view --minify
# View merged kubeconfig settings
kubectl config view
# View raw kubeconfig with certificate data
kubectl config view --raw
# Get specific information using jsonpath
kubectl config view -o jsonpath='{.users[*].name}' # List all users
kubectl config view -o jsonpath='{.clusters[*].name}' # List all clusters
kubectl config view -o jsonpath='{.contexts[*].name}' # List all contexts
# Set namespace for current context
kubectl config set-context --current --namespace=<namespace-name>
# Create a new context with specific cluster and user
kubectl config set-context <context-name> --cluster=<cluster-name> --user=<user-name> --namespace=<namespace-name>
# Rename current context
kubectl config rename-context <old-name> <new-name>
# Delete a context
kubectl config delete-context <context-name>
# Set cluster information
kubectl config set-cluster <cluster-name> --server=<server-url> --certificate-authority=<ca-file-path>
# Set user credentials
kubectl config set-credentials <user-name> --token=<token> # For token-based auth
kubectl config set-credentials <user-name> --client-certificate=<cert-file> --client-key=<key-file> # For client cert auth
# Unset configuration elements
kubectl config unset users.<user-name>
kubectl config unset clusters.<cluster-name>
kubectl config unset contexts.<context-name>
You can work with multiple kubeconfig files by setting the KUBECONFIG environment variable:
# Append to existing KUBECONFIG
export KUBECONFIG="${KUBECONFIG}:${HOME}/.kube/config:${HOME}/.kube/additional-config"
# Use specific kubeconfig file
kubectl --kubeconfig=/path/to/kubeconfig get nodes
# Temporarily use different kubeconfig
KUBECONFIG=/path/to/alternative/config kubectl get pods
# Switch between development and production contexts
kubectl config use-context development
kubectl config use-context production
# Create aliases for quick switching (bash/zsh)
alias kx='kubectl config use-context'
alias kn='kubectl config set-context --current --namespace'
# Example usage:
kx dev-cluster # Switch to dev cluster
kn my-namespace # Set namespace for current context
# Check if current context is properly configured
kubectl cluster-info
kubectl get nodes
# If getting connection errors, verify current context
kubectl config current-context
# View detailed config for troubleshooting
kubectl config view --minify --output yaml
# Reset current context if corrupted
kubectl config use-context <valid-context-name>
A Kubernetes Pod manifest follows this structure:
apiVersion: v1 # API version for Pods