-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-p2p-multicluster.sh
executable file
·83 lines (62 loc) · 3.12 KB
/
deploy-p2p-multicluster.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# deploy-p2p-multicluster.sh
# Demo script for the k3d-multicluster-playground GitHub repository
# Deploys a two cluster pod-to-pod multi-cluster setup
# https://github.com/southsidedean/linkerd-demos/tree/main/k3d-multicluster-playground
# Automates multi-cluster deployment
# Tom Dean | Buoyant
# Last edit: 10/8/2024
# Let's set some variables!
# BEL: Stable
#BEL_VERSION=enterprise-2.16.0
#CLI_VERSION=install
#MC_VERSION=enterprise
# BEL: Preview
BEL_VERSION=preview-24.10.4
CLI_VERSION=install-preview
MC_VERSION=preview
# API Addresses
CLUSTER_WAREHOUSE_API=`echo "https://$(kubectl --context warehouse get node k3d-warehouse-server-0 -o jsonpath='{.status.addresses[?(.type=="InternalIP")].address}'):6443"`
CLUSTER_ORDERS_API=`echo "https://$(kubectl --context orders get node k3d-orders-server-0 -o jsonpath='{.status.addresses[?(.type=="InternalIP")].address}'):6443"`
# Step 1: Add a Hosts Entry to CoreDNS
kubectl get cm coredns -n kube-system -o yaml --context orders -o yaml | grep -Ev "creationTimestamp|resourceVersion|uid" > coredns.yaml
sed -i .orig 's/host.k3d.internal/host.k3d.internal\ kubernetes/g' coredns.yaml
cat coredns.yaml
kubectl apply -f coredns.yaml -n kube-system --context orders
kubectl rollout restart deploy coredns -n kube-system --context orders
kubectl get cm coredns -n kube-system -o yaml --context orders -o yaml
# Step 2: Install the Multi-Cluster Extension
source settings.sh
helm repo add linkerd-buoyant https://helm.buoyant.cloud
helm repo update
helm install linkerd-multicluster \
--create-namespace \
--namespace linkerd-multicluster \
--kube-context orders \
--set linkerd-multicluster.gateway.enabled=false \
--set license=$BUOYANT_LICENSE \
linkerd-buoyant/linkerd-$MC_VERSION-multicluster
helm install linkerd-multicluster \
--create-namespace \
--namespace linkerd-multicluster \
--kube-context warehouse \
--set linkerd-multicluster.gateway.enabled=false \
--set license=$BUOYANT_LICENSE \
linkerd-buoyant/linkerd-$MC_VERSION-multicluster
linkerd --context=orders multicluster check
linkerd --context=warehouse multicluster check
kubectl apply -f policy.yaml --context orders
# Step 3: Link the Clusters
rm multicluster-*.yaml
linkerd --context=warehouse multicluster link --cluster-name warehouse --gateway=false --api-addr $CLUSTER_WAREHOUSE_API > multicluster-link.yaml
#linkerd --context=warehouse multicluster link --cluster-name warehouse --gateway=false > multicluster-link-orig.yaml
#KC1=`linkerd --context=warehouse multicluster link --cluster-name warehouse --gateway=false | grep kubeconfig: | uniq | awk {'print $2'}` ; KC2=`echo $KC1 | base64 -d | sed 's/0\.0\.0\.0/kubernetes/g' | base64` ; awk -f mc.awk "$KC1" "$KC2" multicluster-link-orig.yaml > multicluster-link.yaml
kubectl apply -f multicluster-link.yaml --context orders
kubectl get links -A --context=orders
# Step 4: Export the 'fulfillment' Service to the 'orders' Cluster
kubectl get svc -A --context=orders
kubectl get svc -A --context=warehouse
kubectl --context=warehouse label svc -n orders fulfillment mirror.linkerd.io/exported=remote-discovery
sleep 30
kubectl get svc -A --context=orders
exit 0