Created
April 6, 2021 13:59
-
-
Save ravishtiwari/b3638a615c58115fa3b1c8d2c2c78431 to your computer and use it in GitHub Desktop.
istio install script for kubernetes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## Download istio version | |
download() { | |
OS="$(uname)" | |
if [ "x${OS}" = "xDarwin" ] ; then | |
OSEXT="osx" | |
else | |
OSEXT="linux" | |
fi | |
# Determine the latest Istio version by version number ignoring alpha, beta, and rc versions. | |
if [ "x${ISTIO_VERSION}" = "x" ] ; then | |
ISTIO_VERSION="$(curl -sL https://github.com/istio/istio/releases | \ | |
grep -o 'releases/[0-9]*.[0-9]*.[0-9]*/' | sort --version-sort | \ | |
tail -1 | awk -F'/' '{ print $2}')" | |
ISTIO_VERSION="${ISTIO_VERSION##*/}" | |
fi | |
LOCAL_ARCH=$(uname -m) | |
if [ "${TARGET_ARCH}" ]; then | |
LOCAL_ARCH=${TARGET_ARCH} | |
fi | |
case "${LOCAL_ARCH}" in | |
x86_64) | |
ISTIO_ARCH=amd64 | |
;; | |
armv8*) | |
ISTIO_ARCH=arm64 | |
;; | |
aarch64*) | |
ISTIO_ARCH=arm64 | |
;; | |
armv*) | |
ISTIO_ARCH=armv7 | |
;; | |
amd64|arm64) | |
ISTIO_ARCH=${LOCAL_ARCH} | |
;; | |
*) | |
echo "This system's architecture, ${LOCAL_ARCH}, isn't supported" | |
exit 1 | |
;; | |
esac | |
if [ "x${ISTIO_VERSION}" = "x" ] ; then | |
printf "Unable to get latest Istio version. Set ISTIO_VERSION env var and re-run. For example: export ISTIO_VERSION=1.0.4" | |
exit; | |
fi | |
NAME="istio-$ISTIO_VERSION" | |
URL="https://github.com/istio/istio/releases/download/${ISTIO_VERSION}/istio-${ISTIO_VERSION}-${OSEXT}.tar.gz" | |
ARCH_URL="https://github.com/istio/istio/releases/download/${ISTIO_VERSION}/istio-${ISTIO_VERSION}-${OSEXT}-${ISTIO_ARCH}.tar.gz" | |
with_arch() { | |
printf "\nDownloading %s from %s ...\n" "$NAME" "$ARCH_URL" | |
curl -fsLO "$ARCH_URL" | |
filename="istio-${ISTIO_VERSION}-${OSEXT}-${ISTIO_ARCH}.tar.gz" | |
tar -xzf "${filename}" | |
rm "${filename}" | |
} | |
without_arch() { | |
printf "\nDownloading %s from %s ..." "$NAME" "$URL" | |
curl -fsLO "$URL" | |
filename="istio-${ISTIO_VERSION}-${OSEXT}.tar.gz" | |
tar -xzf "${filename}" | |
rm "${filename}" | |
} | |
# Istio 1.6 and above support arch | |
ARCH_SUPPORTED=$(echo "$ISTIO_VERSION" | awk '{ ARCH_SUPPORTED=substr($0, 1, 3); print ARCH_SUPPORTED; }' ) | |
# Istio 1.5 and below do not have arch support | |
ARCH_UNSUPPORTED="1.5" | |
if [ "${OS}" = "Linux" ] ; then | |
# This checks if 1.6 <= 1.5 or 1.4 <= 1.5 | |
if [ "$(expr "${ARCH_SUPPORTED}" \<= "${ARCH_UNSUPPORTED}")" -eq 1 ]; then | |
without_arch | |
else | |
with_arch | |
fi | |
elif [ "x${OS}" = "xDarwin" ] ; then | |
without_arch | |
else | |
printf "\n\n" | |
printf "Unable to download Istio %s at this moment!\n" "$ISTIO_VERSION" | |
printf "Please verify the version you are trying to download.\n\n" | |
exit | |
fi | |
printf "" | |
printf "\nIstio %s Download Complete!\n" "$ISTIO_VERSION" | |
printf "\n" | |
printf "Istio has been successfully downloaded into the %s folder on your system.\n" "$NAME" | |
printf "\n" | |
} | |
istio_install(){ | |
printf "Starting Istio installation" | |
printf "\n" | |
printf "Installing istioctl" | |
printf "\n" | |
install $NAME/bin/istioctl /bin/ | |
printf "Verifying installation" | |
printf "\n" | |
if type istioctl ;then | |
printf "Installation successfull" | |
else | |
printf "Installation failed" | |
exit | |
fi | |
printf "Deploying Istio \n" | |
istioctl install --set profile=demo | |
printf "Enabling istio for default namesapce \n" | |
kubectl label namespace default istio-injection=enabled | |
printf "Installation successfull. Please redeploy the pods in default namespace to enable istio sidecar \n" | |
} | |
download | |
set -e | |
istio_install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment