Skip to content

Commit

Permalink
fix: resolve helm chart clobbering and confusion between Zarf and Hel…
Browse files Browse the repository at this point in the history
…m `chart` names (#2174)

## Description

This resolves issues where helm charts would have a potential to clobber
each other and also decouples Zarf `charts.Name` from Helm chart names
to increase consistency and reduce confusion.

## Related Issue

Fixes #2062
Fixes #1765

## Type of change

- [X] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Other (security config, docs update, etc)

## Checklist before merging

- [X] Test, docs, adr added or updated as needed
- [X] [Contributor Guide
Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow)
followed
  • Loading branch information
Racer159 authored Dec 6, 2023
1 parent efd265a commit 66b6006
Show file tree
Hide file tree
Showing 12 changed files with 178 additions and 179 deletions.
13 changes: 2 additions & 11 deletions docs/3-create-a-zarf-package/2-zarf-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,11 @@ Charts using the `url` key can be:

- A remote URL (http/https) to a Git repository
- A remote URL (oci://) to an OCI registry
- A remote URL (http/https) to a Helm repository

#### Chart Examples

<Tabs queryString="chart-examples">
<TabItem value="localPath">
<ExampleYAML src={require('../../examples/helm-charts/zarf.yaml')} component="demo-helm-local-chart" />
</TabItem>
<TabItem value="URL (git)">
<ExampleYAML src={require('../../examples/helm-charts/zarf.yaml')} component="demo-helm-git-chart" />
</TabItem>
<TabItem value="URL (oci)">
<ExampleYAML src={require('../../examples/helm-charts/zarf.yaml')} component="demo-helm-oci-chart" />
</TabItem>
</Tabs>
<ExampleYAML src={require('../../examples/helm-charts/zarf.yaml')} component="demo-helm-charts" />

### Kubernetes Manifests

Expand Down
80 changes: 48 additions & 32 deletions docs/3-create-a-zarf-package/4-zarf-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ Must be one of:

![Required](https://img.shields.io/badge/Required-red)

**Description:** The name of the chart to deploy; this should be the name of the chart as it is installed in the helm repo
**Description:** The name of the chart within Zarf; note that this must be unique and does not need to be the same as the name in the chart repo

| | |
| -------- | -------- |
Expand All @@ -999,12 +999,12 @@ Must be one of:

<details>
<summary>
<strong> <a name="components_items_charts_items_releaseName"></a>releaseName</strong>
<strong> <a name="components_items_charts_items_version"></a>version</strong>
</summary>
&nbsp;
<blockquote>

**Description:** The name of the release to create; defaults to the name of the chart
**Description:** The version of the chart to deploy; for git-based charts this is also the tag of the git repo by default (when not using the '@' syntax for 'repos')

| | |
| -------- | -------- |
Expand All @@ -1029,19 +1029,19 @@ Must be one of:
**Examples:**

<code>
"OCI registry: oci://ghcr.io/stefanprodan/charts/podinfo", "helm chart repo: https://stefanprodan.github.io/podinfo", "git repo: https://github.com/stefanprodan/podinfo"</code>
"OCI registry: oci://ghcr.io/stefanprodan/charts/podinfo", "helm chart repo: https://stefanprodan.github.io/podinfo", "git repo: https://github.com/stefanprodan/podinfo (note the '@' syntax for 'repos' is supported here too)"</code>

</blockquote>
</details>

<details>
<summary>
<strong> <a name="components_items_charts_items_version"></a>version</strong>
<strong> <a name="components_items_charts_items_repoName"></a>repoName</strong>
</summary>
&nbsp;
<blockquote>

**Description:** The version of the chart to deploy; for git-based charts this is also the tag of the git repo
**Description:** The name of a chart within a Helm repository (defaults to the Zarf name of the chart)

| | |
| -------- | -------- |
Expand All @@ -1052,41 +1052,33 @@ Must be one of:

<details>
<summary>
<strong> <a name="components_items_charts_items_namespace"></a>namespace *</strong>
<strong> <a name="components_items_charts_items_gitPath"></a>gitPath</strong>
</summary>
&nbsp;
<blockquote>

![Required](https://img.shields.io/badge/Required-red)

**Description:** The namespace to deploy the chart to
**Description:** (git repo only) The sub directory to the chart within a git repo

| | |
| -------- | -------- |
| **Type** | `string` |

**Example:**

<code>
"charts/your-chart"</code>

</blockquote>
</details>

<details>
<summary>
<strong> <a name="components_items_charts_items_valuesFiles"></a>valuesFiles</strong>
<strong> <a name="components_items_charts_items_localPath"></a>localPath</strong>
</summary>
&nbsp;
<blockquote>

**Description:** List of local values file paths or remote URLs to include in the package; these will be merged together

| | |
| -------- | ----------------- |
| **Type** | `array of string` |

![Min Items: N/A](https://img.shields.io/badge/Min%20Items%3A%20N/A-gold)
![Max Items: N/A](https://img.shields.io/badge/Max%20Items%3A%20N/A-gold)
![Item unicity: False](https://img.shields.io/badge/Item%20unicity%3A%20False-gold)
![Additional items: N/A](https://img.shields.io/badge/Additional%20items%3A%20N/A-gold)

### <a name="autogenerated_heading_11"></a>valuesFiles items
**Description:** The path to a local chart's folder or .tgz archive

| | |
| -------- | -------- |
Expand All @@ -1097,33 +1089,30 @@ Must be one of:

<details>
<summary>
<strong> <a name="components_items_charts_items_gitPath"></a>gitPath</strong>
<strong> <a name="components_items_charts_items_namespace"></a>namespace *</strong>
</summary>
&nbsp;
<blockquote>

**Description:** The path to the chart in the repo if using a git repo instead of a helm repo
![Required](https://img.shields.io/badge/Required-red)

**Description:** The namespace to deploy the chart to

| | |
| -------- | -------- |
| **Type** | `string` |

**Example:**

<code>
"charts/your-chart"</code>

</blockquote>
</details>

<details>
<summary>
<strong> <a name="components_items_charts_items_localPath"></a>localPath</strong>
<strong> <a name="components_items_charts_items_releaseName"></a>releaseName</strong>
</summary>
&nbsp;
<blockquote>

**Description:** The path to the local chart's folder or .tgz archive
**Description:** The name of the Helm release to create (defaults to the Zarf name of the chart)

| | |
| -------- | -------- |
Expand All @@ -1148,6 +1137,33 @@ Must be one of:
</blockquote>
</details>

<details>
<summary>
<strong> <a name="components_items_charts_items_valuesFiles"></a>valuesFiles</strong>
</summary>
&nbsp;
<blockquote>

**Description:** List of local values file paths or remote URLs to include in the package; these will be merged together when deployed

| | |
| -------- | ----------------- |
| **Type** | `array of string` |

![Min Items: N/A](https://img.shields.io/badge/Min%20Items%3A%20N/A-gold)
![Max Items: N/A](https://img.shields.io/badge/Max%20Items%3A%20N/A-gold)
![Item unicity: False](https://img.shields.io/badge/Item%20unicity%3A%20False-gold)
![Additional items: N/A](https://img.shields.io/badge/Additional%20items%3A%20N/A-gold)

### <a name="autogenerated_heading_11"></a>valuesFiles items

| | |
| -------- | -------- |
| **Type** | `string` |

</blockquote>
</details>

</blockquote>
</details>

Expand Down
106 changes: 39 additions & 67 deletions examples/helm-charts/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,45 @@ metadata:
version: 0.0.1

components:
- name: demo-helm-local-chart
required: false
- name: demo-helm-charts
required: true
charts:
- name: podinfo
# Charts are organized in a list with unique chart names per component - note that a Zarf chart name does not need to match the chart name in a Chart.yaml
- name: podinfo-local
version: 6.4.0
namespace: podinfo-from-local-chart
# In this case `localPath` will load the podinfo chart that is located in the `chart` directory
localPath: chart
valuesFiles:
- values.yaml
images:
- ghcr.io/stefanprodan/podinfo:6.4.0
# This is the cosign signature for the podinfo image for image signature verification
- ghcr.io/stefanprodan/podinfo:sha256-57a654ace69ec02ba8973093b6a786faa15640575fbf0dbb603db55aca2ccec8.sig
actions:
onDeploy:
after:
- wait:
cluster:
kind: deployment
name: podinfo
namespace: podinfo-from-local-chart
condition: available

- name: podinfo-oci
version: 6.4.0
namespace: podinfo-from-oci
# In this case `url` will load the helm chart located in the podinfo OCI repository
url: oci://ghcr.io/stefanprodan/charts/podinfo
valuesFiles:
- values.yaml

- name: demo-helm-git-chart
required: false
charts:
- name: podinfo
- name: podinfo-git
version: 6.4.0
namespace: podinfo-from-git
# In this case `url` will load the helm chart located in the podinfo git repository
url: https://github.com/stefanprodan/podinfo.git
# By default git will look in the root of the git repository but you can define a sub directory with `gitPath`
gitPath: charts/podinfo
valuesFiles:
- values.yaml
images:
- ghcr.io/stefanprodan/podinfo:6.4.0
# This is the cosign signature for the podinfo image for image signature verification
- ghcr.io/stefanprodan/podinfo:sha256-57a654ace69ec02ba8973093b6a786faa15640575fbf0dbb603db55aca2ccec8.sig
actions:
onDeploy:
after:
- wait:
cluster:
kind: deployment
namespace: podinfo-from-git
name: podinfo
condition: available

- name: demo-helm-oci-chart
required: false
charts:
- name: podinfo
- name: podinfo-repo
version: 6.4.0
namespace: podinfo-from-oci
url: oci://ghcr.io/stefanprodan/charts/podinfo
namespace: podinfo-from-repo
# In this case `url` will load the helm chart located in the podinfo helm repository
url: https://stefanprodan.github.io/podinfo
# By default the chart `name` will be what is used to search a repository but since Zarf chart names must be unique per-component you can override this with `repoName`
repoName: podinfo
# By default the release name will be the chart name, but you can override this with the `releaseName` key
releaseName: cool-release-name
valuesFiles:
- values.yaml
images:
Expand All @@ -70,38 +55,25 @@ components:
after:
- wait:
cluster:
kind: pod
name: app.kubernetes.io/name=podinfo
namespace: podinfo-from-oci
condition: ready
kind: deployment
name: podinfo-local
namespace: podinfo-from-local-chart
condition: available
- wait:
cluster:
kind: deployment
# note this version is the same as the chart version
name: app.kubernetes.io/version=6.4.0
name: podinfo-oci
namespace: podinfo-from-oci
condition: available

- name: demo-helm-alt-release-name
required: false
charts:
- name: podinfo
version: 6.4.0
namespace: helm-alt-release-name
url: https://stefanprodan.github.io/podinfo
releaseName: cool-name
valuesFiles:
- values.yaml
images:
- ghcr.io/stefanprodan/podinfo:6.4.0
# This is the cosign signature for the podinfo image for image signature verification
- ghcr.io/stefanprodan/podinfo:sha256-57a654ace69ec02ba8973093b6a786faa15640575fbf0dbb603db55aca2ccec8.sig
actions:
onDeploy:
after:
- wait:
cluster:
kind: pod
name: app.kubernetes.io/name=cool-name-podinfo
namespace: helm-alt-release-name
condition: ready
kind: deployment
name: podinfo-git
namespace: podinfo-from-git
condition: available
- wait:
cluster:
kind: deployment
name: cool-release-name-podinfo
namespace: podinfo-from-repo
condition: available
Loading

0 comments on commit 66b6006

Please sign in to comment.