Understanding Essential API Resources
- After using the
kubectl create deployment myapp --image=nginx --replicas=3
command, themyapp
application is started in Kubernetes - To run an application in Kubernetes, different API resources are used
- Each API resource adds functionality that is required to run an application in a cloud native environment
- Remember, in a cloud native environment the application is not directly related to any server, so all information the application needs is stored in the cloud
Here everything is represented as an API resource. This means that each object has a defined structure, can be created, modified, and deleted using the Kubernetes API, and is managed by the Kubernetes control plane.
API resources are also called High Level K8s objects
Yes, that's correct. In Kubernetes, all API resources are objects, but not all objects are API resources.
Analogy: API Resources and Objects in K8s
Imagine a city as a Kubernetes cluster.
API Resources are like the different types of buildings in the city.
They have specific structures and purposes, such as residential buildings (Pods), commercial buildings (Services), and government buildings (Deployments).
Objects are like everything in the city, including the buildings (API Resources), the people (namespaces), the traffic (events), and even the weather (status). So, while all buildings (API Resources) are part of the city (objects), not everything in the city is a building.
There are other things like people, traffic, and weather that are also objects but not API resources.
In essence:
- API Resources are a specific type of object with defined structures and behaviors.
- Objects are a broader term that encompasses everything in Kubernetes.
Investigating API Resources
The Kubernetes APIs provide different resources to run applications in a cloud-native environment:
- Deployment: used to represent the application itself
- ReplicaSet: takes care of scalebility by managing application replicas (instances)
- Pods: adds features required in cloud to run the actual containers that contain the application
There are more API resources, use kubectl api-resources
for an overview.