Kubernetes - Overview
    Kubernetes - Objects
    Kubernetes - API Extensions
    Kubernetes - apimachinery
    Kubernetes - Container Runtimes (CRI)
    Kubernetes - Storage (CSI)
    Kubernetes - Networking (CNI)
    Kubernetes - Ecosystem
    Kubernetes - Tools
    Kubernetes - kubectl
    Kubernetes - client-go
    Kubernetes - Source Code
    Kubernetes - Kind
    Kubernetes - kubeconfig
    Kubernetes - Versus

Kubernetes - API Machinery

Updated: 2022-07-25

To make sure that working with one Kubernetes resource feels exactly the same as with any other Kubernetes resources, including custom resources.

It's achieved through common k8s.io/api and k8s.io/apimachinery modules that are used on both client- (client-go, kubectl, etc.) and server-side (api-server), as well as in the majority of the third-party tools and controllers.

  • k8s.io/apimachinery: a shared dependency for servers and clients to work with Kubernetes APIs. (Consumers include k8s.io/kubernetes, k8s.io/client-go, k8s.io/apiserver). For universal lower-level data structures like apiVersion, kind, name, uid, creationTimestamp, etc. Also TypeMeta, ObjectMeta.
    • Object Serialization to JSON, YAML, or Protobuf
    • Scheme (runtime.Scheme) and RESTMapper
    • Field and Label Selectors (k8s.io/apimachinery/pkg/labels)
    • API Error Handling(k8s.io/apimachinery/pkg/api/errors)
    • Utils (apimachinery/pkg/util)



Scheme is the scheme used to resolve runtime.Objects to GroupVersionKinds / Resources.

Every set of controllers needs a Scheme, which provides mappings between Kinds and their corresponding Go types.

create a new Scheme: var scheme = runtime.NewScheme()

The runtime.Scheme struct is such a registry containing the kind to type and type to kind mappings for all kinds of Kubernetes objects.