Skip to content

Commit 540a0ed

Browse files
committed
feat: Add an ArgoCD Application chart to replace AppSets
The AppSets have proven to have quite a bit of limitations and attempts to make the kustomize interface take references like the helm interface can from different repos or branches has not merged upstream. It's harder to see what is being generated or rendered by the AppSet as well. ArgoCD's UI doesn't show AppSets or what they are doing but shows Applications in detail. So switch to utilizing Helm to generate the Applications. We have the added benefit that the Applications can be of different base templates in the same ArgoCD for targeting different clusters as well. With AppSets we have the same base template that is used for all the clusters so they need to stay relatively at the same version.
1 parent 66f0d03 commit 540a0ed

File tree

9 files changed

+513
-2
lines changed

9 files changed

+513
-2
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
name: argocd-understack release
3+
4+
on:
5+
push:
6+
tags:
7+
- "argocd-understack-v*.*.*"
8+
workflow_dispatch:
9+
inputs:
10+
chart_version:
11+
description: "Chart version to release (e.g., 0.1.0)"
12+
required: true
13+
type: string
14+
15+
permissions:
16+
contents: read
17+
packages: write
18+
id-token: write
19+
20+
jobs:
21+
release:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v6
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Set up Helm
30+
uses: azure/setup-helm@v4
31+
with:
32+
version: v3.18.4
33+
34+
- name: Install Cosign
35+
uses: sigstore/cosign-installer@v3
36+
37+
- name: Extract version from tag or input
38+
id: version
39+
run: |
40+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
41+
VERSION="${{ inputs.chart_version }}"
42+
else
43+
VERSION=${GITHUB_REF#refs/tags/argocd-understack-v}
44+
fi
45+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
46+
47+
- name: Helm lint
48+
run: |
49+
helm lint charts/argocd-understack --strict
50+
51+
- name: Package chart
52+
run: |
53+
VERSION="${{ steps.version.outputs.version }}"
54+
helm package charts/argocd-understack --version "$VERSION"
55+
56+
- name: Login to GitHub Container Registry
57+
run: |
58+
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
59+
60+
- name: Push chart to GHCR
61+
run: |
62+
VERSION="${{ steps.version.outputs.version }}"
63+
CHART_PACKAGE="argocd-understack-${VERSION}.tgz"
64+
65+
if [[ ! -f "$CHART_PACKAGE" ]]; then
66+
echo "::error::Chart package $CHART_PACKAGE not found"
67+
ls -la *.tgz
68+
exit 1
69+
fi
70+
71+
helm push "$CHART_PACKAGE" oci://ghcr.io/${{ github.repository }}
72+
73+
echo "::notice::Chart pushed to oci://ghcr.io/${{ github.repository }}/argocd-understack:${VERSION}"
74+
75+
- name: Sign chart with Cosign
76+
run: |
77+
VERSION="${{ steps.version.outputs.version }}"
78+
cosign sign --yes ghcr.io/${{ github.repository }}/argocd-understack:${VERSION}
79+
80+
echo "::notice::Chart signed with keyless signature"
81+
82+
- name: Logout from GHCR
83+
if: always()
84+
run: |
85+
helm registry logout ghcr.io
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
name: Helm Chart Testing
3+
4+
on:
5+
pull_request:
6+
paths:
7+
- "charts/**"
8+
- ".github/workflows/helm-chart-test.yaml"
9+
push:
10+
branches:
11+
- main
12+
paths:
13+
- "charts/**"
14+
merge_group:
15+
types: [checks_requested]
16+
workflow_dispatch:
17+
18+
jobs:
19+
lint-test:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v6
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Set up Helm
28+
uses: azure/setup-helm@v4
29+
with:
30+
version: v3.18.4
31+
32+
- name: Set up Python
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: "3.12"
36+
check-latest: true
37+
38+
- name: Set up chart-testing
39+
uses: helm/chart-testing-action@v2
40+
41+
- name: Run chart-testing (list-changed)
42+
id: list-changed
43+
run: |
44+
changed=$(ct list-changed --chart-dirs charts --target-branch ${{ github.event.repository.default_branch }})
45+
if [[ -n "$changed" ]]; then
46+
echo "changed=true" >> "$GITHUB_OUTPUT"
47+
48+
# Set individual output variables for each changed chart
49+
for chart in $changed; do
50+
chart_name=$(basename "$chart")
51+
echo "$chart_name=true" >> "$GITHUB_OUTPUT"
52+
echo "Changed: $chart_name"
53+
done
54+
fi
55+
56+
- name: Run chart-testing (lint)
57+
if: steps.list-changed.outputs.changed == 'true'
58+
run: ct lint --chart-dirs charts --target-branch ${{ github.event.repository.default_branch }}
59+
60+
- name: Create kind cluster
61+
if: steps.list-changed.outputs.changed == 'true'
62+
uses: helm/kind-action@v1
63+
64+
- name: Install ArgoCD
65+
if: steps.list-changed.outputs.argocd-understack == 'true'
66+
run: |
67+
./bootstrap/argocd.sh
68+
69+
- name: Run chart-testing (install)
70+
if: steps.list-changed.outputs.argocd-understack == 'true'
71+
run: helm install charts/argocd-understack --namespace argocd --values charts/argocd-understack/ci/example.yaml

bootstrap/argocd.sh

100644100755
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ argocd_rev=$(cat "${thisdir}/../apps/appsets/argocd/appset-argocd.yaml" | yq -r
1010
helm repo add argo "${argocd_repo}"
1111
helm repo update argo
1212

13-
helm template argo-cd argo-cd \
13+
kubectl create ns argocd
14+
15+
helm template argo/argo-cd \
1416
--version "${argocd_rev}" \
15-
--create-namespace \
17+
--namespace argocd \
1618
-f "${thisdir}/../components/argocd/values.yaml" \
1719
| kubectl -n argocd apply -f -
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: v2
2+
name: argocd-understack
3+
description: ArgoCD Application definitions for UnderStack
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "1.16.0"
25+
26+
maintainers:
27+
- name: rackerlabs
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
deploy_url: https://github.com/example/example
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "understack.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "understack.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "understack.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "understack.labels" -}}
37+
helm.sh/chart: {{ include "understack.chart" . }}
38+
{{ include "understack.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "understack.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "understack.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "understack.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "understack.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
63+
64+
{{/*
65+
Create a valid ArgoCD Application name
66+
*/}}
67+
{{- define "understack.argocdAppName" -}}
68+
{{- $root := index . 0 }}
69+
{{- $appName := index . 1 }}
70+
{{- printf "%s-%s" $root.Release.Name $appName }}
71+
{{- end }}
72+
73+
{{/*
74+
Get the UnderStack repository URL
75+
*/}}
76+
{{- define "understack.understack_url" -}}
77+
{{- .Values.understack_url }}
78+
{{- end }}
79+
80+
{{/*
81+
Get the UnderStack repository git reference
82+
*/}}
83+
{{- define "understack.understack_ref" -}}
84+
{{- .Values.understack_ref }}
85+
{{- end }}
86+
87+
{{/*
88+
Get the deployment repository URL
89+
*/}}
90+
{{- define "understack.deploy_url" -}}
91+
{{- required "deploy_url is required. Please set it in your values file" .Values.deploy_url }}
92+
{{- end }}
93+
94+
{{/*
95+
Get the deployment repository git reference
96+
*/}}
97+
{{- define "understack.deploy_ref" -}}
98+
{{- .Values.deploy_ref }}
99+
{{- end }}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{{- range $appName, $app := .Values.site.openstack.apps }}
2+
{{- if $app.enabled }}
3+
---
4+
apiVersion: argoproj.io/v1alpha1
5+
kind: Application
6+
metadata:
7+
name: {{ printf "%s-%s" $.Release.Name $appName }}
8+
{{/*
9+
{{- with $app.wave }}
10+
annotations:
11+
argocd.argoproj.io/sync-wave: {{ quote . }}
12+
{{- end }}
13+
*/}}
14+
spec:
15+
destination:
16+
namespace: openstack
17+
server: https://kubernetes.default.svc
18+
project: understack
19+
sources:
20+
- repoURL: {{ $.Values.site.openstack.repoUrl }}
21+
targetRevision: {{ $app.chartVersion }}
22+
chart: {{ $appName }}
23+
helm:
24+
ignoreMissingValueFiles: true
25+
releaseName: {{ $appName }}
26+
valueFiles:
27+
- $understack/components/images-openstack.yaml
28+
- $understack/components/{{ $appName }}/values.yaml
29+
- $deploy/{{ $.Release.Name }}/manifests/secret-openstack.yaml
30+
- $deploy/{{ $.Release.Name }}/manifests/images-openstack.yaml
31+
- $deploy/{{ $.Release.Name }}/helm-configs/{{ $appName }}.yaml
32+
- path: components/{{ $appName }}/
33+
ref: understack
34+
repoURL: {{ include "understack.understack_url" $ }}
35+
targetRevision: {{ include "understack.understack_ref" $ }}
36+
- path: {{ $.Release.Name }}/manifests/{{ $appName }}
37+
ref: deploy
38+
repoURL: {{ include "understack.deploy_url" $ }}
39+
targetRevision: {{ include "understack.deploy_ref" $ }}
40+
syncPolicy:
41+
automated:
42+
prune: true
43+
selfHeal: true
44+
syncOptions:
45+
- ServerSideApply=false
46+
- RespectIgnoreDifferences=true
47+
- ApplyOutOfSyncOnly=true
48+
{{- end }}
49+
{{- end }}

0 commit comments

Comments
 (0)