Update createHelmYaml.sh
All checks were successful
Build docker container / Build image (push) Successful in 13s
All checks were successful
Build docker container / Build image (push) Successful in 13s
This commit is contained in:
parent
22071927a0
commit
7f1f828d3f
@ -44,6 +44,25 @@ createHelmYaml() {
|
||||
echo "$helm_chart_yaml"
|
||||
}
|
||||
|
||||
function checkKubeConfig(){
|
||||
echo "# Check if kubeconfig exists..."
|
||||
if [[ -n "$KUBECONFIG_DATA" ]]; then
|
||||
echo "Check if kubeconfig is valid..."
|
||||
kubectl version
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "# Failed to connect to Kubernetes..."
|
||||
bash createServiceAccount.sh
|
||||
false
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "# No kubeconfig available..."
|
||||
bash createServiceAccount.sh
|
||||
false
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# if actions is not set
|
||||
if [[ -z "$action" ]]; then
|
||||
action="print"
|
||||
@ -54,33 +73,25 @@ echo "# action: $action"
|
||||
if [[ -n "$KUBECONFIG_DATA" ]]; then
|
||||
mkdir -p /root/.kube
|
||||
echo "$KUBECONFIG_DATA" > /root/.kube/config
|
||||
echo "# .kube/config is set"
|
||||
fi
|
||||
|
||||
# Check if the action environment variable is set to 'print'
|
||||
if [[ "$action" == "print" ]]; then
|
||||
createHelmYaml
|
||||
elif [[ "$action" == "deploy" ]] && [[ -n "$KUBECONFIG_DATA" ]]; then
|
||||
kubectl version
|
||||
createHelmYaml | kubectl apply -f -
|
||||
elif [[ "$action" == "deploy-dry-run" ]] && [[ -n "$KUBECONFIG_DATA" ]]; then
|
||||
kubectl version
|
||||
createHelmYaml | kubectl apply --dry-run=client -o yaml -f -
|
||||
elif [[ "$action" == "deploy" ]]; then
|
||||
echo "# no .kube/config set"
|
||||
kubectl version --client=true
|
||||
checkKubeConfig
|
||||
createHelmYaml | kubectl apply -f -
|
||||
elif [[ "$action" == "helm-deploy" ]]; then
|
||||
checkKubeConfig
|
||||
createHelmYaml | kubectl apply -f -
|
||||
elif [[ "$action" == "helm-print" ]]; then
|
||||
helm dependency build .
|
||||
helm template -g . --set-json="subchartData=$(yq '.dependencies[0]' Chart.yaml -ojson | jq -rc)"
|
||||
elif [[ "$action" == "helm-deploy" ]]; then
|
||||
checkKubeConfig
|
||||
helm dependency build .
|
||||
helm template -g . --set-json="subchartData=$(yq '.dependencies[0]' Chart.yaml -ojson | jq -rc)"
|
||||
helm template -g . --set-json="subchartData=$(yq '.dependencies[0]' Chart.yaml -ojson | jq -rc)" | kubectl apply -f -
|
||||
elif [[ "$action" == "debug" ]]; then
|
||||
echo "# dumping files"
|
||||
find . -type f -print -exec cat {} \;
|
||||
echo "# Computed file"
|
||||
createHelmYaml
|
||||
else
|
||||
echo "# invalid action"
|
||||
fi
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user