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
    • Helm Chart
    • Isito-EnvoyFilter
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Vault
    • Longhorn – Storage
    • VictoriaMetrics
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Spinnaker
    • Jenkins
  • Coding
    • Terraform
      • GCP – Google Cloud
      • AWS – Amazon Web Service
    • Golang
    • Laravel
    • Jquery & JavaScript
    • Git
    • Selenium
  • Log & Monitor
    • Prometheus
    • Grafana
    • ELK
      • Kibana
      • Logstash
  • BareMetal
  • 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 rancher or k8s into ArgoCD.
Next Post: [Postgresql] Install Postgresql in Kubernetes by helm.

More Related Articles

[Istio] Fix lỗi validationController khi sử dụng istio-operator [revision] cài đặt istio. Isito-EnvoyFilter
[Istio] Authenticator KubeJWTAuthenticator at index 1 got error: failed to validate the JWT from cluster – When you update K8s version 1.20 to 1.21 Isito-EnvoyFilter
[Harbor] Cài đặt Private Dockerhub – Harbor trên k8s bằng helm – repo Binami Kubernetes & Container
[Isito] FIX status 503 – SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED Isito-EnvoyFilter
[Kustomize] Tìm hiểu về Kustomize tool cho k8s, có thể dùng cho ArgoCD. Kubernetes & Container
[Minio] Install MinIO on Kubernetes through minio-operator Kubernetes & Container

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

  • Protected: My Assignment  June 24, 2022
  • [Spinnaker] Spinnaker writes too many logs – Reduce spinnaker log level June 22, 2022
  • [Jenkins] Jobs will be created automatically by Jenkins Job Builder June 20, 2022
  • [Postgresql] Install postgresql client and trying a few command postgresql. June 20, 2022
  • [Mount/Nextcloud] How do you mount a hard disk that was used windows into Linux. June 19, 2022

Archives

  • 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
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Jenkins
    • Spinnaker
  • Coding
    • Git
    • Golang
    • Jquery & JavaScript
    • Laravel
    • Selenium
    • Terraform
      • AWS – Amazon Web Service
      • GCP – Google Cloud
  • Kubernetes & Container
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Docker
    • Helm Chart
    • Isito-EnvoyFilter
    • Kubernetes
      • Ingress
    • Longhorn – Storage
    • Vault
    • VictoriaMetrics
  • Log & Monitor
    • ELK
      • Kibana
      • Logstash
    • Grafana
    • Prometheus
  • Uncategorized
  • Admin

Copyright © 2022 NimTechnology.