Created
August 14, 2025 22:07
-
-
Save therealmitchconnors/880adc11f101477e58dc5df5dfeb1df6 to your computer and use it in GitHub Desktop.
Ambient Multicluster Setup Script for testing
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/bash | |
# Copyright 2019 Istio Authors | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# Usage: ./mc-setup.sh $ARTIFACTS | |
# This script will read topology-config.json (either created manually or written by integ-suite-kind.sh) | |
# For each included cluster, it will install Istio MC Ambient, along with a sample service, and configure | |
# trust and remote secrets between all clusters. | |
WD=$(dirname "$0") | |
WD=$(cd "$WD"; pwd) | |
ROOT=$(dirname "$WD") | |
# Exit immediately for non zero status | |
set -e | |
# Check unset variables | |
set -u | |
# Print commands | |
set -x | |
# shellcheck source=prow/lib.sh | |
source "${ROOT}/prow/lib.sh" | |
setup_and_export_git_sha | |
# shellcheck source=common/scripts/kind_provisioner.sh | |
source "${ROOT}/common/scripts/kind_provisioner.sh" | |
TOPOLOGY=SINGLE_CLUSTER | |
NODE_IMAGE="gcr.io/istio-testing/kind-node:v1.32.0" | |
KIND_CONFIG="" | |
CLUSTER_TOPOLOGY_CONFIG_DIR="$1" | |
ARTIFACTS=$CLUSTER_TOPOLOGY_CONFIG_DIR | |
CLUSTER_TOPOLOGY_CONFIG_FILE="${CLUSTER_TOPOLOGY_CONFIG_DIR}/topology-config.json" | |
CLUSTER_NAME="${CLUSTER_NAME:-istio-testing}" | |
trace "load cluster topology" load_cluster_topology "${CLUSTER_TOPOLOGY_CONFIG_FILE}" | |
export CLUSTER_KUBECONFIGS | |
KUBE_CLUSTERS=$(jq '.[] | select(.kind == "Kubernetes" or .kind == null)' "${CLUSTER_TOPOLOGY_CONFIG_FILE}") | |
while read -r value; do | |
CLUSTER_KUBECONFIGS+=("$value") | |
done < <(echo "${KUBE_CLUSTERS}" | jq -r '.meta.kubeconfig') | |
echo "fhqwgads" | |
mkdir "${ARTIFACTS}/certs" || true | |
pushd "${ARTIFACTS}/certs" | |
make -f ${ROOT}/tools/certs/Makefile.selfsigned.mk root-ca | |
export CLUSTER_SECRETS | |
ITER_END=$((NUM_CLUSTERS-1)) | |
for i in $(seq 0 "$ITER_END"); do | |
c="${CLUSTER_NAMES[i]}" | |
kc="--kubeconfig ${CLUSTER_KUBECONFIGS[i]}" | |
# setup trust | |
make -f ${ROOT}/tools/certs/Makefile.selfsigned.mk "${c}-cacerts" | |
kubectl $kc get ns istio-system &> /dev/null || \ | |
{ kubectl create ns istio-system $kc; } | |
kubectl label ns istio-system $kc --overwrite topology.istio.io/network=${CLUSTER_NETWORK_ID[i]} | |
kubectl $kc get secret -n istio-system cacerts &> /dev/null || \ | |
{ kubectl create secret generic cacerts -n istio-system $kc \ | |
--from-file=${c}/ca-cert.pem \ | |
--from-file=${c}/ca-key.pem \ | |
--from-file=${c}/root-cert.pem \ | |
--from-file=${c}/cert-chain.pem; } | |
# install istio | |
istioctl install -f ${ROOT}/mc-scale-operator.yaml -y $kc \ | |
--set values.global.multiCluster.clusterName=${c} --set values.global.network=${CLUSTER_NETWORK_ID[i]} | |
# install e/w gateways | |
kubectl get crd gateways.gateway.networking.k8s.io &> /dev/null || \ | |
kubectl kustomize "github.com/kubernetes-sigs/gateway-api/config/crd?ref=v1.3.0" | kubectl apply $kc -f - | |
${ROOT}/samples/multicluster/gen-eastwest-gateway.sh \ | |
--network "${CLUSTER_NETWORK_ID[i]}" \ | |
--ambient | \ | |
kubectl apply $kc -f - | |
# add to remote cluster list | |
SECRET=$(istioctl create-remote-secret $kc --name $c) | |
CLUSTER_SECRETS+=("$SECRET") | |
# add global sample service and client | |
kubectl $kc get ns sample &> /dev/null || \ | |
{ kubectl create ns sample $kc; } | |
kubectl $kc label ns sample istio.io/dataplane-mode=ambient | |
# kubectl apply -f ${ROOT}/samples/helloworld/helloworld.yaml \ | |
# -l service=helloworld -n sample $kc | |
${ROOT}/samples/helloworld/gen-helloworld.sh \ | |
--version ${c} | \ | |
kubectl apply -n sample $kc -f - | |
kubectl label svc helloworld -n sample 'istio.io/global=true' $kc | |
kubectl apply -f ${ROOT}/samples/curl/curl.yaml -n sample $kc | |
done | |
for o in $(seq 0 "$ITER_END"); do | |
for i in $(seq 0 "$ITER_END"); do | |
if [[ $i != $o ]]; then | |
echo "${CLUSTER_SECRETS[i]}" | kubectl apply --kubeconfig ${CLUSTER_KUBECONFIGS[o]} -f - | |
fi | |
done | |
done | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment