argo1/deploy.sh
2023-04-22 13:01:44 -05:00

21 lines
747 B
Bash

#!/bin/bash
cd "$(dirname "$0")"
TARGETNS="$(yq -r .spec.destination.namespace application.yaml)"
ORIGNS="$(kubectl config view --minify -o jsonpath='{..namespace}')"
(
set -e
jq -n --args '{"apiVersion":"v1","kind":"Namespace","metadata":{"name": $ARGS.positional[0]}}' "$TARGETNS" | kubectl apply -f -
[ x"$TARGETNS" != x"$ORIGNS" ] && kubectl config set-context --current --namespace argocd
helm upgrade -i --create-namespace -n argocd argocd argo/argo-cd #-f values.yaml
kubectl wait -n argocd deploy/argocd-server --for=condition=available
kubectl apply -f application.yaml
#
argocd --core app sync argocd
)
[ x"$TARGETNS" != x"$ORIGNS" ] && kubectl config set-context --current --namespace "$ORIGNS"