本系列的安裝會以Istio Primary-Remote的架構進行安裝
安裝參考:https://istio.io/latest/docs/setup/install/multicluster/primary-remote/
下載istio
curl -L https://istio.io/downloadIstio | sh -
指定版本
curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.15.0 TARGET_ARCH=x86_64 sh -
設定環境變數
在lstio資料夾底下
export CTX_CLUSTER1=$(kubectl config view -o jsonpath='{.contexts[0].name}')
export CTX_CLUSTER2=$(kubectl config view -o jsonpath='{.contexts[1].name}')
export PATH=$PWD/bin:$PATH
cluster1、2都需要建立
kubectl create --context=$CTX_CLUSTER1 ns istio-system
# 在istio folder底下
kubectl create secret generic cacerts -n istio-system --from-file=samples/certs/ca-cert.pem --from-file=samples/certs/ca-key.pem --from-file=samples/certs/root-cert.pem --from-file=samples/certs/cert-chain.pem
主遠端設定
cat <<EOF > cluster1.yaml
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
values:
global:
meshID: mesh1
multiCluster:
clusterName: cluster-primary
network: network1
EOF
istioctl install --context="${CTX_CLUSTER1}" -f cluster1.yaml
安裝主遠端east-west gateway
samples/multicluster/gen-eastwest-gateway.sh \
--mesh mesh1 --cluster cluster-primary --network network1 | \
istioctl --context="${CTX_CLUSTER1}" install -y -f -
公開control plane
kubectl apply --context="${CTX_CLUSTER1}" -n istio-system -f \
samples/multicluster/expose-istiod.yaml
公開cluster1 api server
kubectl --context="${CTX_CLUSTER1}" apply -n istio-system -f \
samples/multicluster/expose-services.yaml
為cluster2設定網路
kubectl --context="${CTX_CLUSTER2}" get namespace istio-system && \
kubectl --context="${CTX_CLUSTER2}" label namespace istio-system topology.istio.io/network=network2
為cluster2授權cluster1 api server的存取權
istioctl x create-remote-secret \
--context="${CTX_CLUSTER2}" \
--name=cluster-remote | \
kubectl apply -f - --context="${CTX_CLUSTER1}"
將cluster 東西gateway ip 設定環境變數
export DISCOVERY_ADDRESS=$(kubectl \
--context="${CTX_CLUSTER1}" \
-n istio-system get svc istio-eastwestgateway \
-o jsonpath='{.status.loadBalancer.ingress[0].ip}')
配置cluster2yaml描述檔
cat <<EOF > cluster2.yaml
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
spec:
values:
global:
meshID: mesh1
multiCluster:
clusterName: cluster2
network: network2
remotePilotAddress: ${DISCOVERY_ADDRESS}
EOF
安裝cluster2 istio
istioctl install --context="${CTX_CLUSTER2}" -f cluster2.yaml
安裝cluster2 東西gateway
samples/multicluster/gen-eastwest-gateway.sh \
--mesh mesh1 --cluster cluster-remote --network network2 | \
istioctl --context="${CTX_CLUSTER2}" install -y -f -
公開 cluster2 apiserver
kubectl --context="${CTX_CLUSTER2}" apply -n istio-system -f \
samples/multicluster/expose-services.yaml