Isito version 1.10.4 mình cài multi cluster nhưng chả lỗi j mà cũng chả chạy Cross-Cluster Traffic. Nếu anh em chạy multi cluster trên version 1.10.4 cần chú ý check kĩ nhé.
Ở con console đảm bảo là đã kết nối đến cả 2 cluster
kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
dev dev dev
k0s-cluster2 k0s-cluster2 admin default
* local local local
kubectl get ns --context=k0s-cluster2
NAME STATUS AGE
default Active 8h
istio-system Active 12m
kube-node-lease Active 8h
kube-public Active 8h
kube-system Active 8h
Trên cluster 1 tạo ns và thêm network cho label
kubectl create ns istio-system
kubectl --context=local label namespace istio-system topology.istio.io/network=network1
kubectl describe ns istio-system
Trên con console tạo 1 thư mục để làm việc
mkdir canary-upgrade-istio-cluster
cd canary-upgrade-istio-cluster
Kiểm tra version mới nhất là bao nhiêu và download về
https://github.com/istio/istio/releases/
>>>>download source cài istio
curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.9.8 TARGET_ARCH=x86_64 sh -
root@work-space-u20:~/canary-upgrade-istio-cluster# ls
istio-1.9.8
Giờ chúng gen ca cert để cho các cluster nói chuyện với nhaumake -f Makefile.selfsigned.mk <tên bạn j cũng được>-cacerts
cd /root/canary-upgrade-istio-cluster/istio-1.9.8/tools/certs/
make -f Makefile.selfsigned.mk root-ca
make -f Makefile.selfsigned.mk nimtechnology-cacerts
Dump file operator cho primary(cluster1)
/root/canary-upgrade-istio-cluster/istio-1.9.8/bin/istioctl profile dump default \
> /root/canary-upgrade-istio-cluster/istio-operator-1.9.8-cluster1-primary.yaml
Ở bài lần đầu mình sẽ không đánh revision cho operator nữa thấy nó cũng ko hữu ích lắm
meshID: mesh1
multiCluster:
clusterName: "cluster1"
enabled: true
network: "network1"
omitSidecarInjectorConfigMap: false
oneNamespace: false
operatorManageWebhooks: false
pilotCertProvider: istiod
priorityClassName: ""
proxy:
autoInject: disabled
save lại và gen manifest isito cluster 1
cd /root/canary-upgrade-istio-cluster/
mkdir istio-primary
/root/canary-upgrade-istio-cluster/istio-1.9.8/bin/istioctl manifest generate \
-f /root/canary-upgrade-istio-cluster/istio-operator-1.9.8-cluster1-primary.yaml \
> /root/canary-upgrade-istio-cluster/istio-primary/istio-primary-cluster1-1.9.8.yaml
Đừng apply vội nhé mà create secret ca certs cho cluster 1 đã
>>>> tạo secret
cd /root/canary-upgrade-istio-cluster/istio-1.9.8/tools/certs/
kubectl create secret generic cacerts -n istio-system --context=local \
--from-file=nimtechnology/ca-cert.pem \
--from-file=nimtechnology/ca-key.pem \
--from-file=nimtechnology/root-cert.pem \
--from-file=nimtechnology/cert-chain.pem
Còn 1 lưu ý là do mình cái ở on-premise. mà isito này cần tạo service loadbalancer
nên mình cần cài đặt metallb ở cả 2 cluster và trước khi cài istio
Đã chuẩn bị đẩy đủ rồi thì apply file istio-primary-cluster1-1.9.8.yaml với ns istio-system
Kiêm tra log sem có bị bất thường
Giờ thử deploy 1 app trên 1 namespace”default” xem nó auto inject sidecar istio ko?
kubectl label namespace default istio-injection=enabled
kubectl describe namespace default
cài đặt east-west gateway in cluster1
cd /root/canary-upgrade-istio-cluster/
mkdir eastwest-gateway-cluster1
>>>gen file operator cho eastwest-gateway
----
bash /root/canary-upgrade-istio-cluster/istio-1.9.8/samples/multicluster/gen-eastwest-gateway.sh \
--mesh mesh1 --cluster cluster1 --network network1 \
> /root/canary-upgrade-istio-cluster/istio-eastwest-gateway-operator-1.9.8-default.yaml
Vì chúng ta ko gắn revision cũng chả cần chỉnh file operator làm gi?
Gen file manifest thôi
/root/canary-upgrade-istio-cluster/istio-1.9.8/bin/istioctl manifest generate \
-f /root/canary-upgrade-istio-cluster/istio-eastwest-gateway-operator-1.9.8-default.yaml \
> /root/canary-upgrade-istio-cluster/eastwest-gateway-cluster1/istio-eastwest-gateway-1.9.8-c1-p.yaml
Giờ bạn apply istio-eastwest-gateway-1.9.8.yaml ở primary nhé
Giờ kiểm tra lại ip LoadBalancer của 2 istio
Expose the control plane in cluster1
Copy file có sẵn gateway và virtualservice
cp /root/canary-upgrade-istio-cluster/istio-1.9.8/samples/multicluster/expose-istiod.yaml \
/root/canary-upgrade-istio-cluster/eastwest-gateway-cluster1/
Expose services in cluster1
cp /root/canary-upgrade-istio-cluster/istio-1.9.8/samples/multicluster/expose-services.yaml \
/root/canary-upgrade-istio-cluster/eastwest-gateway-cluster1/
Giờ gen secret với mục địch là istio-primary control cluster k0s-cluster2 thông qua Enable API Server Access to cluster2
Bước này nó sử dụng thông tin trong kubeconfig của cluster 2
/root/canary-upgrade-istio-cluster/istio-1.9.8/bin/istioctl x create-remote-secret \
--context=k0s-cluster2 \
--name=cluster2 > /root/canary-upgrade-istio-cluster/eastwest-gateway-cluster1/istio-remote-secret-cluster2.yaml
Giờ qua action cluster 2:
-tạo namespace và tạo label network2
kubectl --context=k0s-cluster2 create ns istio-system
kubectl --context=k0s-cluster2 get namespace istio-system && \
kubectl --context=k0s-cluster2 label namespace istio-system topology.istio.io/network=network2
kubectl --context=k0s-cluster2 get namespace istio-system
Giờ chúng ta cần IP Loadbalancer của istio-eastwestgateway
export DISCOVERY_ADDRESS=$(kubectl \
--context=local \
-n istio-system get svc istio-eastwestgateway \
-o jsonpath='{.status.loadBalancer.ingress[0].ip}')
root@work-space-u20:~/mutil-cluster-istio-diff-net# echo $DISCOVERY_ADDRESS
192.168.101.223
Giờ dump file operator cho cluster2 remote
/root/canary-upgrade-istio-cluster/istio-1.9.8/bin/istioctl profile dump remote \
> /root/canary-upgrade-istio-cluster/istio-operator-1.9.8-cluster2-remote.yaml
Giờ chúng ta cần sửa file operator cho cluster 2
meshID: mesh1
multiCluster:
clusterName: cluster2
enabled: true
network: network2
remotePilotAddress: "192.168.101.222"
omitSidecarInjectorConfigMap: false
oneNamespace: false
operatorManageWebhooks: false
pilotCertProvider: istiod
priorityClassName: ""
proxy:
autoInject: disabled
Giờ gen manifest cho cluster 2
mkdir /root/canary-upgrade-istio-cluster/istio-remote
/root/canary-upgrade-istio-cluster/istio-1.9.8/bin/istioctl manifest generate \
-f /root/canary-upgrade-istio-cluster/istio-operator-1.9.8-cluster2-remote.yaml \
> /root/canary-upgrade-istio-cluster/istio-remote/istio-remote-cluster2-1.9.8.yaml
CHưa vội apply file istio-remote-cluster2-1.10.4.yaml
Kiểm tra cluster 2 đã có metallb chưa nhé?
rồi create secret ca certs cho cluster 2 – remote nhé
cd /root/canary-upgrade-istio-cluster/istio-1.10.4/tools/certs/
kubectl create secret generic cacerts -n istio-system --context=k0s-cluster2 \
--from-file=nimtechnology/ca-cert.pem \
--from-file=nimtechnology/ca-key.pem \
--from-file=nimtechnology/root-cert.pem \
--from-file=nimtechnology/cert-chain.pem
Giờ thì apply file istio-remote-cluster2-1.10.4.yaml
Giờ kiểm tra log của isito
/root/canary-upgrade-istio-cluster/istio-1.9.8/bin/istioctl ps | grep 1-9-8
Install the east-west gateway in cluster2
cd /root/canary-upgrade-istio-cluster/
mkdir eastwest-gateway-cluster2
>>>gen file operator cho eastwest-gateway
----
bash /root/canary-upgrade-istio-cluster/istio-1.9.8/samples/multicluster/gen-eastwest-gateway.sh \
--mesh mesh1 --cluster cluster2 --network network2 \
> /root/canary-upgrade-istio-cluster/istio-eastwest-gateway-remote-operator-1.9.8-default.yaml
Giờ gen file manifest eastwest gateway cho cluster (remote)
/root/canary-upgrade-istio-cluster/istio-1.9.8/bin/istioctl manifest generate \
-f /root/canary-upgrade-istio-cluster/istio-eastwest-gateway-remote-operator-1.9.8-default.yaml \
> /root/canary-upgrade-istio-cluster/eastwest-gateway-cluster2/istio-eastwest-gateway-1.9.8-c2-r.yaml
Expose services in cluster2
cp /root/canary-upgrade-istio-cluster/istio-1.9.8/samples/multicluster/expose-services.yaml \
/root/canary-upgrade-istio-cluster/eastwest-gateway-cluster2/
Hướng dẫn check nè dễ lắm
https://istio.io/latest/docs/setup/install/multicluster/verify/
Giờ thực hiện Canary sem sao.
Download istio bạn mới nhất về
curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.11.3 TARGET_ARCH=x86_64 sh -
Dump file operator canary cho cluster 1
/root/canary-upgrade-istio-cluster/istio-1.11.3/bin/istioctl profile dump default \
> /root/canary-upgrade-istio-cluster/istio-operator-1.11.3-cluster1-canary.yaml
>>>>>
profile: default
tag: 1.11.3
revision: canary
values:
base:
>>>>>>>>
logAsJson: false
logging:
level: default:info
meshNetworks: {}
mountMtlsCerts: false
meshID: mesh1
multiCluster:
clusterName: "cluster1"
enabled: true
network: "network1"
omitSidecarInjectorConfigMap: false
oneNamespace: false
operatorManageWebhooks: false
pilotCertProvider: istiod
priorityClassName: ""
proxy:
autoInject: disabled
clusterDomain: cluster.local
Gen file manifest thôi
cd /root/canary-upgrade-istio-cluster/
mkdir istio-canary
/root/canary-upgrade-istio-cluster/istio-1.11.3/bin/istioctl manifest generate \
-f /root/canary-upgrade-istio-cluster/istio-operator-1.11.3-cluster1-canary.yaml \
> /root/canary-upgrade-istio-cluster/istio-canary/istio-primary-cluster1-1.11.3.yaml
Mình có để ý validation thường nếu chỉnh review là 1-11-3 thì vào ValidatingWebhookConfiguration để chỉnh cho nó trỏ đến istiod-1-11-3
Con nếu để canary thì ko cần chỉnh vì isito họ care cho mình rồi, Như ảnh bên dưới.
Giờ apply và quan sát
Giờ đổi cho deploy quá istio-proxy mới.
kubectl label namespace sample istio-injection- istio.io/rev=canary --overwrite --context=local
Với eastwest-gateway anh em mình ko cần canary deploy in-place luôn
bash /root/canary-upgrade-istio-cluster/istio-1.11.3/samples/multicluster/gen-eastwest-gateway.sh \
--mesh mesh1 --cluster cluster1 --network network1 \
> /root/canary-upgrade-istio-cluster/istio-eastwest-gateway-operator-1.11.3-default.yaml
Gen file manifest
/root/canary-upgrade-istio-cluster/istio-1.11.3/bin/istioctl manifest generate \
-f /root/canary-upgrade-istio-cluster/istio-eastwest-gateway-operator-1.11.3-default.yaml \
> /root/canary-upgrade-istio-cluster/eastwest-gateway-cluster1/istio-eastwest-gateway-1.11.3-c1-p.yaml
sau đó thì mình phát hiện lỗi khá ngáo
Mình fát hiện ra istio-eastwest-gateway ở version 1.11+ đã thay đổi kha kha
Thấy bỏ khá nhiều . Lúc deploy lỗi liền
có vẻ ở isito 1.11.3 chưa ready cho istio-eastwest-gateway
Giờ vẫn muốn nâng cấp thì làm sao
Sau khi change xong thấy Cross-Cluster Traffic vẫn chạy ngon lành.
Giờ qua canary cho remote
Dump file operator canary cho istio remote cluster2
/root/canary-upgrade-istio-cluster/istio-1.11.3/bin/istioctl profile dump remote \
> /root/canary-upgrade-istio-cluster/istio-operator-1.11.3-cluster2-remote-canary.yaml
Giờ sửa file oprator
meshConfig:
defaultConfig:
proxyMetadata: {}
enablePrometheusMerge: true
profile: remote
tag: 1.11.3
revision: canary
values:
base:
>>>>>>>
jwtPolicy: third-party-jwt
logAsJson: false
logging:
level: default:info
meshNetworks: {}
mountMtlsCerts: false
meshID: mesh1
multiCluster:
clusterName: cluster2
enabled: true
network: network2
remotePilotAddress: "192.168.101.222"
omitSidecarInjectorConfigMap: false
oneNamespace: false
operatorManageWebhooks: false
pilotCertProvider: istiod
priorityClassName: ""
proxy:
autoInject: disabled
clusterDomain: cluster.local
componentLogLevel: misc:error
mkdir /root/canary-upgrade-istio-cluster/istio-remote-canary
/root/canary-upgrade-istio-cluster/istio-1.11.3/bin/istioctl manifest generate \
-f /root/canary-upgrade-istio-cluster/istio-operator-1.11.3-cluster2-remote-canary.yaml \
> /root/canary-upgrade-istio-cluster/istio-remote-canary/istio-remote-cluster2-1.11.3.yaml
Apply thôi
info ads ADS: "@" istio-ingressgateway-758d9d5bbf-6sjl4.istio-system-67 terminated rpc error: code = Canceled desc = context canceled
2021-10-02T18:44:40.300350Z warning envoy config StreamSecrets gRPC config stream closed: 2, failed to generate secret for default: failed to generate workload certificate: create certificate: rpc error: code = Unavailable desc = connection error: desc = "transport: authentication handshake failed: x509: certificate is valid for istiod-remote.istio-system.svc, istiod.istio-system.svc, istio-pilot.istio-system.svc, not istiod-canary.istio-system.svc"
Để fix lỗi trên:
Quay lại file operator và sửa lại:
pilot:
autoscaleEnabled: true
autoscaleMax: 5
autoscaleMin: 1
configMap: true
cpu:
targetAverageUtilization: 80
enableProtocolSniffingForInbound: true
enableProtocolSniffingForOutbound: true
env:
ISTIOD_CUSTOM_HOST: istiod-canary.istio-system.svc
image: pilot
keepaliveMaxServerConnectionAge: 30m
Rồi gen lại file manifest và apply
Check log đã ngon nghẻ và Cross-Cluster Traffic vẫn đang chạy ầm ầm
Giơ upgrade version istio-eastwestgateway-remote
KHông gen cái j cả edit live manifest thôi
while true; do curl -sS helloworld.sample:5000/hello; echo; sleep 0.5; done
Này giờ chưa app bên Cluster2 sang isito-remote-canary
kubectl label namespace sample istio-injection- istio.io/rev=canary --overwrite --context=k0s-cluster2
Giờ bạn move tất cả workload đang sử dụng istio version cũ sang version canary:
– Bước 1: change label ns space:
kubectl label namespace sample istio-injection- istio.io/rev=canary --overwrite --context=local
kubectl label namespace sample istio-injection- istio.io/rev=canary --overwrite --context=k0s-cluster2
– Bước 2: Bạn tiến hành redeploy lại các workload, để inject intio-proxy version cho workload
Kiểm tra anh sem có workload nào ở version isito cũ không?
istio-1.11.3/bin/istioctl version --context=local
Giờ copy file operator của canary và xoá dòng revision đi nhé.
cd canary-upgrade-istio-cluster
cp istio-operator-1.11.3-cluster1-canary.yaml istio-operator-1.11.3-cluster1-primary.yaml
cp istio-operator-1.11.3-cluster2-remote-canary.yaml istio-operator-1.11.3-cluster2-remote.yaml
Gen manifest cho istio primary cluster 1
/root/canary-upgrade-istio-cluster/istio-1.11.3/bin/istioctl manifest generate \
-f /root/canary-upgrade-istio-cluster/istio-operator-1.11.3-cluster1-primary.yaml \
> /root/canary-upgrade-istio-cluster/istio-primary/istio-primary-cluster1-1.11.3.yaml
Giờ gen tiếp file manifest cho Istio remote cluster 2
mkdir /root/canary-upgrade-istio-cluster/istio-remote
/root/canary-upgrade-istio-cluster/istio-1.11.3/bin/istioctl manifest generate \
-f /root/canary-upgrade-istio-cluster/istio-operator-1.11.3-cluster2-remote.yaml \
> /root/canary-upgrade-istio-cluster/istio-remote/istio-remote-cluster2-1.11.3.yaml
Giờ apply 2 manifest cho đúng với cluster tương ứng,
Lúc này chúng ta apply đè lên version cũ
Sau khi xoá xong manifest canary thì tiến anh xoá app thoi hướng dẫn bên dưới
Giờ quá app istio xoá manifest dấu (x)
Xong bạn lập ở bên các cluster remote nhé
Giờ app istio xanh đét
while true; do curl -sS helloworld.sample:5000/hello; echo; sleep 0.5; done
https://istio.io/latest/docs/setup/install/multicluster/verify/
Links chứa file yaml:
https://github.com/mrnim94/istio-multi-cluster/tree/main/canary-upgrade-istio-cluster