In this scenario, you will experience what it's like to create and run a Kubernetes Operator that manages a custom resource. The Operator is created using the Kubebuilder tool. The custom resources will be called
Kubebuilder was released as open source in August from 2018. Two technical staff members from Google, Phillip Wittrock and Sunil Arora, founded the project. Kubebuilder is now a Kubernetes special interest group (SIG) under Apache License 2.0.
The Operator pattern is a very important technique to extend and build upon the basic features of Kubernetes. Operators are controllers with roles that observe and manage associated CRDs. There are a variety of projects that provide tools to build Operators. Kubebuilder is one prominent technique.
This scenario stands on the shoulders of others. The
at utility is found on many operating systems, and it allows you to schedule a command to run at a future date. There is a project called cnat and it stands for cloud native at. There is also an outdated tutorial on Kubebuilder with cnat. Many improvements were applied to Kubebuilder which deprecated that tutorial. Recently, Ken Sipe created a updated lab inspired by
at, cnat, and the old tutorial. In turn, this scenario is a translation of Ken's lab onto Katacoda. You now get to enjoy the broad shoulders of open source and the cloud native community.
In this scenario you will learn how to:
- Modify, build, and test code in a Kubebuilder skeleton project
- Create a new CRD call
Atthrough Go structs and automation
- Define RBACs created through generations from code annotations
- Create a controller for observing and managing the
- Associate Kubernetes events back to the managed resources
You now have a better understanding of how to write an Operator using the Kubebuilder. The real goal of this scenario is to show you the power of extending Kubernetes with your own custom resources and coding controllers that are dedicated to observing and managing your custom resources.
There are some competing Operator frameworks, such as the Operator-SDK, Metacontroller, and KUDO. KUDO, governed by D2IQ, might be an easier way to write an Operator because it embraces a declarative form over an imperative Go-based controller. Head over to the scenario "Kubernetes Extensibility: Develop an Operator with KUDO" and hopefully you will see how to make writing Operators even easier.
With these steps you have learned:
- ✔ How to modify, build and test code in a Kubebuilder skeleton project
- ✔ How to create a CRD through Go structs and, automation
- ✔ How to define RBACs created through generation from code annotations
- ✔ How to create a controller for observing and managing the
- ✔ How to associate Kubernetes events back to the managed resources
Special Thank You
- Article: Kubebuild origin
- Operator pattern
- Custom Resource Definitions (CRDs)
- The Kubebuilder book
- Kuberbuilder with cnat, deprecated
Develop an Operator with Kubebuilder
Your Kubernetes Cluster
For this scenario, Katacoda started a fresh Kubernetes cluster for you. Verify that it's ready:
kubectl version --short && \
kubectl get componentstatus && \
kubectl get nodes && \
The Helm package manager used for installing applications on Kubernetes is also available:
helm version --short
You can administer your cluster with the
kubectl CLI tool or use the visual Kubernetes Dashboard. Use this script to access the protected Dashboard: