In the previous learning modules, we covered how to easily create the following types of Operators with the Operator SDK:
Go: Ideal for traditional software development teams that want to get to a fully auto-pilot Operator. It gives you the ability to leverage the same Kubernetes libraries the upstream projects uses under the hood. Check out the Go Getting Started guide.
Ansible: Useful for infrastructure-focused teams that have investment in Ansible modules but want to use them in a Kubernetes-native way. Also great for using Ansible to configure off-cluster objects like hardware load balancers. Check out the Ansible Getting Started guide.
We will now focus on the easiest way to get started developing an Operator:
- Helm: Useful for securely running Helm charts without Tiller and it doesn’t rely on manual invocation of Helm to reconfigure your apps. Check out the Helm Operator Getting Started guide for more information.
Creating a CockroachDB Operator from a Helm Chart
In this tutorial, we will create a CockroachDB Operator from an existing CockroachDB Helm Chart.
CockroachDB is a distributed SQL database built on a transactional and strongly-consistent key-value store. It can:
- Scale horizontally.
- Survive disk, machine, rack, and even datacenter failures with minimal latency disruption and no manual intervention.
- Supports strongly-consistent ACID transactions and provides a familiar SQL API for structuring, manipulating, and querying data.
Thank you for taking a closer look at Operator SDK's Helm Operator. For more information, check out the links below:
- Helm Operator Getting Started guide: https://github.com/operator-framework/operator-sdk/blob/master/doc/helm/user-guide.md
- Operator-Framework: https://github.com/operator-framework
- Operator-SDK: https://github.com/operator-framework/operator-sdk/
- Kubernetes Slack Chat (upstream): #kubernetes-operators at https://kubernetes.slack.com/
- Operator-Framework on Google Groups: https://groups.google.com/forum/#!forum/operator-framework
- OpenShift Operators Special Interest Group (SIG): https://commons.openshift.org/sig/OpenshiftOperators.html
Operator SDK with Helm
Initialize the Project
Let's begin my creating a new project called
oc new-project myproject
Let's now create a new directory in our
mkdir -p $GOPATH/src/github.com/redhat/
Navigate to the directory:
Create a new Helm-based Operator SDK project for the CockroachDB Operator:
operator-sdk new cockroachdb-operator --type=helm --helm-chart cockroachdb --helm-chart-repo https://kubernetes-charts.storage.googleapis.com
Navigate to the top-level project directory:
Project Scaffolding Layout
After creating a new operator project using
operator-sdk new --type helm, the project directory has numerous generated folders and files. The following table describes a basic rundown of the generated files and directories:
|deploy||Contains a generic set of Kubernetes manifests for deploying this operator on a Kubernetes cluster.|
||Contains a Helm chart initialized using the equivalent of [
|build||Contains scripts that the operator-sdk uses for build and initialization.|
|watches.yaml||Contains Group, Version, Kind, and Helm chart location.|