This is a guest post by Rafał Leszko, Integration Team Lead at Hazelcast. It contains the summary of the OperatorCon talk and the related blog post published at Hazelcast Blog.
You have a lot of tools to choose from when you want to build a Kubernetes Operator for your software. Which is the right one for your use case? Operator SDK with Helm, Ansible, or Go? Or maybe something less common, like Python or Java? This blog post discusses different approaches to make your decision simpler.
Introduction
Kubernetes Operator is an application that watches a custom Kubernetes resource and performs some operations upon its changes.
When a user modifies anything in the custom resource, the operator application notices the change and performs some actions based on this change. These actions are usually some type of calls to Kubernetes API, but technically they can be anything.
Since an operator is simply an application, technically you can write it in any programming language you want and you can deploy it anywhere you want. However, being a pragmatic programmer, you should choose a language with a good Kubernetes client and a language that is simple to dockerize and run in the Kubernetes cluster.
Operator Tools Overview
In short, you can choose from the following options: Operator SDK (Helm, Ansible, Go), Operator Framework (that is, KOPF, Java Operator SDK), Bare Programming Language (such as Java, Kotlin, C#).
Operator SDK: Helm
Helm is a package manager for Kubernetes. It lets you create templated Kubernetes configuration files and render them automatically using Helm CLI. Then, Operator SDK can automatically generate an operator application from a given Helm chart. The benefits include:
- Implementation is declarative and simple
- Operator functionality is limited to Helm features
- Operator manifest bundle files (CRD, RBAC, Operator Deployment) are automatically generated
Operator SDK: Ansible
Ansible is a powerful tool for IT automation. Its nature is declarative and, thanks to the "community.kubernetes.k8s" plugin, it can interact with Kubernetes API. Operator SDK provides a way to scaffold an Ansible-based operator and then writing an operator logic means writing an Ansible role, with embedded Kubernetes configuration. Advantages include:
- Implementation is declarative and human-readable
- Ansible can express almost any operator functionality
- Operator manifest bundle files (CRD, RBAC, Operator Deployment) are automatically generated
Operator SDK: Go
Go is a general-purpose programming language, so you can write any operator logic you want. Kubernetes itself is written in Go, so this language interacts smoothly with Kubernetes API. Operator SDK provides a way to scaffold a Go-based operator and then implementing an operator means writing an imperative Go code. With Go:
- Implementation is imperative and more complex
- There is no limit on the functionality you want to implement
- Operator manifest bundle files (CRD, RBAC, Operator Deployment) are generated from the Go source code
Operator Framework
Apart from Operator SDK, there are other frameworks to help build an operator, such as KOPF (Kubernetes Operator Pythonic Framework) and Java Operator SDK. By using a framework:
- Logic is used in a general-purpose programming language
- Frameworks are more experimental and less developed than Operator SDK
- Kubernetes clients for Python, Java, or other languages are slightly worse than Go
- There is no limit on the functionality desired
Bare Programming Language
The last choice is to start from scratch and write all the operator implementation yourself. One popular approach is to use Java with Quarkus and build a native Docker image using GraalVM. In such a case, you need to write a lot of code, but it can be a good approach if your goal is a single programming language inside your organization. With this approach:
- Implementation is complex and requires writing a lot of code
- There is no limit on the functionality you want to implement
- There is no scaffolding or manifest files generation
Summary
Knowing the options is only half of the story. The other half is looking at what the community does and why. Programming is a collaborative effort, and you'd better stick to the solutions used by others for best results.
Here are the top used tools according to data from OperatorHub.io:
- Go: 71%
- Helm: 13%
- Java: 3%
Go-based operators are by far the most popular. That is why Go is probably the first option to consider. The other good choice is Helm, especially if you already have a Helm chart for your software or you want to build your operator quickly and you don't need any complex capability levels. I'd leave Operator Frameworks or Bare Programming Language implementations only for the cases when keeping a single programming language in your organization is a priority.
About the author
Red Hatter since 2018, technology historian and founder of The Museum of Art and Digital Entertainment. Two decades of journalism mixed with technology expertise, storytelling and oodles of computing experience from inception to ewaste recycling. I have taught or had my work used in classes at USF, SFSU, AAU, UC Law Hastings and Harvard Law.
I have worked with the EFF, Stanford, MIT, and Archive.org to brief the US Copyright Office and change US copyright law. We won multiple exemptions to the DMCA, accepted and implemented by the Librarian of Congress. My writings have appeared in Wired, Bloomberg, Make Magazine, SD Times, The Austin American Statesman, The Atlanta Journal Constitution and many other outlets.
I have been written about by the Wall Street Journal, The Washington Post, Wired and The Atlantic. I have been called "The Gertrude Stein of Video Games," an honor I accept, as I live less than a mile from her childhood home in Oakland, CA. I was project lead on the first successful institutional preservation and rebooting of the first massively multiplayer game, Habitat, for the C64, from 1986: https://neohabitat.org . I've consulted and collaborated with the NY MOMA, the Oakland Museum of California, Cisco, Semtech, Twilio, Game Developers Conference, NGNX, the Anti-Defamation League, the Library of Congress and the Oakland Public Library System on projects, contracts, and exhibitions.
Browse by channel
Automation
The latest on IT automation for tech, teams, and environments
Artificial intelligence
Updates on the platforms that free customers to run AI workloads anywhere
Open hybrid cloud
Explore how we build a more flexible future with hybrid cloud
Security
The latest on how we reduce risks across environments and technologies
Edge computing
Updates on the platforms that simplify operations at the edge
Infrastructure
The latest on the world’s leading enterprise Linux platform
Applications
Inside our solutions to the toughest application challenges
Virtualization
The future of enterprise virtualization for your workloads on-premise or across clouds