Last active
April 22, 2020 15:51
-
-
Save rvennam/98498589bec118b5d8e334db1920f033 to your computer and use it in GitHub Desktop.
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 | |
set -x #echo on | |
## PREREQ: SET CONTEXTS for management-plane-context and remote-cluster-context | |
#### Cleanup | |
kubectl config use-context management-plane-context | |
meshctl uninstall | |
kubectl -n service-mesh-hub delete secret -l solo.io/kubeconfig=true | |
kubectl delete istiooperator istiocontrolplane-default -n istio-operator --context management-plane-context | |
kubectl delete istiooperator istiocontrolplane-default -n istio-operator --context remote-cluster-context | |
sleep 120s | |
#### Install Service Mesh Hub | |
kubectl config use-context management-plane-context | |
meshctl install | |
sleep 30s | |
meshctl check | |
#### Register both clusters | |
meshctl cluster register \ | |
--remote-cluster-name new-remote-cluster \ | |
--remote-context remote-cluster-context | |
meshctl cluster register \ | |
--remote-cluster-name management-cluster \ | |
--remote-context management-plane-context | |
#### Install Istio on management cluster | |
meshctl mesh install istio --context management-plane-context --operator-spec=- <<EOF | |
apiVersion: install.istio.io/v1alpha1 | |
kind: IstioOperator | |
metadata: | |
name: istiocontrolplane-default | |
namespace: istio-operator | |
spec: | |
profile: default | |
values: | |
global: | |
controlPlaneSecurityEnabled: true | |
mtls: | |
enabled: true | |
pilotCertProvider: kubernetes | |
podDNSSearchNamespaces: | |
- global | |
- '{{ valueOrDefault .DeploymentMeta.Namespace "default" }}.global' | |
prometheus: | |
enabled: true | |
security: | |
selfSigned: false | |
addonComponents: | |
kiali: | |
enabled: true | |
grafana: | |
enabled: true | |
tracing: | |
enabled: true | |
EOF | |
#### Install Istio on reomote cluster | |
meshctl mesh install istio --context remote-cluster-context --operator-spec=- <<EOF | |
apiVersion: install.istio.io/v1alpha1 | |
kind: IstioOperator | |
metadata: | |
name: istiocontrolplane-default | |
namespace: istio-operator | |
spec: | |
profile: default | |
values: | |
global: | |
controlPlaneSecurityEnabled: true | |
mtls: | |
enabled: true | |
pilotCertProvider: kubernetes | |
podDNSSearchNamespaces: | |
- global | |
- '{{ valueOrDefault .DeploymentMeta.Namespace "default" }}.global' | |
prometheus: | |
enabled: false | |
security: | |
selfSigned: false | |
EOF | |
sleep 120s | |
#### Get Clusters | |
kubectl -n service-mesh-hub get kubernetesclusters | |
#### Get Meshes | |
kubectl -n service-mesh-hub get meshes | |
#### Create Virtual Mesh | |
kubectl apply -f - <<EOF | |
apiVersion: networking.zephyr.solo.io/v1alpha1 | |
kind: VirtualMesh | |
metadata: | |
name: demo-virtual-mesh | |
namespace: service-mesh-hub | |
spec: | |
enforceAccessControl: false | |
meshes: | |
- name: istio-istio-system-new-remote-cluster | |
namespace: service-mesh-hub | |
- name: istio-istio-system-management-cluster | |
namespace: service-mesh-hub | |
EOF | |
## Restart istiods | |
kubectl delete pod -l app=istiod -n istio-system --context=management-plane-context | |
kubectl delete pod -l app=istiod -n istio-system --context=remote-cluster-context | |
## Deploy some of BookInfo on managment cluster | |
kubectl config use-context management-plane-context | |
kubectl label namespace default istio-injection=enabled | |
# we deploy everything except reviews-v3 to the management-plane cluster | |
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.5/samples/bookinfo/platform/kube/bookinfo.yaml -l 'app,version notin (v3)' | |
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.5/samples/bookinfo/platform/kube/bookinfo.yaml -l 'account' | |
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.5/samples/bookinfo/networking/bookinfo-gateway.yaml | |
## Deploy rest of BookInfo on remote cluster | |
kubectl config use-context remote-cluster-context | |
export REMOTE_CTX=remote-cluster-context | |
kubectl label namespace default istio-injection=enabled | |
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.5/samples/bookinfo/platform/kube/bookinfo.yaml -l 'app,version in (v3)' --context $REMOTE_CTX | |
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.5/samples/bookinfo/platform/kube/bookinfo.yaml -l 'service=reviews' --context $REMOTE_CTX | |
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.5/samples/bookinfo/platform/kube/bookinfo.yaml -l 'account=reviews' --context $REMOTE_CTX | |
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.5/samples/bookinfo/platform/kube/bookinfo.yaml -l 'app=ratings' --context $REMOTE_CTX | |
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.5/samples/bookinfo/platform/kube/bookinfo.yaml -l 'account=ratings' --context $REMOTE_CTX | |
# Weight based routing | |
kubectl config use-context management-plane-context | |
kubectl apply -f - <<EOF | |
apiVersion: networking.zephyr.solo.io/v1alpha1 | |
kind: TrafficPolicy | |
metadata: | |
namespace: service-mesh-hub | |
name: simple | |
spec: | |
destinationSelector: | |
serviceRefs: | |
services: | |
- cluster: management-cluster | |
name: reviews | |
namespace: default | |
trafficShift: | |
destinations: | |
- destination: | |
cluster: new-remote-cluster | |
name: reviews | |
namespace: default | |
weight: 75 | |
- destination: | |
cluster: management-cluster | |
name: reviews | |
namespace: default | |
weight: 15 | |
subset: | |
version: v1 | |
- destination: | |
cluster: management-cluster | |
name: reviews | |
namespace: default | |
weight: 10 | |
subset: | |
version: v2 | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment