mirror of
https://github.com/amkartashov/gf-k8s.git
synced 2026-01-11 01:49:44 +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
|
# apply manifests for crucial applications
|
||||||
for app_file in \
|
for app_file in \
|
||||||
${state_path}/system/argo-cd.yaml \
|
${state_path}/system/argocd.yaml \
|
||||||
; do
|
; do
|
||||||
namespace=$(yq -e '.spec.destination.namespace' ${app_file})
|
namespace=$(yq -e '.spec.destination.namespace' ${app_file})
|
||||||
|
|
||||||
${kubectl_cmd} create ns ${namespace} || true
|
${kubectl_cmd} create ns ${namespace} || true
|
||||||
helm_render ${app_file} | ${kubectl_cmd} -n ${namespace} apply -f -
|
helm_render ${app_file} | ${kubectl_cmd} -n ${namespace} apply -f -
|
||||||
done
|
done
|
||||||
|
|
@ -60,6 +61,17 @@ function help() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function helm_render() {
|
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 app_file=$1
|
||||||
local repo=$(yq -e '.spec.source.repoURL' ${app_file})
|
local repo=$(yq -e '.spec.source.repoURL' ${app_file})
|
||||||
local chart=$(yq -e '.spec.source.chart' ${app_file})
|
local chart=$(yq -e '.spec.source.chart' ${app_file})
|
||||||
|
|
@ -75,4 +87,19 @@ function helm_render() {
|
||||||
--namespace ${namespace} --values ${values_file}
|
--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 "${@}"
|
main "${@}"
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,13 @@ spec:
|
||||||
- CreateNamespace=true
|
- CreateNamespace=true
|
||||||
# https://argo-cd.readthedocs.io/en/stable/user-guide/multiple_sources/#helm-value-files-from-external-git-repository
|
# https://argo-cd.readthedocs.io/en/stable/user-guide/multiple_sources/#helm-value-files-from-external-git-repository
|
||||||
sources:
|
sources:
|
||||||
- repoURL: git@github.com:amkartashov/gf-k8s.git
|
|
||||||
targetRevision: main
|
|
||||||
ref: values
|
|
||||||
- repoURL: https://argoproj.github.io/argo-helm
|
- repoURL: https://argoproj.github.io/argo-helm
|
||||||
chart: argo-cd
|
chart: argo-cd
|
||||||
targetRevision: 5.45.0
|
targetRevision: 5.45.0
|
||||||
helm:
|
helm:
|
||||||
|
releaseName: argocd
|
||||||
valueFiles:
|
valueFiles:
|
||||||
- $values/state/gullfaxi/system/argocd-values.yaml
|
- $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