fix(300-deploy-loki): modify Helm test script to support proxy

Before, invoking the Loki Helm test was skipped if the environment had a
proxy configured.

Now, the configmap for the test is modified with the proxy vars. The
Loki stach Helm chart does not provide any configuration around this, so
we can modify the configmap.

As of right now, the certificates are not needed for `apk add` and only
proxy vars are required.

Change-Id: If58d99555ed299b99bd9bda441856aac326d8379
This commit is contained in:
Dustin Specker 2021-03-15 12:54:12 -05:00
parent 8377c131d9
commit b689929e2d

View File

@ -14,10 +14,37 @@ helm upgrade \
./tools/deployment/common/wait-for-pods.sh loki ./tools/deployment/common/wait-for-pods.sh loki
# TODO(dustinspecker): remove this if condition and run loki test behind proxy # todo(dustinspecker): create a pull request for Loki Helm chart
# loki pod's container downloads jq and curl, which won't work # to provide proxy configuration to prevent having to modify the
# since the proxies are not configured for the pod, so skip test loki test for now # configmap. Then provide proxy configuration as overrides to the
# when proxy is defined # `helm upgrade` command above.
if [ -z "$http_proxy" ]; then proxy_export="\
helm -n loki test loki --logs export HTTP_PROXY=\"$HTTP_PROXY\"\n\
fi export HTTPS_PROXY=\"$HTTPS_PROXY\"\n\
export NO_PROXY=\"$NO_PROXY,\$LOKI_SERVICE\"\n\
export http_proxy=\"$http_proxy\"\n\
export https_proxy=\"$https_proxy\"\n\
export no_proxy=\"$no_proxy,\$LOKI_SERVICE\"\
"
configmap_yaml="$(mktemp)"
kubectl get configmap loki-loki-stack-test \
--namespace loki \
--output yaml \
> "$configmap_yaml"
# install gawk because older versions of awk and alternatives such as mawk
# don't support inplace
sudo -E apt-get install gawk --yes
# prepend proxy_export only for the first match of LOKI_URI=
# This enables the script to be idempotent and prevent modifying the
# last-applied-configuration annotation and breaking the YAML format.
gawk --assign proxy_export="$proxy_export" \
--include inplace \
'/LOKI_URI=/ && !matched { print proxy_export ; matched=1 } 1' "$configmap_yaml"
kubectl apply --filename "$configmap_yaml"
helm -n loki test loki --logs