@@ -190,6 +190,40 @@ install:
190
190
# DEBUG_MESSAGE is used to collect all necessary debug info we need.
191
191
DEBUG_MESSAGE=""
192
192
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
+ echo -e "\033[0;31mTurning off Logging for this installation which currently is not supported in GKE Autopilot.\033[0m" >&2
218
+ NR_CLI_PRIVILEGED=false
219
+ PIXIE_SUPPORTED=false
220
+ NR_CLI_LOGGING=false
221
+ break
222
+ fi
223
+ fi
224
+ echo -e "Please type Y or N only."
225
+ done
226
+
193
227
# Determine the cluster name if not provided
194
228
CLUSTER=$($SUDO $KUBECTL config current-context 2>/dev/null || echo "unknown")
195
229
@@ -528,6 +562,14 @@ install:
528
562
fi
529
563
ARGS="${ARGS} --set ksm.enabled=${NR_CLI_KSM}"
530
564
565
+ # if installing in GKE Autopilot, we need to turn off controlPlane and pixie and set kubelet scheme and port
566
+ if [[ "$GKE_AUTOPILOT_ANSWER" == "Y" ]]; then
567
+ ARGS="${ARGS} --set newrelic-infrastructure.controlPlane.enabled=false"
568
+ ARGS="${ARGS} --set newrelic-infrastructure.kubelet.config.scheme=http"
569
+ ARGS="${ARGS} --set newrelic-infrastructure.kubelet.config.port=10255"
570
+ ARGS="${ARGS} --set newrelic-pixie.enabled=false"
571
+ fi
572
+
531
573
# leaving this commented out for the future
532
574
# if [[ $SERVER_MAJOR_VERSION -eq 1 && $SERVER_MINOR_VERSION -lt 25 ]]; then
533
575
# ARGS="${ARGS} --set kube-state-metrics.image.tag=v2.6.0"
@@ -588,10 +630,16 @@ install:
588
630
echo "{\"Metadata\":{\"helmVersion\":\"$($SUDO helm version -c --short)\", \"helmCommandBeforeExecution\":\"$SUDO helm upgrade $CLEANED_ARGS\", \"K8sClientVersion\":\"$CLIENT_MAJOR_VERSION.$CLIENT_MINOR_VERSION\",\"K8sServerVersion\":\"$SERVER_MAJOR_VERSION.$SERVER_MINOR_VERSION\",\"DebugMessage\":\"$DEBUG_MESSAGE\"}}" | tee -a {{.NR_CLI_OUTPUT}} > /dev/null
589
631
590
632
# With 2>&1 >/dev/null, ERROR only keeps the error message if $? is non-zero and is empty if $? is zero
633
+ echo "Installing newrelic-bundle......."
591
634
ERROR=$($SUDO helm upgrade $ARGS 2>&1 >/dev/null)
592
635
if [[ "${ERROR}" != "" ]]; then
593
- echo "helm (version $HELM_VERSION) repo upgrade installation failed due to: $ERROR"
594
- exit 131
636
+ if [[ "${GKE_AUTOPILOT_ANSWER}" == "Y" ]] && ! (echo "${ERROR}" | grep -q "Error"); then
637
+ echo "Warnings from GKE Autopilot: $ERROR"
638
+ break
639
+ else
640
+ echo "helm (version $HELM_VERSION) repo upgrade installation failed due to: $ERROR"
641
+ exit 131
642
+ fi
595
643
fi
596
644
else
597
645
echo ""
@@ -619,6 +667,13 @@ install:
619
667
BODY="${BODY},\"global.lowDataMode\":\"${NR_CLI_LOW_DATA_MODE}\""
620
668
BODY="${BODY},\"ksm.enabled\":\"${NR_CLI_KSM}\""
621
669
670
+ # if installing in GKE Autopilot, turn off controlPlane and set kubelet scheme and port
671
+ if [[ "$GKE_AUTOPILOT_ANSWER" == "Y" ]]; then
672
+ BODY="${BODY},\"newrelic-infrastructure.controlPlane.enabled\":\"false\""
673
+ BODY="${BODY},\"newrelic-infrastructure.kubelet.config.scheme\":\"http\""
674
+ BODY="${BODY},\"newrelic-infrastructure.kubelet.config.port\":\"10255\""
675
+ fi
676
+
622
677
# leaving this commented out for the future
623
678
# if [[ $SERVER_MAJOR_VERSION -eq 1 && $SERVER_MINOR_VERSION -lt 25 ]]; then
624
679
# BODY="${BODY},\"kube-state-metrics.image.tag\":\"v2.6.0\""
0 commit comments