wip: misc helmfile improvements

This commit is contained in:
2025-05-14 16:01:55 +02:00
parent 87a10aab1f
commit 55c6bb5923
7 changed files with 41 additions and 29 deletions
+3 -8
View File
@@ -1,20 +1,15 @@
#!/bin/sh
export HOME=/plugin
export HELM_CACHE_HOME=/tmp/helm/cache
export HELM_CONFIG_HOME=/tmp/helm/config
export HELMFILE_CACHE_HOME=/tmp/helmfile/cache
export HELMFILE_TEMPDIR=/tmp/helmfile/tmp
env > /tmp/$ARGOCD_APP_NAME.env
[[ -v ARGOCD_ENV_HELMFILE_ENVIRONMENT ]] && export HELMFILE_ENVIRONMENT=$ARGOCD_ENV_HELMFILE_ENVIRONMENT
if [[ -v ENVIRONMENT ]]; then
ARGS="-e $ENVIRONMENT"
elif [[ -v ARGOCD_ENV_ENVIRONMENT ]]; then
ARGS="-e $ARGOCD_ENV_ENVIRONMENT "
else
ARGS=""
fi
env > /tmp/$ARGOCD_APP_NAME.env
helmfile -n "$ARGOCD_APP_NAMESPACE" $ARGS template --include-crds -q
+8 -7
View File
@@ -3,8 +3,8 @@
cmd=$1
chart=$2
env=$3
dir=_helmify
manifests=${4:-manifests}
outdir=${5:-_manifests}
build() {
if [ ! -d "manifests" ]; then
@@ -12,11 +12,11 @@ build() {
exit 0
fi
mkdir -p $dir/templates
mkdir -p $outdir/templates
echo "generating $dir/Chart.yaml" 1>&2
echo "generating $outdir/Chart.yaml" 1>&2
cat <<EOF > $dir/Chart.yaml
cat <<EOF > $outdir/Chart.yaml
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for Kubernetes
@@ -24,11 +24,12 @@ name: $chart
version: 0.1.0
EOF
cp -r manifests/* $dir/templates
cp -r $manifests/* $outdir/templates
}
clean() {
rm -rf $dir
echo "cleaning $outdir" 1>&2
rm -rf $outdir
}
case "$cmd" in
+7 -2
View File
@@ -1,8 +1,13 @@
#!/usr/bin/env bash
if [ -f base/kustomization.yaml ]; then
[ $# != 1 ] && exit 1
[ ! -f base/kustomization.yaml ] && exit 1
env=$1
if [ -f $env/kustomization.yaml ]; then
cat >base/_manifest.yaml
kubectl kustomize base
kubectl kustomize $env
else
cat
fi
+19 -12
View File
@@ -1,16 +1,20 @@
repositories:
- name: argo
url: https://argoproj.github.io/argo-helm
environments:
default:
values:
- ../../apps/values.yaml
- ../../values/sys/values-{{ requiredEnv "CLUSTER" }}.yaml
prod:
values:
- ../../apps/values.yaml
- ../../../values/sys/values-{{ requiredEnv "CLUSTER" }}.yaml
staging:
values:
- ../../apps/values.yaml
- ../../values/sys/values-{{ requiredEnv "CLUSTER" }}.yaml
---
repositories:
- name: argo
url: https://argoproj.github.io/argo-helm
releases:
- name: argocd
@@ -18,18 +22,21 @@ releases:
chart: argo/argo-cd
values:
- values.yaml.gotmpl
- values-{{ .Environment.Name }}.yaml.gotmpl
- values-{{ requiredEnv "CLUSTER" }}.yaml.gotmpl
postRenderer: ../../bin/kustomizer
- name: argocd-manifests
postRendererArgs:
- {{ .Environment.Name }}
missingFileHandler: Info
- name: manifests
namespace: argocd
chart: _helmify
chart: _manifests
hooks:
- events:
- prepare
- cleanup
- events: [ prepare, cleanup ]
showlogs: true
command: ../../bin/helmify
args:
- "{{`{{if eq .Event.Name \"prepare\"}}build{{else}}clean{{end}}`}}"
- "{{`{{.Release.Chart}}`}}"
- "{{`{{.Environment.Name}}`}}"
- '{{`{{ if eq .Event.Name "prepare" }}build{{ else }}clean{{ end }}`}}'
- '{{`{{ .Release.Chart }}`}}'
- '{{`{{ .Environment.Name }}`}}'
@@ -0,0 +1,4 @@
configs:
cm:
url: "https://foobar.oceanbox.io"