Skip to content

NimTechnology

Trình bày các công nghệ CLOUD một cách dễ hiểu.

  • Kubernetes & Container
    • Docker
    • Kubernetes
      • Ingress
      • Pod
    • Helm Chart
    • OAuth2 Proxy
    • Isito-EnvoyFilter
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Vault
    • Longhorn – Storage
    • VictoriaMetrics
    • MetalLB
    • Kong Gateway
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Argo Events
    • Spinnaker
    • Jenkins
    • Harbor
    • TeamCity
    • Git
      • Bitbucket
  • Coding
    • DevSecOps
    • Terraform
      • GCP – Google Cloud
      • AWS – Amazon Web Service
      • Azure Cloud
    • Golang
    • Laravel
    • Python
    • Jquery & JavaScript
    • Selenium
  • Log, Monitor & Tracing
    • DataDog
    • Prometheus
    • Grafana
    • ELK
      • Kibana
      • Logstash
  • BareMetal
    • NextCloud
  • Toggle search form

[Istio/multi cluster] Install multi-cluster Istio with mode “Primary-Remote” for Kubernetes on Google Cloud Platform.

Posted on August 26, 2021December 5, 2021 By nim 1 Comment on [Istio/multi cluster] Install multi-cluster Istio with mode “Primary-Remote” for Kubernetes on Google Cloud Platform.

Để cài được bài này thì bạn phải sử dụng k8s của các Cloud provider google, aws, …. vì pod 2 của 2 cluster có thể ping được với nhau (pod A của cluster A) ping (pod B của cluster B)
còn cài k8s baremetal (VM, server physical) thì ko áp dụng được bài này nhé.

Tổng hợp file ở đây

https://github.com/mrnim94/istio-multi-cluster

download source mới nhất về:

mkdir mutil-cluster-istio
cd mutil-cluster-istio/
curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.9.8 TARGET_ARCH=x86_64 sh -

Ở đây mình chọn mô hinh Install Primary-Remote

https://istio.io/latest/docs/setup/install/multicluster/primary-remote/

Chúng ta sẽ có 1 cluster primary mà nhiều cluster remote và IP LoadBabalancer của các cluster cùng lớp mạng nhé

Chúng ta gen cert ca để dùng cho các cluster

make -f Makefile.selfsigned.mk <tên bạn j cũng được>-cacerts

cd /root/mutil-cluster-istio/istio-1.9.8/tools/certs/
make -f Makefile.selfsigned.mk root-ca
make -f Makefile.selfsigned.mk nimtechnology-cacerts
Bạn sẽ thấy mớ file

Dump file operator cho primary

/root/mutil-cluster-istio/istio-1.9.8/bin/istioctl profile dump default > /root/mutil-cluster-istio/istio-operator-1.9.8-cluster1-primary.yaml

giờ sửa file màu đó là chỗ các bạn cần thêm nhé:

Thực hiện gen ra file manifest để apply trên trên k8s

mkdir istio-primary
/root/mutil-cluster-istio/istio-1.9.8/bin/istioctl manifest generate -f /root/mutil-cluster-istio/istio-operator-1.9.8-cluster1-primary.yaml > /root/mutil-cluster-istio/istio-primary/istio-primary-cluster1-1.9.8.yaml

Ý trước khi apply làm 2 bước này trước

kubectl config get-contexts
Mình đánh dấu cho các bạn hiểu
>>>>tạo ns
kubectl create ns istio-system

>>>> tạo secret
cd /root/mutil-cluster-istio/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
đã tạo thành công secret

à trên cluster primary mình đã cài sẵn metalLB rồi nhé

giờ apply file /root/mutil-cluster-istio/istio-primary/istio-primary-cluster1-1.9.8.yaml

Lưu ý ở bước này apply mà istiod-1-9-8 ok mà istio-ingressgateway bị lỗi vào báo CA root j đó thì bạn cần xoá hết istio-primary và chạy lại câu lệnh gen cert ca và xoá tạo lại secret khách nhé

Như này là đã thành công primary
kubectl label namespace default istio-injection- istio.io/rev=1-9-7 --overwrite

Rồi redeploy 1 app xem nó proxy ko nhé

Như này là primary đã ok

Con đó được gọi là eastwestgateway nó là 1 cánh cổng giúp cho istio remote nói chuyện với istio primary

cd /root/mutil-cluster-istio/
mkdir eastwest-gateway

>>>gen file operator cho eastwest-gateway
----
bash /root/mutil-cluster-istio/istio-1.9.8/samples/multicluster/gen-eastwest-gateway.sh --mesh mesh1 --cluster cluster1 --network network1 --revision 1-9-8 > /root/mutil-cluster-istio/istio-eastwest-gateway-operator-1.9.8-default.yaml

