fix(linkis-dist): fix the install-linkis-to-kubernetes.sh error (#3658)
* fix(linkis-dist): fix the install-linkis-to-kubernetes.sh exception
* fix(linkis-dist): fixed an error getting pods
* fix(linkis-dist): add reset command
* fix(linkis-dist): fix error
diff --git a/linkis-dist/bin/install-linkis-to-kubernetes.sh b/linkis-dist/bin/install-linkis-to-kubernetes.sh
index 6a7e7d5..dbc54de 100644
--- a/linkis-dist/bin/install-linkis-to-kubernetes.sh
+++ b/linkis-dist/bin/install-linkis-to-kubernetes.sh
@@ -16,18 +16,32 @@
#variable
WORK_DIR=`cd $(dirname $0); pwd -P`
+ROOT_DIR=${WORK_DIR}/..
MIRRORS="ghcr.io"
TAG="latest"
COMMAND="pull-install"
DEBUG=false
WITH_LDH=false
+
+debug(){
+ if [ $DEBUG = true ]; then
+ echo $(date "+%Y-%m-%d %H:%M:%S") "debug: "$1
+ fi
+}
+
+info(){
+ echo $(date "+%Y-%m-%d %H:%M:%S") "info: "$1
+}
+
+
#help info
help() {
echo "Command Describe"
echo "pull-install pull and install linkis images"
echo "install pull linkis images"
echo "pull pull linkis images"
+ echo "reset delete the test-helm cluster of kind"
echo "help print help info"
echo ""
echo "Params Describe"
@@ -37,53 +51,56 @@
echo "-t tag name "
echo ""
echo "example:"
- echo "./install-kubernetes.sh pull pull image with ghcr.io"
- echo "./install-kubernetes.sh -t latest pull image with tag"
- echo "./install-kubernetes.sh pull -m ghcr.dockerproxy.com pull image with ghcr.dockerproxy.com"
- echo "./install-kubernetes.sh install install linkis to kind and kubernetes"
- echo "./install-kubernetes.sh pull-install -m ghcr.dockerproxy.com pull image and install linkis to kind and kubernetes"
+ echo "./install-linkis-to-kubernetes.sh pull pull image with ghcr.io"
+ echo "./install-linkis-to-kubernetes.sh -tlatest pull image with tag"
+ echo "./install-linkis-to-kubernetes.sh pull -mghcr.dockerproxy.com pull image with ghcr.dockerproxy.com or ghcr.nju.edu.cn"
+ echo "./install-linkis-to-kubernetes.sh install -l -mghcr.dockerproxy.com install linkis to kind and kubernetes with ldh"
+ echo "./install-linkis-to-kubernetes.sh pull-install -mghcr.dockerproxy.com pull image and install linkis to kind and kubernetes"
}
#pull the container image of the linkis
pull(){
- docker pull $MIRRORS/apache/incubator-linkis/linkis-ldh:${TAG}
- docker pull $MIRRORS/apache/incubator-linkis/linkis:${TAG}
- docker pull $MIRRORS/apache/incubator-linkis/linkis-web:${TAG}
+ debug ${MIRRORS}/apache/incubator-linkis/linkis-ldh:${TAG}
+ docker pull ${MIRRORS}/apache/incubator-linkis/linkis-ldh:${TAG}
+ debug ${MIRRORS}/apache/incubator-linkis/linkis:${TAG}
+ docker pull ${MIRRORS}/apache/incubator-linkis/linkis:${TAG}
+ debug ${MIRRORS}/apache/incubator-linkis/linkis-web:${TAG}
+ docker pull ${MIRRORS}/apache/incubator-linkis/linkis-web:${TAG}
}
#change the label
tag(){
- docker tag $MIRRORS/apache/incubator-linkis/linkis:${TAG} linkis:dev
- docker tag $MIRRORS/apache/incubator-linkis/linkis-web:${TAG} linkis-web:dev
- docker tag $MIRRORS/apache/incubator-linkis/linkis-ldh:${TAG} linkis-ldh:dev
+ docker tag ${MIRRORS}/apache/incubator-linkis/linkis:${TAG} linkis:dev
+ docker tag ${MIRRORS}/apache/incubator-linkis/linkis-web:${TAG} linkis-web:dev
+ docker tag ${MIRRORS}/apache/incubator-linkis/linkis-ldh:${TAG} linkis-ldh:dev
}
#create an image to carry mysql
make_linikis_image_with_mysql_jdbc(){
- ${WORK_DIR}/docker/scripts/make-linikis-image-with-mysql-jdbc.sh
+ ${ROOT_DIR}/docker/scripts/make-linikis-image-with-mysql-jdbc.sh
docker tag linkis:with-jdbc linkis:dev
}
#creating a kind cluster
create_kind_cluster(){
- ${WORK_DIR}/helm/scripts/create-kind-cluster.sh
+ ${ROOT_DIR}/helm/scripts/create-kind-cluster.sh
}
#mysql installation
install_mysql(){
- ${WORK_DIR}/helm/scripts/install-mysql.sh
+ ${ROOT_DIR}/helm/scripts/install-mysql.sh
}
#ldh installation
install_ldh(){
- ${WORK_DIR}/helm/scripts/install-ldh.sh
+ ${ROOT_DIR}/helm/scripts/install-ldh.sh
}
#linkis installation
install_linkis(){
if [ $WITH_LDH = true ];then
- ${WORK_DIR}/helm/scripts/install-charts-with-ldh.sh
+ ${ROOT_DIR}/helm/scripts/install-charts-with-ldh.sh
else
- ${WORK_DIR}/helm/scripts/install-linkis.sh
+ ${ROOT_DIR}/helm/scripts/install-linkis.sh
fi
}
#display pods
display_pods(){
- kubectl get pods -a
+ kubectl get pods -A
}
install(){
@@ -96,14 +113,8 @@
display_pods
}
-debug(){
- if [ $DEBUG = true ]; then
- echo $(date "+%Y-%m-%d %H:%M:%S") "debug: "$1
- fi
-}
-
-info(){
- echo $(date "+%Y-%m-%d %H:%M:%S") "info: "$1
+reset(){
+ kind delete clusters test-helm
}
@@ -124,7 +135,7 @@
}
check_kubectl(){
- kubectl version >> /dev/null 2>&1
+ kubectl >> /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "kubectl is not installed!"
exit 1
@@ -140,6 +151,8 @@
}
+debug $WORK_DIR
+
#entrance to the program
main(){
@@ -151,8 +164,7 @@
#argument parsing
long_opts="debug,mirrors:"
- getopt_cmd=$(getopt -o dmlt: \
- -n $(basename $0) -- "$@") || \
+ getopt_cmd=$(getopt -o dm:lt: -n $(basename $0) -- "$@") || \
{ echo -e "\nERROR: Getopt failed. Extra args\n"; exit 1;}
eval set -- "$getopt_cmd"
@@ -191,6 +203,10 @@
pull
fi
+ if [ $COMMAND = "reset" ]; then
+ reset
+ fi
+
if [ $COMMAND = "help" ]; then
help
fi