Difficulty: Beginner
Estimated Time: 15 minutes

Kubernetes Custom Resource Definitions

Kubernetes

This scenario takes you through the essentials of defining new Kubernetes Custom Resource Definitions (CRDs). You will extend Kubernetes by creating new resources beyond the standard ones you normally get with any Kubernetes cluster. Once you understand CRDs this will lead you to understanding how to further extend Kubernetes using the powerful Operator Pattern.

In this scenario you will learn how to:

  • Create a CRD and define custom attributes
  • Discover how your CRD becomes a new resource
  • Add, inspect and remove instances of a custom resource

Conclusion

Custom Resource Definitions (CRDs) are a mechanism used to add new kinds into a Kubernetes cluster. CRDs are all part of the extensibility of Kubernetes and it API. CRDs are in widespread use as a Kubernetes extensibility mechanism and have been available in beta since the 1.7 release. The 1.16 release marks the graduation of CRDs to general availability (GA). When added with controllers watching the CRDs, enables a custom declarative experience. You now have a solid introduction to the powerful Operator Pattern.

Lessons Learned

With these steps you have learned:

  • ✔ how to create a CRD and define custom attributes,
  • ✔ how how your CRD becomes a new resource,
  • ✔ how to add, inspect and remove instances of a custom resource.

Special Thank You

To Ken Sipe as he inspired this scenario from his labs found here.

References


For a deeper understanding of these topics and more join
Jonathan Johnson
at various conferences, symposiums, workshops and meetups.

Software Architectures ★ Speaker ★ Workshop Hosting ★ Kubernetes & Java Specialist

Custom Resource Definitions

Step 1 of 6

Your Kubernetes Cluster

For this scenario, Katacoda has just started a fresh Kubernetes cluster for you. Verify it's ready for your use.

kubectl version --short && \ kubectl get componentstatus && \ kubectl get nodes && \ kubectl cluster-info

The Helm package manager used for installing applications on Kubernetes is also available.

helm version --short

Kubernetes Dashboard

You can administer your cluster with the kubectl CLI tool or use the visual Kubernetes Dashboard. Use this script to access the protected Dashboard.

token.sh