From 7ccd01f6f547d5f60417a3418b4166563404059b Mon Sep 17 00:00:00 2001 From: Ryan Faircloth <35384120+rfaircloth-splunk@users.noreply.github.com> Date: Thu, 29 Apr 2021 08:54:07 -0400 Subject: [PATCH] feat(install): Single command install with curl (#64) Co-authored-by: Addon Factory template --- deploy/install.bash | 25 ++++++++++++ deploy/{deploy.sh => install_full.bash} | 37 ++++++++++++------ deploy/sck/deploy_sck.sh | 52 ------------------------- docs/source/gettingstarted.rst | 16 ++------ 4 files changed, 54 insertions(+), 76 deletions(-) create mode 100755 deploy/install.bash rename deploy/{deploy.sh => install_full.bash} (84%) delete mode 100755 deploy/sck/deploy_sck.sh diff --git a/deploy/install.bash b/deploy/install.bash new file mode 100755 index 000000000..2c82cdd37 --- /dev/null +++ b/deploy/install.bash @@ -0,0 +1,25 @@ +#!/bin/bash + +BRANCH=${BRANCH:=install-from-url} +echo using $BRANCH +URL=https://raw.githubusercontent.com/splunk/splunk-connect-for-snmp/${BRANCH}/deploy/install_full.bash + +function download { + scratch="$(mktemp -d -t tmp.XXXXXXXXXX)" || exit + script_file="$scratch/install_full.bash" + + echo "Downloading SC4SNMP Install Script: $URL" + curl -s -# "$URL" > "$script_file" || exit + chmod 775 "$script_file" + + echo "Running install script from: $script_file" + bash "$script_file" "$@" +} + +if { command true < /dev/tty; } > /dev/null 2>&1; then + # Grab prompt input from the tty. + download "$@" < /dev/tty +else + download "$@" +fi + diff --git a/deploy/deploy.sh b/deploy/install_full.bash similarity index 84% rename from deploy/deploy.sh rename to deploy/install_full.bash index 0031665fa..05815ce3a 100755 --- a/deploy/deploy.sh +++ b/deploy/install_full.bash @@ -65,13 +65,17 @@ install_dependencies() { fi } + +###MAIN + + if [ "$USER" != "root" ]; then echo "must be root try sudo" exit fi - +BRANCH=${BRANCH:-main} K8S=${K8S:-mk8s} if [ "$K8S" = "mk8s" ]; then @@ -164,7 +168,7 @@ if [ ! -n "$MODE" ]; then echo "MODE Both" ;; *) - echo "MODE invalid" + echo "MODE invalid =$MODE" exit 1 ;; esac @@ -192,7 +196,7 @@ then while [ ! -n "$PORT" ] do - read -p 'PORT of Splunk HEC Inputs 443 (default): ' PROTO + read -p 'PORT of Splunk HEC Inputs 443 (default): ' PORT PORT=${PORT:-443} done URI_PORT=":$PORT" @@ -278,7 +282,9 @@ then $HCMD repo add splunk https://splunk.github.io/splunk-connect-for-kubernetes/ >/dev/null $HCMD uninstall -n sck sck - cat deploy/sck/sck_145.yaml \ + + if [ -f "deploy/sck/sck_145.yaml" ]; then sck_values="cat deploy/sck/sck_145.yaml"; else sck_values="curl -s https://raw.githubusercontent.com/splunk/splunk-connect-for-snmp/$BRANCH/deploy/sck/sck_145.yaml"; fi + $sck_values \ | sed "s/##INSECURE_SSL##/${INSECURE_SSL}/g" \ | sed "s/##PROTO##/${PROTO}/g" \ | sed "s/##PORT##/${PORT}/g" \ @@ -332,21 +338,30 @@ then --from-literal=SIGNALFX_REALM=$SIMREALM fi - - -$KCMD -n sc4snmp create -f deploy/sc4snmp/ftr 2>/dev/null +files=( "deploy/sc4snmp/ftr/scheduler-config.yaml" "deploy/sc4snmp/ftr/scheduler-inventory.yaml" "deploy/sc4snmp/ftr/traps-server-config.yaml") +for i in "${files[@]}" +do + if [ -f $i ]; then f=$i; else f=https://raw.githubusercontent.com/splunk/splunk-connect-for-snmp/$BRANCH/$i; fi + $KCMD -n sc4snmp create -f $f +done while [ ! -n "$SHAREDIP" ] do - read -p 'SHAREDIP for HA installations this is in addition to the member addresses for single instance this is the host ip: ' SHAREDIP - + read -p 'SHAREDIP for HA installations this is in addition to the member addresses for single instance this is the host ip: ' SHAREDIP done svcip=$(echo $SHAREDIP | cut -d '/' -f 1) -cat deploy/sc4snmp/external/traps-service.yaml \ + +if [ -f "deploy/sc4snmp/external/traps-service.yaml" ]; then svc_values="cat deploy/sc4snmp/external/traps-service.yaml"; else svc_values="curl -s https://raw.githubusercontent.com/splunk/splunk-connect-for-snmp/$BRANCH/deploy/sc4snmp/external/traps-service.yaml"; fi +$svc_values \ | sed "s/##SHAREDIP##/${svcip}/g" \ | $KCMD -n sc4snmp apply -f - -$KCMD -n sc4snmp apply -f deploy/sc4snmp/internal +files=( "deploy/sc4snmp/internal/mib-server-deployment.yaml" "deploy/sc4snmp/internal/mongo-deployment.yaml" "deploy/sc4snmp/internal/otel-config.yaml" "deploy/sc4snmp/internal/otel-service.yaml" "deploy/sc4snmp/internal/rq-service.yaml" "deploy/sc4snmp/internal/traps-deployment.yaml" "deploy/sc4snmp/internal/mib-server-service.yaml" "deploy/sc4snmp/internal/mongo-service.yaml" "deploy/sc4snmp/internal/otel-deployment.yaml" "deploy/sc4snmp/internal/rq-deployment.yaml" "deploy/sc4snmp/internal/scheduler-deployment.yaml" "deploy/sc4snmp/internal/worker-deployment.yaml" ) +for i in "${files[@]}" +do + if [ -f $i ]; then f=$i; else f=https://raw.githubusercontent.com/splunk/splunk-connect-for-snmp/$BRANCH/$i; fi + $KCMD -n sc4snmp create -f $f +done echo "" echo done diff --git a/deploy/sck/deploy_sck.sh b/deploy/sck/deploy_sck.sh deleted file mode 100755 index 83d9a5efc..000000000 --- a/deploy/sck/deploy_sck.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -INSECURE_SSL=${INSECURE_SSL:=false} -PROTO=${PROTO:=https} -PORT=${PORT:=8088} -EVENTS_INDEX=${EVENTS_INDEX:=em_events} -METRICS_INDEX=${METRICS_INDEX:=em_metrics} -META_INDEX=${META_INDEX:=em_logs} -CUSTER_NAME=${CUSTER_NAME:=splunk-connect} -NAMESPACE=${NAMESPACE:=default} - -if [ ! -n "$HOST" ]; then - echo print_error "Undefined environment variable HOST ..." - exit 1 -fi -if [ ! -n "$TOKEN" ]; then - echo print_error "Undefined environment variable TOKEN ..." - exit 1 -fi - -if ! command -v realpath &> /dev/null -then - echo "realpath could not be found" - exit -fi -HCMD=helm3 -if ! command -v helm3 &> /dev/null -then - if command -v microk8s.helm3 &> /dev/null - then - HCMD=microk8s.helm3 - else - echo "realpath could not be found" - exit - fi -fi - -full_path=$(realpath $0) -dir_path=$(dirname $full_path) - -cat ${dir_path}/sck_145.yaml \ - | sed "s/##INSECURE_SSL##/${INSECURE_SSL}/g" \ - | sed "s/##PROTO##/${PROTO}/g" \ - | sed "s/##PORT##/${PORT}/g" \ - | sed "s/##HOST##/${HOST}/g" \ - | sed "s/##TOKEN##/${TOKEN}/g" \ - | sed "s/##EVENTS_INDEX##/${EVENTS_INDEX}/g" \ - | sed "s/##METRICS_INDEX##/${METRICS_INDEX}/g" \ - | sed "s/##META_INDEX##/${META_INDEX}/g" \ - | sed "s/##CUSTER_NAME##/${CUSTER_NAME}/g" \ - | sed "s/##NAMESPACE##/${NAMESPACE}/g" \ - | $HCMD -n ${NAMESPACE} install sck -f - splunk/splunk-connect-for-kubernetes - diff --git a/docs/source/gettingstarted.rst b/docs/source/gettingstarted.rst index fa8c75dec..7243a9702 100644 --- a/docs/source/gettingstarted.rst +++ b/docs/source/gettingstarted.rst @@ -36,22 +36,12 @@ Obtain the correct realm and token. Deploy ************************************************** -Get current deployment scripts -=================================================== - -.. code-block:: bash - - git clone https://github.com/splunk/splunk-connect-for-snmp.git - cd splunk-connect-for-snmp - - - Deploy SC4SNMP Interactive =================================================== .. code-block:: bash - ./deploy/deploy.sh + curl -sfL https://raw.githubusercontent.com/splunk/splunk-connect-for-snmp/main/deploy/install.bash | sudo -E bash - Deploy SC4SNMP non-interactive @@ -63,7 +53,7 @@ This script has been tested with Centos 7, Centos 8, Redhat 8, and Ubuntu 20.04 .. code-block:: bash - sudo \ + curl -sfL https://raw.githubusercontent.com/splunk/splunk-connect-for-snmp/install-from-url/deploy/install.bash | \ MODE=splunk \ PROTO=https \ INSECURE_SSL=true \ @@ -76,7 +66,7 @@ This script has been tested with Centos 7, Centos 8, Redhat 8, and Ubuntu 20.04 CLUSTER_NAME=foo \ SHAREDIP=10.202.18.166/32 \ RESOLVERIP=8.8.4.4 \ - ./deploy/deploy.sh + sudo -E bash - * Confirm deployment using ``kubectl get svc -n sc4snmp`` confirm the value of external-ip in the row below matches IP used above