Custom resources allow extending Kubernetes API
- Custom resources can be introduced to address unsupported functionalities
- Deploying custom resources and controllers is the responsibility of devops engineer
Kubernetes supports custom resources to enhance cluster behavior.
- The number of applications and resources in the Kubernetes ecosystem keeps growing.
- Kubernetes cannot accommodate logic for all these applications, so it uses custom controllers to handle them.
Kubernetes allows extending capabilities by adding custom resources
- Kubernetes allows users to extend the API by adding new API resources
- Three resources can be used to extend the API: Custom Resource Definition (CRD), CR, and Custom Controller
Understanding custom resource and resource definition in Kubernetes
- Resource definition validates if the created resource is correct or not
- Custom resource enhances the behavior of Kubernetes and extends its API
Virtual service is a custom resource that extends the capabilities of Kubernetes API and is validated against a CRD.
- CRDs are used to define the structure and validation rules for custom resources.
- Custom resources are created by users and are validated against the CRD before being deployed to the Kubernetes cluster.
A virtual service custom resource is deployed onto the Kubernetes cluster.
- A user (developer or DevOps engineer) creates a custom resource named 'vs' in the 'Abhishek' namespace.
- The API server validates the custom resource against the virtual service CRD, allowing the request to pass if it's correct.
Deploy a custom controller to watch and perform actions on the custom resource.
- The custom controller is deployed using the helm chart, plain manifest, or operator.
- The custom controller reads the custom resource and performs the required action, such as Istio configuration.
Writing a custom controller in Golang is the preferred way in Kubernetes.
- Kubernetes API is interacted using client-go component inside the Kubernetes API server.
- Client-go supports multiple languages, but Golang is recommended due to community support and the ecosystem.
Creating custom Watchers for Kubernetes controllers using client go or Kubernetes controller runtime
- By default, Kubernetes has inbuilt Watches for resources like deployment and service
- To write a custom Kubernetes controller, you need to create new Watchers using frameworks like Kubernetes controller runtime
Custom Kubernetes controllers are widely used in the community and can be easily deployed with custom resource definitions.
- You can write a custom resource definition easily to define your own resources.
- Popular custom Kubernetes controllers can be found on the GitHub page of the Cloud Native Computing Foundation (CNCF).
CNCF provides support for custom Kubernetes controllers and projects.
- CNCF incubation provides attention and support to projects.
- Custom Kubernetes controllers like CoreDNS, Crossplane, Prometheus, and Istio are popular in the community.
To deploy Istio-related custom controllers in your namespace and create Istio virtual services, follow the provided documentation.
- Copy the Helm commands to add the Istio repo and update it.
- After completing the installation steps, choose a Helm release and create an Istio namespace.
As a DevOps engineer, it is important to debug and understand custom resources and controllers in Kubernetes.
- The HTO controller can be used to check the logs and status of a virtual service resource.
- Follow the documentation to create custom resources and controllers for different tools like Istio, Argo CD, and Prometheus.