$kubectlapply--context=$CTX_CLUSTER1-nfoo-f-<<EOF apiVersion:networking.istio.io/v1alpha3 kind:ServiceEntry metadata: name:httpbin-bar spec: hosts: # must be of form name.namespace.global -httpbin.bar.global # Treat remote cluster services as part of the service mesh # as all clusters in the service mesh share the same root of trust. location:MESH_INTERNAL ports: -name:http1 number:8000 protocol:http resolution:DNS addresses: # the IP address to which httpbin.bar.global will resolve to # must be unique for each remote service, within a given cluster. # This address need not be routable. Traffic for this IP will be captured # by the sidecar and routed appropriately. -240.0.0.2 endpoints: # This is the routable address of the ingress gateway in cluster2 that # sits in front of sleep.foo service. Traffic from the sidecar will be # routed to this address. -address:${CLUSTER2_GW_ADDR} ports: http1:15443# Do not change this port value EOF
$ cat <<EOF> istio-main-cluster.yaml apiVersion: install.istio.io/v1alpha1 kind: IstioOperator spec: values: global: multiCluster: clusterName: ${MAIN_CLUSTER_NAME} network: ${MAIN_CLUSTER_NETWORK} # Mesh network configuration. This is optional and may be omitted if # all clusters are on the same network. meshNetworks: ${MAIN_CLUSTER_NETWORK}: endpoints: - fromRegistry: ${MAIN_CLUSTER_NAME} gateways: - registry_service_name: istio-ingressgateway.istio-system.svc.cluster.local port: 443 ${REMOTE_CLUSTER_NETWORK}: endpoints: - fromRegistry: ${REMOTE_CLUSTER_NAME} gateways: - registry_service_name: istio-ingressgateway.istio-system.svc.cluster.local port: 443 # Change the Istio service `type=LoadBalancer` and add the cloud provider specific annotations. See # https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer for more # information. The example below shows the configuration for GCP/GKE. components: pilot: k8s: service: type: LoadBalancer service_annotations: cloud.google.com/load-balancer-type: Internal EOF $ istioctl install -f istio-main-cluster.yaml
1 2
$ export ISTIOD_REMOTE_EP=$(kubectl get svc -n istio-system --context=${MAIN_CLUSTER_CTX} istiod -o jsonpath='{.status.loadBalancer.ingress[0].ip}') $ echo"ISTIOD_REMOTE_EP is ${ISTIOD_REMOTE_EP}"
cat <<EOF> istio-remote0-cluster.yaml apiVersion: install.istio.io/v1alpha1 kind: IstioOperator spec: values: global: # The remote cluster's name and network name must match the values specified in the # mesh network configuration of the main cluster. multiCluster: clusterName: ${REMOTE_CLUSTER_NAME} network: ${REMOTE_CLUSTER_NETWORK} # Replace ISTIOD_REMOTE_EP with the the value of ISTIOD_REMOTE_EP set earlier. remotePilotAddress: ${ISTIOD_REMOTE_EP} ## The istio-ingressgateway is not required in the remote cluster if both clusters are on ## the same network. To disable the istio-ingressgateway component, uncomment the lines below. # # components: # ingressGateways: # - name: istio-ingressgateway # enabled: false EOF $ istioctl install -f istio-remote0-cluster.yaml