From c0d4ec10414dee5001d8638a26ac4f94fc984284 Mon Sep 17 00:00:00 2001 From: Delyan Raychev Date: Wed, 21 Jul 2021 07:38:45 -0700 Subject: [PATCH] multicluster: Populate MulticlusterService (#3802) * multicluster: Populate MulticlusterService * Shellcheck fixes * Change port number --- demo/populate-MulticlusterService.sh | 42 ++++++++++++++++++++++++++++ demo/run-osm-multicluster-demo.sh | 2 ++ 2 files changed, 44 insertions(+) create mode 100755 demo/populate-MulticlusterService.sh diff --git a/demo/populate-MulticlusterService.sh b/demo/populate-MulticlusterService.sh new file mode 100755 index 0000000000..301c81374b --- /dev/null +++ b/demo/populate-MulticlusterService.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +set -auexo pipefail + +# TODO: Parameterize this value: https://github.com/openservicemesh/osm/issues/3804 +GATEWAY_PORT=14080 + +# Populate the IP of the Multicluster Gateway from the OTHER cluster +########################## +# Get IP addresses of OSM Multicluster Gateways +kubectl config use-context 'alpha' +ALPHA_OSM_GATEWAY_IP=$(kubectl get pods -n 'osm-system' --selector app=osm-gateway -o json | jq -r '.items[].status.podIP') + +kubectl config use-context 'beta' +BETA_OSM_GATEWAY_IP=$(kubectl get pods -n 'osm-system' --selector app=osm-gateway -o json | jq -r '.items[].status.podIP') + +########################## +# Populate Alpha w/ Beta's IP +kubectl config use-context 'alpha' +kubectl patch MulticlusterService \ + --namespace bookstore \ + bookstore \ + --type merge \ + --patch '{"spec":{"clusters":[{"name":"beta","address":"'"${BETA_OSM_GATEWAY_IP}"':'"${GATEWAY_PORT}"'"}]}}' + +kubectl get MulticlusterService \ + --namespace bookstore bookstore \ + -o json | jq '.spec.clusters' + + +########################## +# Populate Beta w/ Alpha's IP +kubectl config use-context 'beta' +kubectl patch MulticlusterService \ + --namespace bookstore \ + bookstore \ + --type merge \ + --patch '{"spec":{"clusters":[{"name":"alpha","address":"'"${ALPHA_OSM_GATEWAY_IP}"':'"${GATEWAY_PORT}"'"}]}}' + +kubectl get MulticlusterService \ + --namespace bookstore bookstore \ + -o json | jq '.spec.clusters' diff --git a/demo/run-osm-multicluster-demo.sh b/demo/run-osm-multicluster-demo.sh index bb08d14fab..c206a5839e 100755 --- a/demo/run-osm-multicluster-demo.sh +++ b/demo/run-osm-multicluster-demo.sh @@ -133,3 +133,5 @@ for CONTEXT in $MULTICLUSTER_CONTEXTS; do # Create the MultiClusterService object. ./demo/deploy-MultiClusterService.sh done + +./demo/populate-MulticlusterService.sh