Object in Kubernetes

  • A Kubernetes object is a “record of intent”—once you create the object, the Kubernetes system will constantly work to ensure that object exists. By creating an object, you’re effectively telling the Kubernetes system what you want your cluster’s workload to look like; this is your cluster’s desired state.

  • To work with Kubernetes objects—whether to create, modify, or delete them—you’ll need to use the Kubernetes API.

  • Almost every Kubernetes object includes two nested object fields that govern the object’s configuration: the object spec and the object status. For objects that have a spec, you have to set this when you create the object, providing a description of the characteristics you want the resource to have: its desired state.

  • The status describes the current state of the object, supplied and updated by the Kubernetes system and its components.

Describe a object

  • When you create an object in Kubernetes, you must provide the object spec that describes its desired state, as well as some basic information about the object (such as a name).
  • When you use the Kubernetes API to create the object (either directly or via kubectl), that API request must include that information as JSON in the request body. Most often, you provide the information to kubectl in a .yaml file. kubectl converts the information to JSON when making the API request

Object Names and IDs

Each object in your cluster has a Name that is unique for that type of resource. Every Kubernetes object also has a UID that is unique across your whole cluster.

Labels and Selectors

Labels are key/value pairs that are attached to Object in Kubernetes such as Pods

Namespaces

In Kubernetes, namespaces provides a mechanism for isolating groups of resources within a single cluster.

For clusters with a few to tens of users, you should not need to create or think about namespaces at all

Initial namespaces

Kubernetes Object Management

Management techniqueOperates onRecommended environmentSupported writersLearning curve
Imperative commandsLive objectsDevelopment projects1+Lowest
Imperative object configurationIndividual filesProduction projects1Moderate
Declarative object configurationDirectories of filesProduction projects1+Highest

Kubernetes Components