Skip to content

Commit

Permalink
Working(\!) example using deploy_esexporter.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmith-sas committed Dec 14, 2023
1 parent 4d033f1 commit 80fa02b
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 10 deletions.
66 changes: 66 additions & 0 deletions bin/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,69 @@ export -f trap_add
export -f errexit_msg
export -f disable_sa_token_automount
export -f enable_pod_token_automount


function parseFullImage {
fullImage="$1"
unset REGISTRY REPOS IMAGE VERSION

if [[ "$1" =~ (.*)\/(.*)\/(.*)\:(.*) ]]; then
echo "DEBUG: ${BASH_REMATCH[0]}"

REGISTRY="${BASH_REMATCH[1]}"
REPOS="${BASH_REMATCH[2]}"
IMAGE="${BASH_REMATCH[3]}"
VERSION="${BASH_REMATCH[4]}"
else
echo "no match"
fi
}


function v4m_replace {

if echo "$OSTYPE" | grep 'darwin' > /dev/null 2>&1; then
sed -i '' s/"$1"/"$2"/g "$3"
else
sed -i s/"$1"/"$2"/g "$3"
fi
}

function doitall {

#arg1 Full container image
#arg2 name of template file
#arg3 prefix to insert in placeholders

parseFullImage "$1"
prefix=${3:-""}

tempfile="/tmp/container_image.yaml"
template_file=$2

if [ "$template_file" != "TEMPFILE" ]; then
rm -f $tempfile
cp $template_file $tempfile
else
echo "DEBUG: modifying existing file"
fi

if [ "$AIRGAP_DEPLOYMENT" == "true" ]; then
REGISTRY="$AIRGAP_REGISTRY"
fi
v4m_replace "__${prefix}IMAGE_REGISTRY__" "$REGISTRY" "$tempfile"
v4m_replace "__${prefix}GLOBAL_REGISTRY__" "$REGISTRY" "$tempfile"
v4m_replace "__${prefix}IMAGE_REPO__" "$REGISTRY\/$REPOS\/$IMAGE" "$tempfile"
v4m_replace "__${prefix}IMAGE__" "$IMAGE" "$tempfile"
v4m_replace "__${prefix}IMAGE_TAG__" "$VERSION" "$tempfile"
v4m_replace "__${prefix}IMAGE_PULL_POLICY__" "Always" "$tempfile"
v4m_replace "__${prefix}IMAGE_PULL_SECRET__" "null" "$tempfile" #Handle Single Image Pull Secret
v4m_replace "__${prefix}IMAGE_PULL_SECRETS__" "[]" "$tempfile" #Handle Multiple Image Pull Secrets

}



export -f parseFullImage
export -f v4m_replace
export -f doitall
2 changes: 2 additions & 0 deletions component_versions.env
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ESEXPORTER_HELM_CHART_REPO=prometheus-community
ESEXPORTER_HELM_CHART_NAME=prometheus-elasticsearch-exporter
ESEXPORTER_HELM_CHART_VERSION=5.3.1
ES_EXPORTER_FULL_IMAGE="quay.io/prometheuscommunity/elasticsearch-exporter:v1.6.0"
###ESEXPORTER_HELM_CHART_VERSION=5.2.0
###ES_EXPORTER_FULL_IMAGE="quay.io/prometheuscommunity/elasticsearch-exporter:v1.5.0"

#Fluent Bit
FLUENTBIT_HELM_CHART_REPO=fluent
Expand Down
19 changes: 14 additions & 5 deletions logging/bin/deploy_esexporter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,22 @@ if [ "$AIRGAP_DEPLOYMENT" == "true" ]; then

# Check for the image pull secret for the air gap environment and replace placeholders
checkForAirgapSecretInNamespace "$AIRGAP_IMAGE_PULL_SECRET_NAME" "$LOG_NS"
replaceAirgapValuesInFiles "logging/airgap/airgap-values-es-exporter.yaml"
### replaceAirgapValuesInFiles "logging/airgap/airgap-values-es-exporter.yaml"

airgapValuesFile=$updatedAirgapValuesFile
else
airgapValuesFile=$TMP_DIR/empty.yaml
### airgapValuesFile=$updatedAirgapValuesFile
###else
### airgapValuesFile=$TMP_DIR/empty.yaml
fi

########
echo "DDDDDDD"
doitall "$ES_EXPORTER_FULL_IMAGE" "logging/esexporter/es-exporter_container_image.template"
imageKeysFile="/tmp/container_image.yaml"
cat "$imageKeysFile"
echo "DDDDDDD"



# Load any user customizations/overrides
ES_OPEN_EXPORTER_USER_YAML="${ES_OPEN_EXPORTER_USER_YAML:-$USER_DIR/logging/user-values-es-exporter.yaml}"
if [ ! -f "$ES_OPEN_EXPORTER_USER_YAML" ]; then
Expand Down Expand Up @@ -119,10 +128,10 @@ log_debug "Installing Helm chart from artifact [$chart2install]"
helm $helmDebug upgrade --install es-exporter \
--namespace $LOG_NS \
--version $ESEXPORTER_HELM_CHART_VERSION \
-f $imageKeysFile \
-f $primaryValuesFile \
-f $wnpValuesFile \
-f $openshiftValuesFile \
-f $airgapValuesFile \
-f $ES_OPEN_EXPORTER_USER_YAML \
--set fullnameOverride=v4m-es-exporter \
$chart2install
Expand Down
10 changes: 5 additions & 5 deletions logging/esexporter/values-es-exporter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ replicaCount: 1
##
restartPolicy: Always

image:
repository: quay.io/prometheuscommunity/elasticsearch-exporter
tag: v1.6.0
pullPolicy: Always
pullSecret: ""
#image:
# repository: quay.io/prometheuscommunity/elasticsearch-exporter
# tag: v1.6.0
# pullPolicy: Always
# pullSecret: ""

# logfmt|json
log:
Expand Down

0 comments on commit 80fa02b

Please sign in to comment.