Skip to content

Commit

Permalink
update GKE autopilot question (#1045)
Browse files Browse the repository at this point in the history
  • Loading branch information
csongnr authored Feb 14, 2024
1 parent dec1722 commit 631d037
Showing 1 changed file with 40 additions and 63 deletions.
103 changes: 40 additions & 63 deletions recipes/newrelic/infrastructure/kubernetes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,71 +190,48 @@ install:
# DEBUG_MESSAGE is used to collect all necessary debug info we need.
DEBUG_MESSAGE=""
# Determine if user is installing in gke autopilot
GKE_AUTOPILOT_ANSWER="N"
while :; do
echo -e -n "${GREEN}Are you installing in a GKE Autopilot cluster? Y/N? ${NC} "
if [[ "{{.NEW_RELIC_ASSUME_YES}}" == "true" ]]; then
echo "Assume yes flag was provided - answering N for installing in GKE Autopilot."
echo "Continuing with installing the integration."
GKE_AUTOPILOT_ANSWER="N"
break
else
read ans
echo ""
GKE_AUTOPILOT_ANSWER=$(echo "${ans^^}" | cut -c1-1)
if [[ "$GKE_AUTOPILOT_ANSWER" == "N" ]]; then
echo "Continuing with installing the integration."
echo "{\"Metadata\":{\"gkeAutopilotAnswer\":\"No\",\"DebugMessage\":\"$DEBUG_MESSAGE\"}}" | tee -a {{.NR_CLI_OUTPUT}} > /dev/null
break
fi
if [[ "$GKE_AUTOPILOT_ANSWER" == "Y" ]]; then
echo "{\"Metadata\":{\"gkeAutopilotAnswer\":\"Yes\",\"DebugMessage\":\"$DEBUG_MESSAGE\"}}" | tee -a {{.NR_CLI_OUTPUT}} > /dev/null
echo -e "\033[0;31mGKE Autopilot does not allow privileged access. Turning off privileged mode.\033[0m" >&2
echo -e "\033[0;31mTurning off Pixie for this installation which requires privileged access.\033[0m" >&2
NR_CLI_PRIVILEGED=false
PIXIE_SUPPORTED=false
if [[ "{{.NR_CLI_GKE_AUTOPILOT}}" == "true" ]]; then
echo "{\"Metadata\":{\"gkeAutopilotAnswer\":\"Yes\",\"DebugMessage\":\"$DEBUG_MESSAGE\"}}" | tee -a {{.NR_CLI_OUTPUT}} > /dev/null
echo -e "\033[0;31mGKE Autopilot usage confirmed.\033[0m" >&2
echo -e "\033[0;31mGKE Autopilot does not allow privileged access. Turning off privileged mode.\033[0m" >&2
echo -e "\033[0;31mTurning off Pixie for this installation which requires privileged access.\033[0m" >&2
NR_CLI_PRIVILEGED=false
PIXIE_SUPPORTED=false
if [[ "$NR_CLI_LOGGING" == "true" ]]; then
# We assume that if those both envs are set, the FileStore decision has been made on the Guided install.
if [[ -z "$NR_CLI_LOGGING_PERSISTENCE" || -z "$NR_CLI_LOGGING_LINUX_MOUNT_PATH" ]]; then
while :; do
echo ""
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
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
echo -e "\033[0;31mNot using FileStore will produce data loss or data duplication when Fluent Bit gets restarted.\033[0m" >&2
echo -e -n "${GREEN}Do you want to use FileStore to keep track of read and sent logs by Fluent Bit? Y/N? ${NC} "
read filestoreans
echo ""
LOGGING_USE_FILESTORE=$(echo "${filestoreans^^}" | cut -c1-1)
if [[ "$LOGGING_USE_FILESTORE" == "Y" ]]; then
NR_CLI_LOGGING_PERSISTENCE=persistentVolume
NR_CLI_LOGGING_PERSISTENCE_STORAGE_CLASS=standard-rwx
NR_CLI_LOGGING_LINUX_MOUNT_PATH=/var/log
break
fi
if [[ "$LOGGING_USE_FILESTORE" == "N" ]]; then
NR_CLI_LOGGING_PERSISTENCE=none
NR_CLI_LOGGING_LINUX_MOUNT_PATH=/var/log
break
fi
echo -e "Please type Y or N only."
done
else
if [[ "$NR_CLI_LOGGING_PERSISTENCE" == "none" ]]; then
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
elif [[ "$NR_CLI_LOGGING_PERSISTENCE" == "persistentVolume" ]]; then
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
fi
if [[ "$NR_CLI_LOGGING" == "true" ]]; then
# We assume that if those both envs are set, the FileStore decision has been made on the Guided install.
if [[ -z "$NR_CLI_LOGGING_PERSISTENCE" || -z "$NR_CLI_LOGGING_LINUX_MOUNT_PATH" ]]; then
while :; do
echo ""
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
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
echo -e "\033[0;31mNot using FileStore will produce data loss or data duplication when Fluent Bit gets restarted.\033[0m" >&2
echo -e -n "${GREEN}Do you want to use FileStore to keep track of read and sent logs by Fluent Bit? Y/N? ${NC} "
read filestoreans
echo ""
LOGGING_USE_FILESTORE=$(echo "${filestoreans^^}" | cut -c1-1)
if [[ "$LOGGING_USE_FILESTORE" == "Y" ]]; then
NR_CLI_LOGGING_PERSISTENCE=persistentVolume
NR_CLI_LOGGING_PERSISTENCE_STORAGE_CLASS=standard-rwx
NR_CLI_LOGGING_LINUX_MOUNT_PATH=/var/log
break
fi
if [[ "$LOGGING_USE_FILESTORE" == "N" ]]; then
NR_CLI_LOGGING_PERSISTENCE=none
NR_CLI_LOGGING_LINUX_MOUNT_PATH=/var/log
break
fi
echo -e "Please type Y or N only."
done
else
if [[ "$NR_CLI_LOGGING_PERSISTENCE" == "none" ]]; then
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
elif [[ "$NR_CLI_LOGGING_PERSISTENCE" == "persistentVolume" ]]; then
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
fi
break
fi
fi
echo -e "Please type Y or N only."
done
fi
# Determine the cluster name if not provided
CLUSTER=$($SUDO $KUBECTL config current-context 2>/dev/null || echo "unknown")
Expand Down Expand Up @@ -598,7 +575,7 @@ install:
ARGS="${ARGS} --set ksm.enabled=${NR_CLI_KSM}"
# if installing in GKE Autopilot, we need to turn off controlPlane and pixie and set kubelet scheme and port
if [[ "$GKE_AUTOPILOT_ANSWER" == "Y" ]]; then
if [[ "{{.NR_CLI_GKE_AUTOPILOT}}" == "true" ]]; then
ARGS="${ARGS} --set newrelic-infrastructure.controlPlane.enabled=false"
ARGS="${ARGS} --set newrelic-infrastructure.kubelet.config.scheme=http"
ARGS="${ARGS} --set newrelic-infrastructure.kubelet.config.port=10255"
Expand Down Expand Up @@ -678,7 +655,7 @@ install:
echo "Installing newrelic-bundle......."
ERROR=$($SUDO helm upgrade $ARGS 2>&1 >/dev/null)
if [[ "${ERROR}" != "" ]]; then
if [[ "${GKE_AUTOPILOT_ANSWER}" == "Y" ]] && ! (echo "${ERROR}" | grep -q "Error"); then
if [[ "{{.NR_CLI_GKE_AUTOPILOT}}" == "true" ]] && ! (echo "${ERROR}" | grep -q "Error"); then
echo "Warnings from GKE Autopilot: $ERROR"
break
else
Expand Down Expand Up @@ -713,7 +690,7 @@ install:
BODY="${BODY},\"ksm.enabled\":\"${NR_CLI_KSM}\""
# if installing in GKE Autopilot, turn off controlPlane and set kubelet scheme and port
if [[ "$GKE_AUTOPILOT_ANSWER" == "Y" ]]; then
if [[ "{{.NR_CLI_GKE_AUTOPILOT}}" == "true" ]]; then
BODY="${BODY},\"newrelic-infrastructure.controlPlane.enabled\":\"false\""
BODY="${BODY},\"newrelic-infrastructure.kubelet.config.scheme\":\"http\""
BODY="${BODY},\"newrelic-infrastructure.kubelet.config.port\":\"10255\""
Expand Down

0 comments on commit 631d037

Please sign in to comment.