Skip to content

Commit bdd730a

Browse files
committed
Add Helm charts proposal
Signed-off-by: Atanas Dinov <atanas.dinov@suse.com>
1 parent a961ef1 commit bdd730a

File tree

1 file changed

+249
-0
lines changed

1 file changed

+249
-0
lines changed

design-proposals/helm-chart.md

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
# Overview
2+
3+
Provide and support Helm charts as an alternative installation method for KubeVirt and CDI.
4+
5+
## Motivation
6+
7+
Helm is one of the most popular choices when it comes to managing Kubernetes applications and their release lifecycle.
8+
Many software platforms prefer Helm charts for their configuration, automation and distribution capabilities.
9+
10+
## Goals
11+
12+
- Provide Helm charts for all upcoming versions of KubeVirt and CDI
13+
14+
## Non Goals
15+
16+
- Removing manifests installation method is out of scope.
17+
Users will continue to have the option to deploy KubeVirt and CDI using the manifests provided at build time.
18+
19+
## Definition of Users
20+
21+
This feature is intended for administrators of Kubernetes clusters who are managing KubeVirt's (and CDI's) release lifecycles.
22+
23+
## User Stories
24+
25+
- As a cluster administrator, I'd want to install, upgrade and uninstall KubeVirt using Helm chart
26+
- As a cluster administrator, I'd want to install, upgrade and uninstall CDI using Helm chart
27+
28+
## Repos
29+
30+
* [kubevirt/kubevirt](https://github.com/kubevirt/kubevirt)
31+
* [kubevirt/containerized-data-importer](https://github.com/kubevirt/containerized-data-importer)
32+
33+
# Design
34+
35+
In order to establish a solution design we need to answer the following questions:
36+
* How are the Helm charts going to look like?
37+
* How will the Helm charts be managed?
38+
39+
## Chart Design
40+
41+
Both KubeVirt and CDI installations depend on CRD, CR and Operator Deployment resources.
42+
43+
The current installation procedure involves creating the CRD and Operator Deployment first closely followed by creating the CR.
44+
45+
Helm, however, has limitations when it comes to [handling CRDs](https://helm.sh/docs/chart_best_practices/custom_resource_definitions/).
46+
Upgrading and deleting is not currently supported (unless templated) and CRDs must be present before creating a CR.
47+
The CR is required in order for the operator to deploy the rest of KubeVirt's dependencies and applications.
48+
49+
This leaves us with the following Helm chart layouts:
50+
51+
### Approach 1: Single chart
52+
53+
```text
54+
├── Chart.yaml
55+
├── crds
56+
│ └── kubevirt-crd.yaml
57+
├── templates
58+
│ ├── kubevirt-cr.yaml
59+
│ ├── kubevirt-hooks.yaml
60+
│ └── kubevirt-operator.yaml
61+
└── values.yaml
62+
```
63+
64+
This method allows us to have all resources in the same chart.
65+
66+
The `CustomResourceDefinition` is extracted out of `kubevirt-operator.yaml` under the special `/crds` directory which Helm will pick up and install first.
67+
Note that `kubevirt-crd.yaml` cannot be templated.
68+
69+
The installation process for this approach is simple (`$ helm install kubevirt <repo-url>`), however,
70+
there are some obstacles when it comes to upgrade and uninstall procedures.
71+
72+
Upgrading a CRD is not currently possible in Helm. Once installed, further upgrades will only detect that the CRD already exists and will ignore it.
73+
74+
Uninstalling depends on the CR being removed before the Operator. The CRD removal is also not taken care of by Helm automatically.
75+
76+
In order to resolve these issues, we can leverage [Helm's hooks mechanism](https://helm.sh/docs/topics/charts_hooks/).
77+
It allows us to intervene at certain points of the release lifecycle and perform custom operations.
78+
These operations will be defined in `kubevirt-hooks.yaml` and will consist of the following:
79+
- `pre-upgrade` hook manually applying the CRD manifest in order to perform modifications to it
80+
- `pre-delete` hook removing the CR first in order for the operator to gracefully uninstall KubeVirt's components before Helm removes it
81+
- `post-delete` hook removing the leftover CRD
82+
83+
This approach was used in [SUSE Edge's initial Helm chart](https://github.com/suse-edge/charts/tree/main/charts/kubevirt/0.1.0).
84+
[PR](https://github.com/suse-edge/charts/pull/13) for additional context.
85+
86+
### Approach 2: One CRD chart and one CR + Operator chart
87+
88+
Perhaps the most common solution to tackle the CRD problem is to extract the CRD in a separate Helm chart.
89+
90+
```text
91+
├── Chart.yaml
92+
├── templates
93+
│ └── kubevirt-crd.yaml
94+
```
95+
96+
```text
97+
├── Chart.yaml
98+
├── templates
99+
│ ├── kubevirt-cr.yaml
100+
│ ├── kubevirt-hooks.yaml
101+
│ └── kubevirt-operator.yaml
102+
└── values.yaml
103+
```
104+
105+
Here we will install the CRD chart first and the CR / Operator chart after that.
106+
Upcoming releases of KubeVirt can ship newer versions of both charts in order to avoid discrepancies between chart versions.
107+
108+
The benefits are that we don't need to worry about manually upgrading or deleting the CRD. We'd still need a `pre-delete` hook to remove the CR first though.
109+
110+
The negatives are that we'd maintain two charts instead of a single one.
111+
112+
### Approach 3: One CR chart and one CRD + Operator chart
113+
114+
The showstopper is that the CRD must exist before deploying the CR.
115+
We could also achieve this with the following split:
116+
117+
```text
118+
├── Chart.yaml
119+
├── templates
120+
│ ├── kubevirt-crd.yaml
121+
│ └── kubevirt-operator.yaml
122+
└── values.yaml
123+
```
124+
125+
```text
126+
├── Chart.yaml
127+
├── templates
128+
│ └── kubevirt-cr.yaml
129+
└── values.yaml
130+
```
131+
132+
This approach is also similar to the current installation / uninstallation flows:
133+
134+
```shell
135+
$ helm install kubevirt-operator <repo-url>
136+
$ helm install kubevirt-cr <repo-url>
137+
...
138+
$ helm uninstall kubevirt-cr
139+
$ sleep 45 # wait for the operator to uninstall the different components
140+
$ helm uninstall kubevirt-operator
141+
```
142+
143+
Note that the CRD is under `/templates` for this example.
144+
This means that we can execute upgrades / deletes without custom hooks.
145+
This isn't possible if the CR is also a template in the same chart.
146+
147+
### Approach N: Exotic options
148+
149+
As seen above, Helm provides a lot of customization possibilities.
150+
I'd only mention some more and move on.
151+
Let me know if you're interested in either of the following:
152+
- One CRD + Operator chart, post-install hook creating the CR
153+
- One CRD, one CR and one Operator chart
154+
155+
### Overview
156+
157+
Many Helm chart layouts can work. Choosing one depends on how much we'd want to rely on chart hooks.
158+
159+
[Approach 1](#approach-1-single-chart) was chosen for the initial Helm chart linked above in order to:
160+
- stay as close as possible to the original manifest setup
161+
- demonstrate chart hooks in action
162+
163+
As mentioned earlier, I believe [Approach 2](#approach-2-one-crd-chart-and-one-cr--operator-chart) is the most popular so far.
164+
165+
[Approach 3](#approach-3-one-cr-chart-and-one-crd--operator-chart) is most similar to the current setup.
166+
167+
The CDI project has the same `CRD-Operator-CR` setup so all of the above applies to it as well.
168+
169+
Note that the file structures above are purely for illustrative purposes.
170+
Different Kubernetes resources (e.g. `rbac`) could be extracted as separate templates (files) in order to keep the charts cleaner and easier to navigate.
171+
172+
## Chart Management
173+
174+
The second problem which needs to be addressed is how Helm charts are going to be created and modified.
175+
176+
Currently, the manifests in KubeVirt are generated in two steps:
177+
1. `resource-generator` generates semi-populated configurations under `/manifests/generated`
178+
2. `manifest-templator` produces the final version of the manifests which are then shipped as part of each GitHub release
179+
180+
### Approach 1: Generate Helm chart(s)
181+
182+
Helm charts are in general not that different from plain Kubernetes manifests.
183+
It all depends on how much customization we'd allow the user but for the SUSE Edge initial chart we kept as little modifications as possible.
184+
185+
We should be able to plug in the functionality to generate a `Chart.yaml`, `values.yaml` and possibly hooks and organize those in the necessary file structure.
186+
The charts can then be generated, packaged and pushed to the configured Helm repository at build time.
187+
188+
### Approach 2: Manually curate a Helm chart
189+
190+
We can depend on the Kubernetes manifests provided as part of GitHub releases and create a Helm chart based on those.
191+
This is the approach I've seen most people attempt when trying to come up with a custom KubeVirt installation method.
192+
193+
It does not involve any changes to the manifest generation flow, however, some degree of automation would still be necessary in order to patch, package and publish the charts.
194+
The end result probably needs to be kept outside the main KubeVirt repository.
195+
196+
### Overview
197+
198+
In theory, both approaches should work.
199+
200+
[Approach 1](#approach-1-generate-helm-charts) will probably require more effort when it comes to the implementation,
201+
but it should be stable and both manifests and charts would be released simultaneously.
202+
203+
[Approach 2](#approach-2-manually-curate-a-helm-chart) is the more popular choice,
204+
however, we need to keep in mind that the complete manifests are not version controlled.
205+
This would also mean that updated Helm charts are released separately from the manifests.
206+
207+
Unfortunately, I'm still very new to KubeVirt so feedback in this section would be more than welcome.
208+
209+
I'm not familiar with CDI's current manifest creation flow yet, but I *believe* it is similar.
210+
211+
## API Examples
212+
213+
Working with Helm charts is fairly straightforward. Users should be able to manage the applications by:
214+
215+
```shell
216+
$ helm repo add kubevirt <repo-url>
217+
$ helm install kubevirt kubevirt/kubevirt --version <version> \
218+
# additional configuration
219+
$ helm install cdi kubevirt/cdi --version <version> \
220+
# additional configuration
221+
$ helm uninstall kubevirt
222+
$ helm uninstall cdi
223+
```
224+
225+
## Scalability
226+
227+
N/A
228+
229+
## Update/Rollback Compatibility
230+
231+
The feature will not impact older versions of KubeVirt or CDI.
232+
Helm charts will, however, be a viable way of updating & rolling back future releases.
233+
234+
## Functional Testing Approach
235+
236+
- Deploy KubeVirt from Helm chart
237+
- Ensure all components are created and work as expected
238+
- Slightly modify the configuration of the CRD, CR and operator's Deployment and upgrade KubeVirt
239+
- Ensure all components are working as expected and the configurations have been properly updated
240+
- Uninstall KubeVirt chart
241+
- Ensure all components have been removed
242+
243+
The same tests should be performed for CDI.
244+
245+
# Implementation Phases
246+
247+
- Create a KubeVirt Helm chart
248+
- Configure a Helm repository (using GitHub pages is probably the best option)
249+
- Create a CDI Helm chart and add it to the same Helm repository

0 commit comments

Comments
 (0)