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"
|
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 actions is not set
|
||||||
if [[ -z "$action" ]]; then
|
if [[ -z "$action" ]]; then
|
||||||
action="print"
|
action="print"
|
||||||
@ -54,33 +73,25 @@ echo "# action: $action"
|
|||||||
if [[ -n "$KUBECONFIG_DATA" ]]; then
|
if [[ -n "$KUBECONFIG_DATA" ]]; then
|
||||||
mkdir -p /root/.kube
|
mkdir -p /root/.kube
|
||||||
echo "$KUBECONFIG_DATA" > /root/.kube/config
|
echo "$KUBECONFIG_DATA" > /root/.kube/config
|
||||||
echo "# .kube/config is set"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if the action environment variable is set to 'print'
|
# Check if the action environment variable is set to 'print'
|
||||||
if [[ "$action" == "print" ]]; then
|
if [[ "$action" == "print" ]]; then
|
||||||
createHelmYaml
|
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
|
elif [[ "$action" == "deploy" ]]; then
|
||||||
echo "# no .kube/config set"
|
checkKubeConfig
|
||||||
kubectl version --client=true
|
createHelmYaml | kubectl apply -f -
|
||||||
|
elif [[ "$action" == "helm-deploy" ]]; then
|
||||||
|
checkKubeConfig
|
||||||
|
createHelmYaml | kubectl apply -f -
|
||||||
elif [[ "$action" == "helm-print" ]]; then
|
elif [[ "$action" == "helm-print" ]]; then
|
||||||
helm dependency build .
|
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)"
|
||||||
elif [[ "$action" == "helm-deploy" ]]; then
|
elif [[ "$action" == "helm-deploy" ]]; then
|
||||||
|
checkKubeConfig
|
||||||
helm dependency build .
|
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)"
|
||||||
helm template -g . --set-json="subchartData=$(yq '.dependencies[0]' Chart.yaml -ojson | jq -rc)" | kubectl apply -f -
|
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
|
else
|
||||||
echo "# invalid action"
|
echo "# invalid action"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user