Last active
August 12, 2020 20:14
-
-
Save nmittler/b52a5727917f43cd4702a92641a85ade to your computer and use it in GitHub Desktop.
This file contains 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 | |
set -euo pipefail | |
HUB=gcr.io/istio-testing | |
TAG=latest | |
echo "HUB=${HUB}" | |
echo "TAG=${TAG}" | |
# Delete Istio in this cluster | |
kubectl delete ns istio-system sample --context=${CTX3} --ignore-not-found | |
# Expose istiod on the first cluster. | |
echo "Exposing istiod on the first cluster..." | |
kubectl apply --context=${CTX1} -f \ | |
${ISTIO}/samples/istiod-gateway/istiod-gateway.yaml | |
# Update the first cluster | |
echo "Updating MeshNetworks in the first cluster..." | |
cat <<EOF> ${WORK_DIR}/${CLUSTER1}/install.yaml | |
apiVersion: install.istio.io/v1alpha1 | |
kind: IstioOperator | |
spec: | |
values: | |
global: | |
meshID: ${MESH} | |
multiCluster: | |
clusterName: ${CLUSTER1} | |
network: ${NETWORK1} | |
meshNetworks: | |
${NETWORK1}: | |
endpoints: | |
- fromRegistry: ${CLUSTER1} | |
gateways: | |
- registry_service_name: istio-ingressgateway.istio-system.svc.cluster.local | |
port: 15443 | |
${NETWORK2}: | |
endpoints: | |
- fromRegistry: ${CLUSTER3} | |
gateways: | |
- registry_service_name: istio-ingressgateway.istio-system.svc.cluster.local | |
port: 15443 | |
EOF | |
istioctl --context=${CTX1} install -f \ | |
${WORK_DIR}/${CLUSTER1}/install.yaml \ | |
--charts manifests \ | |
--set values.global.hub=${HUB} \ | |
--set values.global.tag=${TAG} \ | |
--set values.global.imagePullPolicy=Always | |
# Configure trust | |
echo "Configuring trust..." | |
kubectl create namespace istio-system --context=${CTX3} | |
kubectl create secret generic cacerts --context=${CTX3} \ | |
-n istio-system \ | |
--from-file=${ISTIO}/samples/certs/ca-cert.pem \ | |
--from-file=${ISTIO}/samples/certs/ca-key.pem \ | |
--from-file=${ISTIO}/samples/certs/root-cert.pem \ | |
--from-file=${ISTIO}/samples/certs/cert-chain.pem | |
# Install Istio | |
echo "Installing Istio on the remote cluster..." | |
export DISCOVERY_ADDRESS=$(kubectl \ | |
--context=${CTX1} \ | |
-n istio-system get svc istio-ingressgateway \ | |
-o jsonpath='{.status.loadBalancer.ingress[0].ip}') | |
mkdir -p ${WORK_DIR}/${CLUSTER3} && \ | |
cat <<EOF> ${WORK_DIR}/${CLUSTER3}/install.yaml | |
apiVersion: install.istio.io/v1alpha1 | |
kind: IstioOperator | |
spec: | |
values: | |
global: | |
meshID: ${MESH} | |
multiCluster: | |
clusterName: ${CLUSTER3} | |
network: ${NETWORK2} | |
# Access the control plane discovery server via the ingress | |
remotePilotAddress: ${DISCOVERY_ADDRESS} | |
EOF | |
istioctl --context=${CTX3} install -f \ | |
${WORK_DIR}/${CLUSTER3}/install.yaml \ | |
--charts manifests \ | |
--set values.global.hub=${HUB} \ | |
--set values.global.tag=${TAG} \ | |
--set values.global.imagePullPolicy=Always | |
# Verify the installation | |
kubectl --context=${CTX3} -n istio-system get pod | |
# Expose services via ingress | |
echo "Exposing services via ingress..." | |
kubectl --context=${CTX1} apply -n istio-system -f \ | |
${ISTIO}/samples/cross-network-gateway/cross-network-gateway.yaml | |
kubectl --context=${CTX3} apply -n istio-system -f \ | |
${ISTIO}/samples/cross-network-gateway/cross-network-gateway.yaml | |
# Configure cross-cluster LB | |
echo "Configuring cross-cluster load balancing..." | |
istioctl x create-remote-secret \ | |
--context=${CTX3} \ | |
--name=${CLUSTER3} | \ | |
kubectl apply -f - --context=${CTX1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment