Back to articles
Kubernetes Has a Free API: Here's How to Use It for Cluster Automation
How-ToDevOps

Kubernetes Has a Free API: Here's How to Use It for Cluster Automation

via Dev.to DevOpsAlex Spinov

Every Kubernetes cluster exposes a powerful REST API. If you're still using only kubectl, you're missing out on programmatic control that can automate deployments, scaling, monitoring, and incident response. Why Use the Kubernetes API Directly? Automate deployments without shell scripts wrapping kubectl Build custom dashboards and monitoring tools Create self-healing systems that respond to cluster events Integrate K8s into your existing toolchain via HTTP Getting Started The API server runs on your cluster's control plane. Access it via kubectl proxy: # Start a local proxy to the API server kubectl proxy --port = 8080 & # List all pods in default namespace curl -s http://localhost:8080/api/v1/namespaces/default/pods | jq '.items[] | {name: .metadata.name, status: .status.phase}' List All Resources # Get all API resources available curl -s http://localhost:8080/api/v1 | jq '.resources[] | {name: .name, kind: .kind, verbs: .verbs}' # Get nodes and their capacity curl -s http://localhost

Continue reading on Dev.to DevOps

Opens in a new tab

Read Full Article
8 views

Related Articles