mirror of
https://github.com/zhufuyi/sponge.git
synced 2025-10-28 03:13:09 +08:00
32 lines
675 B
Bash
32 lines
675 B
Bash
#!/bin/bash
|
|
|
|
SERVER_NAME="serverNameExample"
|
|
DEPLOY_FILE="deployments/kubernetes/${SERVER_NAME}-deployment.yml"
|
|
|
|
function checkResult() {
|
|
result=$1
|
|
if [ ${result} -ne 0 ]; then
|
|
exit ${result}
|
|
fi
|
|
}
|
|
|
|
# Determining whether a file exists
|
|
if [ ! -f "${DEPLOY_FILE}" ];then
|
|
echo "Deployment file file ${DEPLOY_FILE} does not exist"
|
|
checkResult 1
|
|
fi
|
|
|
|
# Check if you are authorised to operate k8s
|
|
echo "kubectl version"
|
|
kubectl version
|
|
checkResult $?
|
|
|
|
echo "kubectl delete -f ${DEPLOY_FILE} --ignore-not-found"
|
|
kubectl delete -f ${DEPLOY_FILE} --ignore-not-found
|
|
checkResult $?
|
|
|
|
sleep 1
|
|
|
|
echo "kubectl apply -f ${DEPLOY_FILE}"
|
|
kubectl apply -f ${DEPLOY_FILE}
|