liveBook · Manning

Custom object

As explained in Acing the Certified Kubernetes Administrator Exam, Second Edition

A custom resource is a Kubernetes API resource instance representing domain-specific state defined by a custom resource definition.

A custom object, also called a custom resource (CR), is an instance of a resource type defined by a custom resource definition (CRD). It is the YAML or kubectl-managed object that an operator watches and reconciles. section 5.4.3 section 5.4

Use the distinction between the definition and its instances when working with custom objects:

  • A CRD defines the schema, API group, version, kind, resource name, and scope. section 5.4.1
  • A custom object instantiates that definition and supplies metadata plus desired state in its spec. section 5.4.3
  • An operator observes the object and performs application-specific work such as deployment, scaling, or healing. section 5.4

Create and verify a PostgreSQL custom object

Apply a Cluster object with apiVersion postgresql.cnpg.io/v1, name my-postgres-cluster, namespace default, one instance, and 1Gi of storage. Verify it with kubectl get cluster my-postgres-cluster, kubectl describe cluster my-postgres-cluster, and kubectl get pods; the resulting status can report a healthy cluster and a Running PostgreSQL pod. section 5.4.3

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: my-postgres-cluster
  namespace: default
spec:
  instances: 1
  storage:
    size: 1Gi

Inspect the complete Cluster manifest to connect apiVersion, kind, metadata, namespace, and spec fields with the resulting custom object. section 5.4.3

How Acing the Certified Kubernetes Administrator Exam, Second Edition covers it

How deep it goes
Explains the CR-versus-CRD distinction, manifest fields, operator interaction, and kubectl verification, without descending into controller implementation.
Examples
Uses a CloudNativePG Cluster object with one instance and 1Gi storage, then checks cluster status, description, and pod readiness.
What it assumes
Assumes a corresponding CRD and operator are installed, while teaching the CRD-versus-CR relationship and object fields explicitly.
What you can do after
Operate/configure a custom resource with YAML and kubectl, then verify reconciliation through resource status, descriptions, and pods.
How it connects
Connects custom objects to custom resource definitions, operators, controllers, Kubernetes APIs, YAML, namespaces, and kubectl.

Also explained in

Compare how 2 books explain custom object →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Certified Kubernetes Administrator Exam, Second Edition. The section links point to the parts of the book it draws on.