mirror of
https://github.com/amkartashov/gf-k8s.git
synced 2026-01-10 17:39:43 +00:00
bootstrap: fix rendering helm from app with multiple sources
This commit is contained in:
parent
a592e648fd
commit
f0da6fb748
2 changed files with 32 additions and 4 deletions
|
|
@ -25,9 +25,10 @@ function main() {
|
|||
|
||||
# apply manifests for crucial applications
|
||||
for app_file in \
|
||||
${state_path}/system/argo-cd.yaml \
|
||||
${state_path}/system/argocd.yaml \
|
||||
; do
|
||||
namespace=$(yq -e '.spec.destination.namespace' ${app_file})
|
||||
|
||||
${kubectl_cmd} create ns ${namespace} || true
|
||||
helm_render ${app_file} | ${kubectl_cmd} -n ${namespace} apply -f -
|
||||
done
|
||||
|
|
@ -60,6 +61,17 @@ function help() {
|
|||
}
|
||||
|
||||
function helm_render() {
|
||||
local app_file=$1
|
||||
local values_file=${app_file%.yaml}-values.yaml
|
||||
|
||||
if [ -f ${values_file} ]; then
|
||||
helm_render_from_sources "$@"
|
||||
else
|
||||
helm_render_from_source "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
function helm_render_from_source() {
|
||||
local app_file=$1
|
||||
local repo=$(yq -e '.spec.source.repoURL' ${app_file})
|
||||
local chart=$(yq -e '.spec.source.chart' ${app_file})
|
||||
|
|
@ -75,4 +87,19 @@ function helm_render() {
|
|||
--namespace ${namespace} --values ${values_file}
|
||||
}
|
||||
|
||||
function helm_render_from_sources() {
|
||||
local app_file=$1
|
||||
local repo=$(yq -e '.spec.sources[0].repoURL' ${app_file})
|
||||
local chart=$(yq -e '.spec.sources[0].chart' ${app_file})
|
||||
local chart_version=$(yq -e '.spec.sources[0].targetRevision' ${app_file})
|
||||
local release=$(yq -e '.spec.sources[0].helm.releaseName' ${app_file})
|
||||
local namespace=$(yq -e '.spec.destination.namespace' ${app_file})
|
||||
local values_file=${app_file%.yaml}-values.yaml
|
||||
|
||||
helm template ${release} ${chart} \
|
||||
--version ${chart_version} --repo ${repo} \
|
||||
--include-crds \
|
||||
--namespace ${namespace} --values ${values_file}
|
||||
}
|
||||
|
||||
main "${@}"
|
||||
|
|
|
|||
|
|
@ -16,12 +16,13 @@ spec:
|
|||
- CreateNamespace=true
|
||||
# https://argo-cd.readthedocs.io/en/stable/user-guide/multiple_sources/#helm-value-files-from-external-git-repository
|
||||
sources:
|
||||
- repoURL: git@github.com:amkartashov/gf-k8s.git
|
||||
targetRevision: main
|
||||
ref: values
|
||||
- repoURL: https://argoproj.github.io/argo-helm
|
||||
chart: argo-cd
|
||||
targetRevision: 5.45.0
|
||||
helm:
|
||||
releaseName: argocd
|
||||
valueFiles:
|
||||
- $values/state/gullfaxi/system/argocd-values.yaml
|
||||
- repoURL: git@github.com:amkartashov/gf-k8s.git
|
||||
targetRevision: main
|
||||
ref: values
|
||||
|
|
|
|||
Loading…
Reference in a new issue