File chúng ta chưa cần sửa operator giờ gen file manifest

/root/mutil-cluster-istio/istio-1.9.8/bin/istioctl manifest generate -f /root/mutil-cluster-istio/istio-eastwest-gateway-operator-1.9.8-default.yaml > /root/mutil-cluster-istio/eastwest-gateway/istio-eastwest-gateway-1.9.8.yaml

Giờ bạn apply istio-eastwest-gateway-1.9.8.yaml ở primary nhé

Giờ chúng ta cần Expose the control plane in cluster1 và gt, vs và dr

cp /root/mutil-cluster-istio/istio-1.9.8/samples/multicluster/expose-istiod.yaml /root/mutil-cluster-istio/eastwest-gateway/

Giờ mới bắt đầu sửa vì chúng ta có chạy revision cho primary và service istio đang là

giờ apply file expose

Enable API Server Access to cluster2 , bạn sử dụng context để istioctl gen nhé

/root/mutil-cluster-istio/istio-1.9.8/bin/istioctl x create-remote-secret \
    --context=k0s-cluster2 \
    --name=cluster2 > /root/mutil-cluster-istio/eastwest-gateway/istio-remote-secret-cluster2.yaml

Giờ apply secret trên primary và sem log

Nếu ko thấy lỗi lẫm j là ngon

Nếu không may bạn gặp lỗi này “reflector.go:167: Failed to watch ————– x509: certificate signed by unknown authority” và –context của bạn không phải trọ thẳng vào k8s mà lại trỏ vào rancher
thì bạn mở file secret lên nhé:

Rồi giờ mấy thông tin rancher lấy ở đâu
Nếu bạn để ý thì config này sẽ có điểm tương đồng với file secret nhé

Khi thêm secret thành công thì khi bạn qua check cluster 2 thấy nó sẽ tạo ns

quay lại cluster 1 thư redeploy app bên ns default sem có lỗi không và quan sát log

không lỗi lần j cả

Câu lênh bên dưới dùng để lấy ip LB của eastwest gateway

export DISCOVERY_ADDRESS=$(kubectl \
    --context="${CTX_CLUSTER1}" \
    -n istio-system get svc istio-eastwestgateway \
    -o jsonpath='{.status.loadBalancer.ingress[0].ip}')

GIờ tiến hành dump operator remote với profile remote

/root/mutil-cluster-istio/istio-1.9.8/bin/istioctl profile dump remote > /root/mutil-cluster-istio/istio-operator-1.9.8-cluster2-remote.yaml

nó có hiện 2021-08-26T07:39:27.140673Z info proto: tag has too few fields: “-“ thì chả sao nhé
giờ sửa file operator

Màu đỏ các các thứ bạn cần thêm

Bạn để ý remotePilotAddress: “192.168.101.222” là đọan mà ở trên mình các bạn chú ý đó

nếu có bạn thắc mắc là sao mình ko đánh revision cho remote thì mình để ý dù mình đã chỉnh revision và fix validate rồi nhưng nó vẫn bị lỗi validate nên thôi khỏi set revision cho remote luôn

This image has an empty alt attribute; its file name is image-104.png
mkdir istio-remote
/root/mutil-cluster-istio/istio-1.9.8/bin/istioctl manifest generate -f /root/mutil-cluster-istio/istio-operator-1.9.8-cluster2-remote.yaml > /root/mutil-cluster-istio/istio-remote/istio-remote-cluster2-1.9.8.yaml

Sau khi manifest đừng vội apply nhé cần là

  • install metallb bên cluster 2
  • create secret giống như cluster 1
cd /root/mutil-cluster-istio/istio-1.9.8/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 istio-remote-cluster2-1.9.8.yaml lên cluster 2 được òi đó

dòng lỗi này bên istio-ingress cluster 2

Với lỗi trên bên remote cluster thì bạn xoá istio-remote, rồi xoá cacerts

rồi tạo lại cacerts và install lại istio remote

Nếu hết lỗi trên mà lỗi

Hoặc lỗi này:

This image has an empty alt attribute; its file name is image-105.png

bạn xoá secret istio-remote-secret-cluster2 bên primary rồi gen và create lại

sau khi xoá các kiểu rồi và may mắn bạn nhận được ntn

Nên ăn mừng nhé.

chúng ta vào coi thử remote có cài j hay

>>>>>>> các câu lệnh sư tầm

