Skip to content

Commit 23c517f

Browse files
committed
doc/proposals: adding helm operator proposal
1 parent ee6eee6 commit 23c517f

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed

doc/proposals/helm-operator.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
## Helm Operator Proposal
2+
3+
### Background
4+
5+
As was mentioned in the [Ansible Operator Proposal](./ansible-operator.md), not everyone is a golang developer, so the SDK needs to support other types of operators to gain adoption across a wider community of users.
6+
7+
[Helm](https://helm.sh/) is one of the most widely-used tools for Kubernetes application management, and it bills itself as the "package manager for Kubernetes." Operators serve a nearly identical function, but they improve on Helm's concepts by incorporating an always-on reconciliation loop rather than relying on an imperative user-driven command line tool. By integrating Helm's templating engine and release management into an operator, the SDK will further increase the number of potential users by adding the ability to deploy Charts (e.g. from Helm's [large catalog of existing Charts](https://github.com/helm/charts)) as operators with very little extra effort.
8+
9+
### Goals
10+
11+
The goal of the Helm Operator will be to create a fully functional framework for Helm Chart developers to create operators. It will also expose a library for golang users to use Helm in their operator if they so choose. These two goals in conjunction will allow users to select the best technology for their project or skillset.
12+
13+
### New Operator Type
14+
15+
This proposal creates a new type of operator called `helm`. The new type is used to tell the tooling to act on that type of operator.
16+
17+
### Package Structure
18+
19+
Packages will be added to the operator-sdk. These packages are designed to be usable by the end user if they choose to and should have a well documented public API. The proposed packages are:
20+
21+
* /operator-sdk/pkg/helm/client
22+
* Will contain a helper function to create a Helm client from `controller-runtime` manager.
23+
24+
* /operator-sdk/pkg/helm/controller
25+
* Will contain the Helm controller.
26+
* Will contain an exposed reconciler. The default `Add` method will use this reconciler.
27+
28+
* /operator-sdk/pkg/helm/engine
29+
* Will contain a Helm Engine implementation that adds owner references to generated Kubernetes resource assets, which is necessary for garbage collection of Helm chart resources.
30+
31+
* /operator-sdk/pkg/helm/internal
32+
* Will contain types and utilities used by other Helm packages in the SDK.
33+
34+
* /operator-sdk/pkg/helm/release
35+
* Will contain the Manager types and interfaces. A Manager is responsible for:
36+
* Implementing Helm's Tiller functions that are necessary to install, update, and uninstall releases.
37+
* Reconciling an existing release's resources.
38+
* A default Manager implementation is provided in this package but is not exported.
39+
* Package functions:
40+
* NewManager - method that returns a new Manager for a provided helm chart.
41+
* NewManagersFromEnv - method that returns a map of GVK to Manager types based on environment variables.
42+
* NewManagersFromFile - method that returns a map of GVK to Manager types based on a provided config file.
43+
44+
### Commands
45+
46+
We are adding and updating existing commands to accommodate the helm operator. Changes to the `cmd` package as well as changes to the generator are needed.
47+
48+
#### New
49+
50+
New functionality will be updates to allow Helm operator developers to create a new boilerplate operator structure with everything necessary to get started developing and deploying a Helm operator with the SDK.
51+
52+
```
53+
operator-sdk new <project-name> --type=helm --kind=<kind> --api-version=<group/version>
54+
```
55+
56+
This will be new scaffolding for the above command under the hood. We will:
57+
* Create a `./<project-name>` directory.
58+
* Create a `./<project-name>/charts` directory.
59+
* Generate a simple default chart at `./<project-name>/charts/<kind>`.
60+
* Create a new watches file at `./<project-name>/watches.yaml`. The chart and GVK will be defaulted based on input to the `new` command.
61+
* Create a `./<project-name>/deploy` with the Kubernetes resource files necessary to run the operator.
62+
* Create a `./build/Dockerfile` that uses the watches file and the helm chart. It will use the Helm operator as its base image.
63+
64+
The resulting structure will be:
65+
66+
```
67+
<project-name>
68+
| watches.yaml
69+
|
70+
|-- build
71+
| | Dockerfile
72+
|
73+
|-- charts
74+
| |-- <kind>
75+
| | Chart.yaml
76+
| | ...
77+
|
78+
|-- deploy
79+
| | operator.yaml
80+
| | role_binding.yaml
81+
| | role.yaml
82+
| | service_account.yaml
83+
| |
84+
| |-- crds
85+
| | <gvk>_crd.yaml
86+
| | <gvk>_cr.yaml
87+
```
88+
89+
#### Add
90+
91+
Add functionality will be updated to allow Helm operator developers to add new CRDs/CRs and to update the watches.yaml file for additional Helm charts. The command helps when a user wants to watch more than one CRD for their operator.
92+
93+
```
94+
operator-sdk add api --api-version=<group>/<version> --kind=<kind>
95+
```
96+
97+
Flags:
98+
* **Required:** --kind - the kind for the CRD.
99+
* **Required:** --api-version - the group/version for the CRD.
100+
101+
**NOTE:** `operator-sdk add controller` will not be supported, since it doesn't make sense for a Helm operator.
102+
103+
#### Up
104+
105+
Up functionality will be updated to allow Helm operator developers to run their operator locally, using the `operator-sdk` binary's built-in helm operator implementation.
106+
107+
```
108+
operator-sdk up local
109+
```
110+
111+
This should use the known structure and the helm operator code to run the operator from this location. The existing code will need to be updated with a new operator type check for `helm` (in addition to existing `go` and `ansible` types). The command works by running the operator-sdk binary, which includes the Helm operator code, as the operator process.
112+
113+
#### Build
114+
115+
Build functionality will be updated to support building a docker image from the Helm operator directory structure.
116+
117+
```
118+
operator-sdk build <image-name>
119+
```
120+
121+
### Observations and open questions
122+
123+
* There will be a large amount of overlap in the `operator-sdk` commands for the Ansible and Helm operators. We should take care to extract the resusable features of the Ansible operator commands into a shared library, usable by both Helm and Ansible commands.
124+
125+
* This proposal assumes that a Helm Operator base image will be available for building Helm operator projects. What generates the Helm operator base image and what is the registry, image name, versioning, etc.?
126+
127+
* There is a moderate amount of complexity already related to how operator types are handled between the `go` and `ansible` types. With the addition of a third type, there may need to be a larger design proposal for operator types. For example, do we need to define an `Operator` interface that each of the operator types can implement for flag verification, scaffolding, project detection, etc.?

0 commit comments

Comments
 (0)