github.com/verrazzano/verrazzano@v1.7.1/tests/e2e/config/scripts/configure_thanos_install_storage.sh (about) 1 #!/bin/bash 2 3 # Copyright (c) 2023, Oracle and/or its affiliates. 4 # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 5 6 INSTALL_CONFIG_TO_EDIT=$1 7 8 THANOS_ENABLED=$(yq ".spec.components.thanos.enabled" ${INSTALL_CONFIG_TO_EDIT}) 9 if [[ $THANOS_ENABLED != "true" ]]; then 10 echo "Thanos component disabled, skipping editing of ${INSTALL_CONFIG_TO_EDIT}" 11 exit 12 fi 13 14 if [ "${ENABLE_THANOS_STORE_GATEWAY}" != "true" ] && [ "${ENABLE_THANOS_COMPACTOR}" != "true" ] && [ "${ENABLE_THANOS_RULER}" != "true" ]; then 15 echo "None of the Thanos Object Storage components are enabled, skipping edit of ${INSTALL_CONFIG_TO_EDIT}" 16 exit 17 fi 18 19 # Thanos storage provider config that uses local filesystem 20 STORAGE_PROVIDER_CONFIG='type: FILESYSTEM 21 config: 22 directory: "/tmp" 23 ' 24 25 # Create the verrazzano-monitoring namespace if it does not exist and create a secret with the storage provider config 26 kubectl create ns verrazzano-monitoring 2>/dev/null || true 27 kubectl create secret generic -n verrazzano-monitoring objstore-config --from-literal=objstore.yml="${STORAGE_PROVIDER_CONFIG}" 28 29 # Add the object store override because it is independent of other Thanos components 30 yq -i eval ".spec.components.thanos.overrides.[0].values.existingObjstoreSecret = \"objstore-config\"" ${INSTALL_CONFIG_TO_EDIT} 31 32 # Modify the VZ CR to enable Thanos Store Gateway and to reference the storage provider secret 33 if [ "${ENABLE_THANOS_STORE_GATEWAY}" == "true" ]; then 34 echo "Editing install config file for Thanos Store Gateway ${INSTALL_CONFIG_TO_EDIT}" 35 yq -i eval ".spec.components.thanos.overrides.[0].values.storegateway.enabled = true" ${INSTALL_CONFIG_TO_EDIT} 36 fi 37 38 # If specified, also enable the Thanos Compactor - storage provider is shared so doesn't need extra configuration 39 if [ "${ENABLE_THANOS_COMPACTOR}" == "true" ]; then 40 echo "Editing install config file for Thanos Compactor ${INSTALL_CONFIG_TO_EDIT}" 41 yq -i eval ".spec.components.thanos.overrides.[0].values.compactor.enabled = true" ${INSTALL_CONFIG_TO_EDIT} 42 fi 43 44 # If specified, also enable the Thanos Ruler - storage provider is shared so doesn't need extra configuration 45 if [ "${ENABLE_THANOS_RULER}" == "true" ]; then 46 echo "Editing install config file for Thanos Ruler ${INSTALL_CONFIG_TO_EDIT}" 47 # ensure alertmanager is enabled and running outside of Istio 48 yq -i eval ".spec.components.prometheusOperator.overrides[2].values.alertmanager.enabled = true" ${INSTALL_CONFIG_TO_EDIT} 49 yq -i eval '.spec.components.prometheusOperator.overrides[2].values.alertmanager.alertmanagerSpec.podMetadata.annotations."sidecar.istio.io/inject" = "false"' ${INSTALL_CONFIG_TO_EDIT} 50 51 # Add the Thanos Ruler overrides 52 yq -i eval ".spec.components.thanos.overrides.[0].values.ruler.enabled = true" ${INSTALL_CONFIG_TO_EDIT} 53 fi 54 55 # Modify the VZ CR to enable storage on the Prometheus Thanos Sidecar 56 # This yq magic adds the Sidecar object storage config overrides to the correct override array element, but only if there is an existing prometheus override 57 echo "Editing install config file to enable long-term storage on the Prometheus Thanos Sidecar ${INSTALL_CONFIG_TO_EDIT}" 58 yq -i eval '(.spec.components.prometheusOperator.overrides.[].values | select(has("prometheus")).prometheus) += {"prometheusSpec":{"thanos":{"objectStorageConfig":{"key": "objstore.yml","name":"objstore-config"}}}}' ${INSTALL_CONFIG_TO_EDIT} 59 60 cat ${INSTALL_CONFIG_TO_EDIT}