root@work-space-u20:~/istio-1.9.8/bin# ./istioctl ps --context=local
NAME                                                    CDS        LDS        EDS        RDS          ISTIOD                            VERSION
helloworld-v1-67948495c5-fs4kg.sample                   SYNCED     SYNCED     SYNCED     SYNCED       istiod-1-9-8-6b9448d57f-fhv2s     1.9.8
helloworld-v2-7d9bb859fc-2fpxq.sample                   SYNCED     SYNCED     SYNCED     SYNCED       istiod-1-9-8-6b9448d57f-fhv2s     1.9.8
istio-eastwestgateway-64f997948b-526w5.istio-system     SYNCED     SYNCED     SYNCED     NOT SENT     istiod-1-9-8-6b9448d57f-fhv2s     1.9.8
istio-ingressgateway-66fddc5b54-k244b.istio-system      SYNCED     SYNCED     SYNCED     SYNCED       istiod-1-9-8-6b9448d57f-fhv2s     1.9.8
istio-ingressgateway-79575d8bf6-vdk4r.istio-system      SYNCED     SYNCED     SYNCED     SYNCED       istiod-1-9-8-6b9448d57f-fhv2s     1.9.8
sleep-5585bb9cd5-lgpw5.sample                           SYNCED     SYNCED     SYNCED     SYNCED       istiod-1-9-8-6b9448d57f-fhv2s     1.9.8
sleep-95967c8cb-2hh8c.sample                            SYNCED     SYNCED     SYNCED     SYNCED       istiod-1-9-8-6b9448d57f-fhv2s     1.9.8



root@work-space-u20:~/istio-1.9.8/bin# ./istioctl pc ep --context=k0s-cluster2 sleep-f49dbf874-7cwcn.sample | grep hello
10.244.194.123:5000              HEALTHY     OK                outbound|5000||helloworld.sample.svc.cluster.local
10.245.61.167:5000               HEALTHY     OK                outbound|5000||helloworld.sample.svc.cluster.local
Isito-EnvoyFilter, Kubernetes & Container

Post navigation

Previous Post: [ArgoCD] Add other Cluster ranchers, k8s, or EKS into ArgoCD.
Next Post: [Postgresql] Install Postgresql in Kubernetes by helm.

More Related Articles

[istio] There are a few problems inside mode “POD to POD” when using Istio Isito-EnvoyFilter
[Istio] Workload injected Istio that can’t connect Database(Redis, PostgreSQL) – excludeOutboundPorts or excludeIPRanges Isito-EnvoyFilter
[AWS] Creating EKS windows on AWS and Running windows pods AWS - Amazon Web Service
[Istio-Multi Cluster] Tutorial is very detailed to install Primary-Remote on different networks Isito-EnvoyFilter
[istio] Sử dụng istio-operator và istioctl để cài đặt Istio Isito-EnvoyFilter
[Case dị – istio] Những case khó đỡ khiến chúng ra suy nghĩ là istio có chạy được hay ko? Isito-EnvoyFilter

Comment (1) on “[Istio/multi cluster] Install multi-cluster Istio with mode “Primary-Remote” for Kubernetes on Google Cloud Platform.”

  1. Pingback: [Istio-Multi Cluster] Tutorial is very detailed to install Primary-Remote on different networks – NimTechnology

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Tham Gia Group DevOps nhé!
Để Nim có nhiều động lực ra nhiều bài viết.
Để nhận được những thông báo mới nhất.

Recent Posts

  • [Azure] The subscription is not registered to use namespace ‘Microsoft.ContainerService’ May 8, 2025
  • [Azure] Insufficient regional vcpu quota left May 8, 2025
  • [WordPress] How to add a Dynamic watermark on WordPress. May 6, 2025
  • [vnet/Azure] VNet provisioning via Terraform. April 28, 2025
  • [tracetcp] How to perform a tracert command using a specific port. April 3, 2025

Archives

  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Categories

  • BareMetal
    • NextCloud
  • CI/CD
    • Argo Events
    • ArgoCD
    • ArgoWorkflows
    • Git
      • Bitbucket
    • Harbor
    • Jenkins
    • Spinnaker
    • TeamCity
  • Coding
    • DevSecOps
    • Golang
    • Jquery & JavaScript
    • Laravel
    • NextJS 14 & ReactJS & Type Script
    • Python
    • Selenium
    • Terraform
      • AWS – Amazon Web Service
      • Azure Cloud
      • GCP – Google Cloud
  • Kubernetes & Container
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Docker
    • Helm Chart
    • Isito-EnvoyFilter
    • Kong Gateway
    • Kubernetes
      • Ingress
      • Pod
    • Longhorn – Storage
    • MetalLB
    • OAuth2 Proxy
    • Vault
    • VictoriaMetrics
  • Log, Monitor & Tracing
    • DataDog
    • ELK
      • Kibana
      • Logstash
    • Fluent
    • Grafana
    • Prometheus
  • Uncategorized
  • Admin

Copyright © 2025 NimTechnology.