Kahibaro
Discord Login Register

Kubernetes objects and resources

Concept of Kubernetes Objects

Kubernetes manages everything in the cluster as an object. An object is a record of intent: you describe the desired state, and the system works to make reality match that description.

Every Kubernetes object:

In OpenShift, you use the same Kubernetes object model; OpenShift just adds more objects on top.

API Groups, Versions, and Kinds

Kubernetes objects are exposed via an HTTP API. Each object is identified by:

Example mapping:

Understanding this is important for:

Resource Types vs Individual Objects

Resource type: the collection of all objects of a given kind in the API.

Object instance: one particular object within that resource.

You interact with resource types using verbs:

These verbs are fundamental for RBAC and for how controllers work.

Object Metadata

Every object has metadata, which at minimum includes:

Example:

yaml
metadata:
  name: web-frontend
  namespace: production
  labels:
    app: shop
    tier: frontend
  annotations:
    description: "Main web front-end"

Labels and Label Selectors

Labels are structural metadata: they are used to define relationships between objects.

Common uses:

Label selectors are expressions used to match labels, e.g.:

Selectors appear:

Changing labels can change which Pods are part of a Service or Deployment, often immediately, so be careful.

Annotations

Annotations are non-structural metadata: they do not affect object selection.

Typical uses:

Because they are ignored for selection, annotations are safe places to store extra context that tools may rely on.

Namespaced vs Cluster-Scoped Resources

Kubernetes groups resources into two scopes:

The scope affects:

Core Categories of Kubernetes Objects

Kubernetes has many object kinds, but they can be grouped by role. These categories help you reason about how applications are defined and managed.

Workload Resources

Workload resources describe what should run.

In practice, you rarely create Pods directly; you create controllers that manage them.

Service Discovery and Networking Resources

These resources control how workloads talk to each other:

OpenShift extends these with its own routing primitives, but they are built on this core model.

Storage and Data Resources

These represent storage and configuration related to persistent data:

These objects let you describe what storage you need, not how to attach a specific disk or NFS path.

Configuration and Secret Resources

Used to externalize configuration and sensitive material from your code:

These objects enable 12-factor style configuration and separation of concerns.

Access Control and Policy Resources

Kubernetes models permissions and security-related policies using objects:

OpenShift builds on top of these with its own policy constructs, but the base is the same resource model.

Object Structure: Spec and Status

Most Kubernetes objects follow a common high-level shape:

yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
spec:
  # Desired state (what you want)
status:
  # Observed state (what exists now), filled in by the system

Controllers continuously reconcile status towards spec. You almost always edit spec, and you read status to understand what’s going on.

API Operations and Resource Lifecycles

Every resource follows the same general lifecycle:

  1. Create – via YAML manifest, oc create, or another controller
  2. Readoc get, oc describe, watches
  3. Update/Patch – modifying spec, labels, annotations, or other fields
  4. Delete – marking for deletion and cleaning up dependent resources

Under the hood, the API server exposes REST-like endpoints:

This is the same model used by oc, by controllers, and by Operators.

Custom Resources and Extensibility

Kubernetes can be extended with new object kinds without changing the core platform by using CustomResourceDefinitions (CRDs).

OpenShift makes heavy use of CRDs and Operators, but the underlying mechanism is still “objects and resources” in the API.

Objects in Practice with `oc`/`kubectl`

Although OpenShift uses oc, the resource concepts map directly:

Behind every command is the same notion: manipulating Kubernetes objects and their resources in the cluster API.

Views: 13

Comments

Please login to add a comment.

Don't have an account? Register now!