codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
☸️

Kubernetes

48 / 82 topics
46Kubernetes Frequently Asked Questions (FAQ)47Kubernetes Glossary48Kubernetes API Reference49Kubernetes Version Compatibility50Kubernetes Roadmap
Tutorials/Kubernetes/Kubernetes API Reference
☸️Kubernetes

Kubernetes API Reference

Updated 2026-05-15
10 min read

Kubernetes API Reference

Introduction

Kubernetes provides a powerful RESTful API that allows you to interact with and manage your cluster. This API is the backbone of many operations, from deploying applications to managing resources. Understanding the Kubernetes API is crucial for developers looking to automate tasks, integrate with other systems, or build custom tools.

In this section, we will explore the key components and endpoints of the Kubernetes API, providing both theoretical understanding and practical examples.

Concepts

API Groups and Versions

Kubernetes APIs are organized into groups and versions. Each group represents a set of related resources, while each version indicates changes in the API over time. For example, apps/v1 is a common group that includes resources like Deployments, ReplicaSets, and StatefulSets.

Resource Types

Resources in Kubernetes represent various entities such as Pods, Services, ConfigMaps, and more. Each resource type has its own set of fields and operations you can perform on it.

API Server

The Kubernetes API server is the central component that exposes the RESTful API. It handles all requests to manage and query resources within the cluster.

Examples

Accessing the API

To interact with the Kubernetes API, you typically use kubectl, the command-line tool for managing Kubernetes clusters. However, you can also access the API directly using tools like curl or programming languages that support HTTP requests.

Using kubectl to Get Pods

Terminal
JSON
1{
2"kind": "PodList",
3"apiVersion": "v1",
4"metadata": {
5 "selfLink": "/api/v1/namespaces/default/pods",
6 "resourceVersion": "12345"
7},
8"items": [
9 {
10 "metadata": {
11 "name": "pod-1",
12 "namespace": "default",
13 "uid": "abc123",
14 "creationTimestamp": "2023-01-01T00:00:00Z"
15 },
16 "spec": {
17 "containers": [
18 {
19 "name": "container-1",
20 "image": "nginx:latest"
21 }
22 ]
23 },
24 "status": {
25 "phase": "Running",
26 "podIP": "10.244.1.3"
27 }
28 },
29 {
30 "metadata": {
31 "name": "pod-2",
32 "namespace": "default",
33 "uid": "def456",
34 "creationTimestamp": "2023-01-02T00:00:00Z"
35 },
36 "spec": {
37 "containers": [
38 {
39 "name": "container-2",
40 "image": "nginx:latest"
41 }
42 ]
43 },
44 "status": {
45 "phase": "Running",
46 "podIP": "10.244.1.4"
47 }
48 }
49]
50}

Creating a Resource

You can create resources using the API by sending POST requests with JSON payloads.

Using kubectl to Create a Deployment

Terminal
JSON
1{
2"apiVersion": "apps/v1",
3"kind": "Deployment",
4"metadata": {
5 "name": "my-deployment"
6},
7"spec": {
8 "replicas": 3,
9 "selector": {
10 "matchLabels": {
11 "app": "my-app"
12 }
13 },
14 "template": {
15 "metadata": {
16 "labels": {
17 "app": "my-app"
18 }
19 },
20 "spec": {
21 "containers": [
22 {
23 "name": "my-container",
24 "image": "nginx:latest"
25 }
26 ]
27 }
28 }
29}
30}

What's Next?

  • Kubernetes Version Compatibility: Ensure that the API version you are using is compatible with your Kubernetes cluster version. Refer to the official Kubernetes documentation for details on supported versions and resources.

By understanding the Kubernetes API, you gain powerful capabilities to manage and automate your Kubernetes clusters effectively.


PreviousKubernetes GlossaryNext Kubernetes Version Compatibility

Recommended Gear

Kubernetes GlossaryKubernetes Version Compatibility