Skip to content

Commit dd0222e

Browse files
add documentation for the helm based addons
1 parent c3caac3 commit dd0222e

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
title: "Helm Based Addons"
3+
weight: 5
4+
description: >
5+
How to develop minikube addons using Helm charts.
6+
---
7+
8+
## Overview
9+
10+
Minikube supports creating addons that are deployed via Helm charts. This allows for more complex applications to be managed as addons. This guide will walk you through creating a Helm-based addon.
11+
12+
For a general overview of creating addons, please see the [Creating a new addon](https://minikube.sigs.k8s.io/docs/contrib/addons/) guide first. This guide focuses on the specifics of Helm-based addons.
13+
14+
## Creating a Helm-based addon
15+
16+
Creating a Helm-based addon is very similar to creating a standard addon, with a few key differences in how the addon is defined.
17+
18+
### 1. Define the Addon in `pkg/minikube/assets/addons.go`
19+
20+
The core of a Helm-based addon is the `HelmChart` struct within your `Addon` definition. You will define your addon in `pkg/minikube/assets/addons.go`.
21+
22+
Here is an example of what a Helm-based addon definition looks like:
23+
24+
```go
25+
"my-helm-addon": NewAddon(
26+
[]*BinAsset{}, // Usually empty for pure Helm addons
27+
false,
28+
"my-helm-addon",
29+
"Your Name",
30+
"",
31+
"path/to/your/addon/docs.md",
32+
map[string]string{
33+
// Optional: Define images for caching if not in the chart
34+
},
35+
map[string]string{
36+
// Optional: Define registries for images
37+
},
38+
&HelmChart{
39+
Name: "my-helm-addon-release",
40+
Repo: "oci://my-repo/my-chart",
41+
Namespace: "my-addon-namespace",
42+
Values: []string{
43+
"key1=value1",
44+
"key2=value2",
45+
},
46+
ValueFiles: []string{
47+
// Paths to values files inside the minikube VM
48+
},
49+
},
50+
),
51+
```
52+
53+
#### `HelmChart` struct fields:
54+
55+
* `Name`: The release name for the Helm installation (`helm install <release-name>`).
56+
* `Repo`: The Helm chart repository URL (e.g., `stable/chart-name` or `oci://my-repo/my-chart`).
57+
* `Namespace`: The Kubernetes namespace to install the chart into. The `--create-namespace` flag is always used.
58+
* `Values`: A slice of strings for setting individual values via `--set` (e.g., `key=value`).
59+
* `ValueFiles`: A slice of strings pointing to paths of YAML value files inside the minikube VM. These are passed to Helm with the `--values` flag.
60+
61+
When the addon is enabled, minikube will automatically ensure the `helm` binary is installed within the cluster and then run `helm upgrade --install` with the parameters you have defined. When disabled, it will run `helm uninstall`.
62+
63+
### 2. Add the Addon to `pkg/addons/config.go`
64+
65+
To make your addon visible to `minikube addons list` and enable it to be managed, you need to add an entry for it in `pkg/addons/config.go`.
66+
67+
```go
68+
{
69+
name: "my-helm-addon",
70+
set: SetBool,
71+
callbacks: []setFn{EnableOrDisableAddon},
72+
},
73+
```
74+
75+
### 3. Testing your Helm Addon
76+
77+
To test your new addon, rebuild minikube and enable it:
78+
79+
```shell
80+
make && ./out/minikube addons enable my-helm-addon
81+
```
82+
83+
You can then verify that the Helm chart was deployed correctly using `kubectl`.
84+
85+
```bash
86+
kubectl -n my-addon-namespace get pods
87+
```

0 commit comments

Comments
 (0)