#Kubernetes Objects

While working with Kubernetes the most important thing we need to understand is Kubernetes Objects. By definition, Kubernetes objects are persistent entities in the Kubernetes system. Kubernetes uses these entities to represent the state of your cluster. The objects include things like

  • State of your application
  • Application Resources
  • Policies
  • Default, Autogenerated Metadata

It also serves as record of intent for your Kubernetes cluster. By creating an object you are effectively telling Kubernetes system what you want to do on your Kubernetes cluster, what your application workload would look like, what is it’s desired state, etc. You can operate on Kubernetes objects with Kubernetes API and it can be operated with any client of your preference, the most common being kubectl command line client.

Every Kubernetes object includes minimum two nested fields that govern the object’s configuration:

  • the object spec, is a user defined characteristics you want the object to have, its desired state, etc
  • the object status, is an autogenerated current state of the object and managed by the Kubernetes system

When creating any Kubernetes object, following fields are required to be set,

  • apiVersion - Which version of the Kubernetes API you’re using to create this object
  • kind - What kind of object you want to create
  • metadata - Data that helps uniquely identify the object, including a name string, UID, and optional namespace spec - What state you desire for the object

References:

Kubernetes Documentation