Kubernetes 101 : A simple overview of the CRD - Custom Resource Definition -

There are a lot of programs that could be deployed as API objects to extend the abilities of kubernetes.

Extensions could be related for example to networking (CNI), storage (CSI) or container runtime engines (CRI).

Custom resources definition (CRD) are API objects, and can be accessed and manipulated like the kubernetes "standardAPI objects using the "kubectl" tool.

The names of the CRD resource has to follow the below naming convention:

plural-name from the "plural" in the above Yaml file.

To create the CRD resource we use the below command:

Creating instances of the CRD resource:

To create instances of our CRD resources, we define a Yaml configuration file for it:

We create our resource using the below command:

We can display our new resources using the below command:

The "testresource" API controller:

The new object needs be associated with its a API controller, to manage, monitor, create, delete, ..., the new resource.

We can either use a default controller with basic functionalities (simple loop that watches the new API object), or write our own controller.

A controller for our CRD, constantly watches the API server for instructions to create a "testresource".
It takes care of creating the deployment, the pods and the services for accessing the "testresource" pods - . 
It then, continuously watches the pods to make sure they are running as they should.


Leave as a comment: