|
| 1 | +# Support bundles in helm charts |
| 2 | + |
| 3 | +A quick note on structure and formatting for support bundles in helm charts |
| 4 | + |
| 5 | +## structure |
| 6 | + |
| 7 | +Each helm chart in your release should contain a support bundle spec that collects and analyzes resources that are installed by that chart. |
| 8 | + |
| 9 | +If you're installing a helm chart from an upstream project that doesn't supply their own support bundles, you can include it as a sub-chart of a wrapper inside your release: |
| 10 | + |
| 11 | +``` |
| 12 | + app-workspace |
| 13 | + ├─ cert-manager-HelmChart.yaml |
| 14 | + ├─ cert-manager |
| 15 | + ┊ ├─ Chart.yaml |
| 16 | + └─ templates |
| 17 | + ├─ _supportbundle.tpl |
| 18 | + ├─ secret-supportbundle.yaml |
| 19 | + ┊ |
| 20 | +``` |
| 21 | + |
| 22 | +`cert-manager-HelmChart.yaml` |
| 23 | +```yaml |
| 24 | +apiVersion: kots.io/v1beta2 |
| 25 | +kind: HelmChart |
| 26 | +metadata: |
| 27 | + name: cert-manager |
| 28 | +spec: |
| 29 | + chart: |
| 30 | + name: cert-manager |
| 31 | +``` |
| 32 | +
|
| 33 | +`Chart.yaml` |
| 34 | +```yaml |
| 35 | +name: cert-manager |
| 36 | +apiVersion: v2 |
| 37 | +version: 1.0.0 |
| 38 | +dependencies: |
| 39 | + - name: cert-manager |
| 40 | + version: '1.14.5' |
| 41 | + repository: https://charts.jetstack.io |
| 42 | +``` |
| 43 | + |
| 44 | +You can see examples of this wrapper chart structure: |
| 45 | +- [Wrapped cert-manager chart](https://github.com/replicatedhq/platform-examples/tree/main/applications/wg-easy/charts/cert-manager) |
| 46 | +- [Wrapped traefik chart](https://github.com/replicatedhq/platform-examples/tree/main/applications/wg-easy/charts/traefik) |
| 47 | + |
| 48 | +## formatting |
| 49 | + |
| 50 | +To ease writing support bundles inside a secret, we can use a simple template `include` pattern to avoid having to write nested yaml structures. |
| 51 | + |
| 52 | +`templates/secret-supportbundle.yaml` |
| 53 | +```yaml |
| 54 | +apiVersion: v1 |
| 55 | +kind: Secret |
| 56 | +metadata: |
| 57 | + name: cert-manager-supportbundle |
| 58 | + labels: |
| 59 | + troubleshoot.sh/kind: support-bundle |
| 60 | +type: Opaque |
| 61 | +stringData: |
| 62 | + support-bundle-spec: | |
| 63 | +{{ include "cert-manager.supportbundle" . | indent 4 }} |
| 64 | +``` |
| 65 | + |
| 66 | +`templates/_supportbundle.tpl` |
| 67 | +```yaml |
| 68 | +{{- define "cert-manager.supportbundle" -}} |
| 69 | +apiVersion: troubleshoot.sh/v1beta2 |
| 70 | +kind: SupportBundle |
| 71 | +metadata: |
| 72 | + name: cert-manager-supportbundle |
| 73 | +spec: |
| 74 | + collectors: |
| 75 | + - logs: |
| 76 | + namespace: {{ .Release.Namespace }} |
| 77 | + selector: |
| 78 | + - app.kubernetes.io/instance=cert-manager |
| 79 | +{{- end -}} |
| 80 | +``` |
| 81 | + |
| 82 | +Some further examples can be found: |
| 83 | +- [Traefik support bundles and preflights](https://github.com/replicatedhq/platform-examples/tree/main/applications/wg-easy/charts/traefik/templates) |
| 84 | +- [cert-manager support bundles and preflights](https://github.com/replicatedhq/platform-examples/tree/main/applications/wg-easy/charts/cert-manager/templates) |
0 commit comments