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.
저자 소개
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.
채널별 검색
오토메이션
기술, 팀, 인프라를 위한 IT 자동화 최신 동향
인공지능
고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트
오픈 하이브리드 클라우드
하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요
보안
환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보
엣지 컴퓨팅
엣지에서의 운영을 단순화하는 플랫폼 업데이트
인프라
세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보
애플리케이션
복잡한 애플리케이션에 대한 솔루션 더 보기
가상화
온프레미스와 클라우드 환경에서 워크로드를 유연하게 운영하기 위한 엔터프라이즈 가상화의 미래