Skip to content

Commit 631d037

Browse files
authored
update GKE autopilot question (#1045)
1 parent dec1722 commit 631d037

File tree

1 file changed

+40
-63
lines changed

1 file changed

+40
-63
lines changed

recipes/newrelic/infrastructure/kubernetes.yml

Lines changed: 40 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -190,71 +190,48 @@ install:
190190
# DEBUG_MESSAGE is used to collect all necessary debug info we need.
191191
DEBUG_MESSAGE=""
192192
193-
# Determine if user is installing in gke autopilot
194-
195-
GKE_AUTOPILOT_ANSWER="N"
196-
while :; do
197-
echo -e -n "${GREEN}Are you installing in a GKE Autopilot cluster? Y/N? ${NC} "
198-
199-
if [[ "{{.NEW_RELIC_ASSUME_YES}}" == "true" ]]; then
200-
echo "Assume yes flag was provided - answering N for installing in GKE Autopilot."
201-
echo "Continuing with installing the integration."
202-
GKE_AUTOPILOT_ANSWER="N"
203-
break
204-
else
205-
read ans
206-
echo ""
207-
GKE_AUTOPILOT_ANSWER=$(echo "${ans^^}" | cut -c1-1)
208-
if [[ "$GKE_AUTOPILOT_ANSWER" == "N" ]]; then
209-
echo "Continuing with installing the integration."
210-
echo "{\"Metadata\":{\"gkeAutopilotAnswer\":\"No\",\"DebugMessage\":\"$DEBUG_MESSAGE\"}}" | tee -a {{.NR_CLI_OUTPUT}} > /dev/null
211-
break
212-
fi
213-
if [[ "$GKE_AUTOPILOT_ANSWER" == "Y" ]]; then
214-
echo "{\"Metadata\":{\"gkeAutopilotAnswer\":\"Yes\",\"DebugMessage\":\"$DEBUG_MESSAGE\"}}" | tee -a {{.NR_CLI_OUTPUT}} > /dev/null
215-
echo -e "\033[0;31mGKE Autopilot does not allow privileged access. Turning off privileged mode.\033[0m" >&2
216-
echo -e "\033[0;31mTurning off Pixie for this installation which requires privileged access.\033[0m" >&2
217-
NR_CLI_PRIVILEGED=false
218-
PIXIE_SUPPORTED=false
193+
if [[ "{{.NR_CLI_GKE_AUTOPILOT}}" == "true" ]]; then
194+
echo "{\"Metadata\":{\"gkeAutopilotAnswer\":\"Yes\",\"DebugMessage\":\"$DEBUG_MESSAGE\"}}" | tee -a {{.NR_CLI_OUTPUT}} > /dev/null
195+
echo -e "\033[0;31mGKE Autopilot usage confirmed.\033[0m" >&2
196+
echo -e "\033[0;31mGKE Autopilot does not allow privileged access. Turning off privileged mode.\033[0m" >&2
197+
echo -e "\033[0;31mTurning off Pixie for this installation which requires privileged access.\033[0m" >&2
198+
NR_CLI_PRIVILEGED=false
199+
PIXIE_SUPPORTED=false
219200
220-
if [[ "$NR_CLI_LOGGING" == "true" ]]; then
221-
# We assume that if those both envs are set, the FileStore decision has been made on the Guided install.
222-
if [[ -z "$NR_CLI_LOGGING_PERSISTENCE" || -z "$NR_CLI_LOGGING_LINUX_MOUNT_PATH" ]]; then
223-
while :; do
224-
echo ""
225-
echo -e "\033[0;31mFluent Bit can use a FileStore volume to prevent data loss or duplicated logs during Fluent Bit pod restarts or redeploys.\033[0m" >&2
226-
echo -e "\033[0;31mUsing FileStore will incur additional costs as charged by Google. Consult your Google Cloud Admin or visit the FileStore docs.\033[0m" >&2
227-
echo -e "\033[0;31mNot using FileStore will produce data loss or data duplication when Fluent Bit gets restarted.\033[0m" >&2
228-
echo -e -n "${GREEN}Do you want to use FileStore to keep track of read and sent logs by Fluent Bit? Y/N? ${NC} "
229-
read filestoreans
230-
echo ""
231-
LOGGING_USE_FILESTORE=$(echo "${filestoreans^^}" | cut -c1-1)
232-
if [[ "$LOGGING_USE_FILESTORE" == "Y" ]]; then
233-
NR_CLI_LOGGING_PERSISTENCE=persistentVolume
234-
NR_CLI_LOGGING_PERSISTENCE_STORAGE_CLASS=standard-rwx
235-
NR_CLI_LOGGING_LINUX_MOUNT_PATH=/var/log
236-
break
237-
fi
238-
if [[ "$LOGGING_USE_FILESTORE" == "N" ]]; then
239-
NR_CLI_LOGGING_PERSISTENCE=none
240-
NR_CLI_LOGGING_LINUX_MOUNT_PATH=/var/log
241-
break
242-
fi
243-
echo -e "Please type Y or N only."
244-
done
245-
else
246-
if [[ "$NR_CLI_LOGGING_PERSISTENCE" == "none" ]]; then
247-
echo -e "\033[0;31mFluent Bit is not using a database and data loss or data duplication can happen when Fluent Bit gets restarted.\033[0m" >&2
248-
elif [[ "$NR_CLI_LOGGING_PERSISTENCE" == "persistentVolume" ]]; then
249-
echo -e "\033[0;31mFluent Bit is using FileStore volume to prevent data loss or duplicated logs during Fluent Bit pod restarts or redeploys. Using FileStore will incur additional costs as charged by Google. Consult your Google Cloud Admin or visit the FileStore docs.\033[0m" >&2
250-
fi
201+
if [[ "$NR_CLI_LOGGING" == "true" ]]; then
202+
# We assume that if those both envs are set, the FileStore decision has been made on the Guided install.
203+
if [[ -z "$NR_CLI_LOGGING_PERSISTENCE" || -z "$NR_CLI_LOGGING_LINUX_MOUNT_PATH" ]]; then
204+
while :; do
205+
echo ""
206+
echo -e "\033[0;31mFluent Bit can use a FileStore volume to prevent data loss or duplicated logs during Fluent Bit pod restarts or redeploys.\033[0m" >&2
207+
echo -e "\033[0;31mUsing FileStore will incur additional costs as charged by Google. Consult your Google Cloud Admin or visit the FileStore docs.\033[0m" >&2
208+
echo -e "\033[0;31mNot using FileStore will produce data loss or data duplication when Fluent Bit gets restarted.\033[0m" >&2
209+
echo -e -n "${GREEN}Do you want to use FileStore to keep track of read and sent logs by Fluent Bit? Y/N? ${NC} "
210+
read filestoreans
211+
echo ""
212+
LOGGING_USE_FILESTORE=$(echo "${filestoreans^^}" | cut -c1-1)
213+
if [[ "$LOGGING_USE_FILESTORE" == "Y" ]]; then
214+
NR_CLI_LOGGING_PERSISTENCE=persistentVolume
215+
NR_CLI_LOGGING_PERSISTENCE_STORAGE_CLASS=standard-rwx
216+
NR_CLI_LOGGING_LINUX_MOUNT_PATH=/var/log
217+
break
218+
fi
219+
if [[ "$LOGGING_USE_FILESTORE" == "N" ]]; then
220+
NR_CLI_LOGGING_PERSISTENCE=none
221+
NR_CLI_LOGGING_LINUX_MOUNT_PATH=/var/log
222+
break
251223
fi
224+
echo -e "Please type Y or N only."
225+
done
226+
else
227+
if [[ "$NR_CLI_LOGGING_PERSISTENCE" == "none" ]]; then
228+
echo -e "\033[0;31mFluent Bit is not using a database and data loss or data duplication can happen when Fluent Bit gets restarted.\033[0m" >&2
229+
elif [[ "$NR_CLI_LOGGING_PERSISTENCE" == "persistentVolume" ]]; then
230+
echo -e "\033[0;31mFluent Bit is using FileStore volume to prevent data loss or duplicated logs during Fluent Bit pod restarts or redeploys. Using FileStore will incur additional costs as charged by Google. Consult your Google Cloud Admin or visit the FileStore docs.\033[0m" >&2
252231
fi
253-
break
254232
fi
255233
fi
256-
echo -e "Please type Y or N only."
257-
done
234+
fi
258235
259236
# Determine the cluster name if not provided
260237
CLUSTER=$($SUDO $KUBECTL config current-context 2>/dev/null || echo "unknown")
@@ -598,7 +575,7 @@ install:
598575
ARGS="${ARGS} --set ksm.enabled=${NR_CLI_KSM}"
599576
600577
# if installing in GKE Autopilot, we need to turn off controlPlane and pixie and set kubelet scheme and port
601-
if [[ "$GKE_AUTOPILOT_ANSWER" == "Y" ]]; then
578+
if [[ "{{.NR_CLI_GKE_AUTOPILOT}}" == "true" ]]; then
602579
ARGS="${ARGS} --set newrelic-infrastructure.controlPlane.enabled=false"
603580
ARGS="${ARGS} --set newrelic-infrastructure.kubelet.config.scheme=http"
604581
ARGS="${ARGS} --set newrelic-infrastructure.kubelet.config.port=10255"
@@ -678,7 +655,7 @@ install:
678655
echo "Installing newrelic-bundle......."
679656
ERROR=$($SUDO helm upgrade $ARGS 2>&1 >/dev/null)
680657
if [[ "${ERROR}" != "" ]]; then
681-
if [[ "${GKE_AUTOPILOT_ANSWER}" == "Y" ]] && ! (echo "${ERROR}" | grep -q "Error"); then
658+
if [[ "{{.NR_CLI_GKE_AUTOPILOT}}" == "true" ]] && ! (echo "${ERROR}" | grep -q "Error"); then
682659
echo "Warnings from GKE Autopilot: $ERROR"
683660
break
684661
else
@@ -713,7 +690,7 @@ install:
713690
BODY="${BODY},\"ksm.enabled\":\"${NR_CLI_KSM}\""
714691
715692
# if installing in GKE Autopilot, turn off controlPlane and set kubelet scheme and port
716-
if [[ "$GKE_AUTOPILOT_ANSWER" == "Y" ]]; then
693+
if [[ "{{.NR_CLI_GKE_AUTOPILOT}}" == "true" ]]; then
717694
BODY="${BODY},\"newrelic-infrastructure.controlPlane.enabled\":\"false\""
718695
BODY="${BODY},\"newrelic-infrastructure.kubelet.config.scheme\":\"http\""
719696
BODY="${BODY},\"newrelic-infrastructure.kubelet.config.port\":\"10255\""

0 commit comments

Comments
 (0)