Kubernetes - API Machinery
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/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/apiserver). For universal lower-level data structures like
creationTimestamp, etc. Also
- Object Serialization to JSON, YAML, or Protobuf
- Scheme (
runtime.Scheme) and RESTMapper
- Field and Label Selectors (
- API Error Handling(
- Utils (
Scheme is the scheme used to resolve
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()
runtime.Scheme struct is such a registry containing the kind to type and type to kind mappings for all kinds of Kubernetes objects.
How to check conditions
// "k8s.io/apimachinery/pkg/api/meta" conds := Foo.Status.Conditions meta.IsStatusConditionTrue(conds, conditionType)