diff --git a/README.md b/README.md index 5e2f8310d2ca19ab1a1653784727ecfcd3e41f1b..2ed6623cb8b6d28689c1146f38560f5c5aacab6f 100644 --- a/README.md +++ b/README.md @@ -274,18 +274,28 @@ sh deploy.sh middleware -K <部署节点管理IP> -P -p -S <离线安装包所在目录> +sh deploy.sh gopher -K -p -S <离线安装包所在目录> [--docker] ``` 选项详细说明: @@ -295,6 +305,7 @@ sh deploy.sh gopher -K -p -S < | -K\|--kafka | 指定gala-gopher上报采集数据的目标kakfa服务器地址,当不配置该选项时,kafka服务器地址使用localhost | 否 | | -p\|--pyroscope | 指定gala-gopher开启火焰图功能后火焰图上传到的pyroscope服务器地址(用于对接前端界面显示),当不配置该选项时,pyroscope服务器地址使用localhost | 否 | | -S\|--srcdir | 离线部署时使用该选项来指定gala-gopher以及其依赖包所在的目录 | 离线部署时必配 | +| --docker | 指定以 docker 方式部署 gala-gopher | 否 | #### 管理节点:部署gala-ops diff --git a/deploy/deploy.sh b/deploy/deploy.sh index b05bf7c91ab6f45d92195d22b7640b5194f6d54b..a0fc39e7c471e13b28f9f4afa3c37b547700741f 100755 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -470,26 +470,35 @@ EOF function prepare_docker_gopher_conf() { mkdir -p /opt/gala/gopher_conf/extend_probes - wget https://gitee.com/openeuler/gala-gopher/raw/master/config/gala-gopher.conf \ - -O /opt/gala/gopher_conf/gala-gopher.conf --no-check-certificate - [ $? -ne 0 ] && echo_err_exit "Failed to download gala-gopher.conf" - - wget https://gitee.com/openeuler/gala-gopher/raw/master/config/gala-gopher-app.conf \ - -O /opt/gala/gopher_conf/gala-gopher-app.conf --no-check-certificate - [ $? -ne 0 ] && echo_err_exit "Failed to download gala-gopher-app.conf" - - wget https://gitee.com/openeuler/gala-gopher/raw/master/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe.conf \ - -O /opt/gala/gopher_conf/extend_probes/stackprobe.conf --no-check-certificate - [ $? -ne 0 ] && echo_err_exit "Failed to download gala-gopher stackprobe.conf" + if [ "$DEPLOY_TYPE" != "local" ] ; then + wget https://gitee.com/openeuler/gala-gopher/raw/master/config/gala-gopher.conf \ + -O /opt/gala/gopher_conf/gala-gopher.conf --no-check-certificate + [ $? -ne 0 ] && echo_err_exit "Failed to download gala-gopher.conf" + + wget https://gitee.com/openeuler/gala-gopher/raw/master/config/gala-gopher-app.conf \ + -O /opt/gala/gopher_conf/gala-gopher-app.conf --no-check-certificate + [ $? -ne 0 ] && echo_err_exit "Failed to download gala-gopher-app.conf" + + wget https://gitee.com/openeuler/gala-gopher/raw/master/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe.conf \ + -O /opt/gala/gopher_conf/extend_probes/stackprobe.conf --no-check-certificate + [ $? -ne 0 ] && echo_err_exit "Failed to download gala-gopher stackprobe.conf" + else + mv $LOCAL_DEPLOY_SRCDIR/gala-gopher.conf /opt/gala/gopher_conf/gala-gopher.conf + mv $LOCAL_DEPLOY_SRCDIR/gala-gopher-app.conf /opt/gala/gopher_conf/gala-gopher-app.conf + mv $LOCAL_DEPLOY_SRCDIR/stackprobe.conf /opt/gala/gopher_conf/extend_probes/stackprobe.conf + fi } function deploy_gopher_docker() { container_name="aops-gala-gopher" - - [ "$DEPLOY_TYPE" == "local" ] && echo_err_exit "gala-gopher deployment in docker mode is only supported online" - echo -e "[1] Pulling/Loading gala-gopher docker image for ${GOPHER_DOCKER_TAG}" gopher_tag="gala-gopher-$(uname -m):${GOPHER_DOCKER_TAG}" - docker_pull_image "${gopher_tag}" + + if [ "$DEPLOY_TYPE" == "local" ] ; then + docker_load_image_file "$LOCAL_DEPLOY_SRCDIR/gala-gopher-$(uname -m):${GOPHER_DOCKER_TAG}.tar" + else + echo -e "[1] Pulling/Loading gala-gopher docker image for ${GOPHER_DOCKER_TAG}" + docker_pull_image "${gopher_tag}" + fi echo -e "\n[2] Configuring gala-gopher" prepare_docker_gopher_conf diff --git a/deploy/download_offline_res.sh b/deploy/download_offline_res.sh index 5d980f9bd552bd79ee712043ce1460c9447dfb04..a3cd295bff26512dfc0168c232b7d7916f2f6bc0 100755 --- a/deploy/download_offline_res.sh +++ b/deploy/download_offline_res.sh @@ -17,6 +17,7 @@ REMOTE_REPO_PREFIX="" REMOTE_ALIYUN_REPO_PREFIX="http://mirrors.aliyun.com/openeuler" EPOL_REPO="" EPOL_UPDATE_REPO="" +GOPHER_DOWNLOAD_MODE="rpm" function echo_err_exit() { echo -e "\e[31m $@ \e[0m" @@ -281,6 +282,46 @@ download_gopher() { createrepo ${DOWNLOAD_DIR} } +# get gopher image tag by os_version +get_gopher_image_tag() { + if [ "x$OS_TYPE" == "xopenEuler" ] ; then + if [ "$OS_VERSION" == "openEuler-22.03-LTS-SP1" ] ; then + echo "22.03-lts-sp1" + elif [ "$OS_VERSION" == "openEuler-22.03-LTS" ] ; then + echo "22.03-lts" + else #openEuler-20.03-LTS-SP1 + echo "20.03-lts-sp1" + fi + else #kylin + echo "kylin-v10" + fi +} + +download_gopher_image() { + tag=$(get_gopher_image_tag) + echo_info "- Download gala-gopher docker image" + if [ ! -f ${DOWNLOAD_DIR}/gala-gopher-${OS_ARCH}-${tag}.tar ] ; then + echo " [1] Executing \"docker pull ${DOCKER_HUB_TAG_PREFIX}/gala-gopher-${OS_ARCH}:${tag}\"" + docker_pull_image "gala-gopher-${OS_ARCH}:${tag}" + + echo " [2] Executing \"docker save -o ${DOWNLOAD_DIR}/gala-gopher-${OS_ARCH}:${tag}.tar ${DOCKER_HUB_TAG_PREFIX}/gala-gopher-${OS_ARCH}:${tag}\"" + docker save -o ${DOWNLOAD_DIR}/gala-gopher-${OS_ARCH}:${tag}.tar ${DOCKER_HUB_TAG_PREFIX}/gala-gopher-${OS_ARCH}:${tag} + + echo " [3] download gala-gopher conf file" + wget https://gitee.com/openeuler/gala-gopher/raw/master/config/gala-gopher.conf \ + -O ${DOWNLOAD_DIR}/gala-gopher.conf --no-check-certificate + [ $? -ne 0 ] && echo_err_exit "Failed to download gala-gopher.conf" + + wget https://gitee.com/openeuler/gala-gopher/raw/master/config/gala-gopher-app.conf \ + -O ${DOWNLOAD_DIR}/gala-gopher-app.conf --no-check-certificate + [ $? -ne 0 ] && echo_err_exit "Failed to download gala-gopher-app.conf" + + wget https://gitee.com/openeuler/gala-gopher/raw/master/src/probes/extends/ebpf.probe/src/stackprobe/conf/stackprobe.conf \ + -O ${DOWNLOAD_DIR}/stackprobe.conf --no-check-certificate + [ $? -ne 0 ] && echo_err_exit "Failed to download gala-gopher stackprobe.conf" + fi +} + # use OS_TYPE OS_VERSION config yum repo function config_remote_repo() { if [ "x$OS_TYPE" == "xopenEuler" ] ; then @@ -312,24 +353,46 @@ function detect_os() { config_remote_repo } -function parse_arg_gopher() { - if [ $# -ne 3 ];then - echo_err_exit "download gopher param err" - fi +function config_os_version_type() { + os_version="$1" + os_arch="$2" - if [ $2 == "kylin" ];then + if [ $os_version == "kylin" ];then OS_TYPE="kylin" else OS_TYPE="openEuler" fi - OS_VERSION=$2 + OS_VERSION=$os_version - if [ $3 == "aarch64" ] || [ $3 == "x86_64" ]; then - OS_ARCH=$3 + if [ $os_arch == "aarch64" ] || [ $os_arch == "x86_64" ]; then + OS_ARCH=$os_arch else - echo_err_exit "no support \"$3\" arch" + echo_err_exit "no support \"$os_arch\" arch" + fi +} + +# download gopher have four param format +# 1. download gopher +# 2. download gopher docker +# 3. download gopher version arch +# 4. download gopher version arch docker +function parse_arg_gopher() { + if [ $# -gt 4 ];then + echo_err_exit "download gopher param err" fi + if [ $2 != "docker" ] ;then + if [ $# -eq 3 ] ; then + config_os_version_type $2 $3 + elif [ $# -eq 4 ] && [ $4 == "docker" ] ; then + config_os_version_type $2 $3 + GOPHER_DOWNLOAD_MODE="docker" + else + echo_err_exit "download gopher param err" + fi + else + GOPHER_DOWNLOAD_MODE="docker" + fi config_remote_repo } @@ -401,5 +464,9 @@ if [[ "${DOWNLOAD_COMPONENT_LIST}" =~ "ops" ]] ; then fi if [[ "${DOWNLOAD_COMPONENT_LIST}" =~ "gopher" ]] ; then - download_gopher + if [ $GOPHER_DOWNLOAD_MODE == "rpm" ] ; then + download_gopher + else + download_gopher_image + fi fi