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
    • Harbor
    • TeamCity
    • Git
      • Bitbucket
  • Coding
    • Terraform
      • GCP – Google Cloud
      • AWS – Amazon Web Service
    • Golang
    • Laravel
    • Python
    • Jquery & JavaScript
    • Selenium
  • Log & Monitor
    • Prometheus
    • Grafana
    • ELK
      • Kibana
      • Logstash
  • BareMetal
  • Toggle search form

[ArgoCD] Add other Cluster ranchers, k8s, or EKS into ArgoCD.

Posted on August 25, 2021January 4, 2023 By nim 2 Comments on [ArgoCD] Add other Cluster ranchers, k8s, or EKS into ArgoCD.

Contents

  • 1) Argocd connects Rancher
  • 2) Argocd connects EKS(aws)

1) Argocd connects Rancher

Bạn đã có sẵn 1 hệ thông ArgoCD và được install trên Cluster A(k8s) nhưng nếu bạn có cluster k8s B và cluster k8s rancher C. Vậy chẳng lẽ chạy qua cluster C và B cài lại ArgoCD.
Không ý tưởng của mình là dùng ArgoCD trên cluster A và quản lý cả cluster B và C luôn.

https://argoproj.github.io/argo-cd/user-guide/commands/argocd_cluster_add/

Ở link trên sẽ chỉ các bạn add 1 cluster k8s bằng argocd cli. Argocd tham khảo context cuả kubeconfig để biết là sẽ add cluster nào vào argocd

Nhưng vấn đề nếu bạn muốn add cluster k8s thông qua kubeconfig của Rancher, nghĩ là k8s của bạn đang được quản lý bằng rancher thì sẽ có lỗi

argocd cluster add CONTEXT-RANCHER [flags]

>>>>xuất hiện lỗi.
rpc error: code = Unauthenticated desc = the server has asked for the client to provide credentials

Giờ bạn tham khảo các bài viết sau:

https://gist.github.com/janeczku/b16154194f7f03f772645303af8e9f80

https://loadbalancing.se/2021/03/22/argocd-behind-istio-on-rancher/

https://argoproj.github.io/argo-cd/operator-manual/troubleshooting/#cluster-credentials

Giờ là cách làm của mình

Đầu tiền bạn tạo tài khoản trên rancher nếu chưa có

tạo API hay Keys cho argocd nhé
Nhận về token nó chỉ hiển thị 1 lần thôi

lấy caí url của cluster mà bạn vựa chọn ở phần token

tạo ra file secret và apply cho namespace argocd

root@work-space-u20:~/argocd# cat secret-argocd-k8s-cluster2.yaml 
apiVersion: v1
kind: Secret
metadata:
  name: racherprod-k8s-cluster2-secret
  labels:
    argocd.argoproj.io/secret-type: cluster
  namespace: argocd
type: Opaque
stringData:
  name: rancher-k8s-cluster2
  server: https://192.168.101.34/k8s/clusters/c-f8569
  config: |
    {
      "bearerToken": "token-mm945:8s77cpjmxqllrq5b45gzmrws4knn4s9tc77bbngvbf4mm8rdvkbwnw",
      "tlsClientConfig": {
        "insecure": true
      }
    }

Nếu web rancher của mình ko có ssl xanh lè nền mình để “insecure”: true

Sau khi apply thì kiểm tra:

Deploy thử thấy ăn là ok

lên racher kiểm tra

2) Argocd connects EKS(aws)

https://medium.com/@jerome.decoster/eks-argocd-multi-environments-and-multi-clusters-gitops-76aef2fc5711

Đầu tiên là list các cluster đó ra

kubectl config get-contexts
CURRENT   NAME                           CLUSTER                                                             AUTHINFO                                                               
*         multienv-infra-production      arn:aws:eks:eu-west-3:xxxxx:cluster/multienv-infra-production       arn:aws:eks:eu-west-3:xxxxx:cluster/multienv-infra-production       
          multienv-infra-staging         arn:aws:eks:eu-west-3:xxxxx:cluster/multienv-infra-staging          arn:aws:eks:eu-west-3:xxxxx:cluster/multienv-infra-staging

add cluster lên argocd bằng context name.

argocd cluster add --yes <cluster-context-name>

Kiểm tra lại trên argocd

$ argocd cluster list
SERVER                                         NAME                       VERSION  STATUS      MESSAGE
https://xxxxx.gr7.eu-west-3.eks.amazonaws.com  multienv-infra-production           Unknown     Cluster has no applications and is not being monitored.  
https://kubernetes.default.svc                 in-cluster                 1.21+    Successful
ArgoCD, Kubernetes & Container

Post navigation

Previous Post: [issue/alpine] docker 20.10.2 -> golang:1-alpine3.14 error: make: go: Operation not permitted
Next Post: [Istio/multi cluster] Install multi-cluster Istio with mode “Primary-Remote” for Kubernetes on Google Cloud Platform.

More Related Articles

[git-sync] an auto simple that pulls a git repository into a container on Kubernetes Git
[ArgoCD Image Updater] How does Argocd trigger images on Dockerhub and deploy workload on k8s automatically? ArgoCD
Hướng dẫn đưa secret của Kubernetes thành biến env của pod Kubernetes
[Kubernetes] RBAC Demo Kubernetes
[kiali/istio] Fix issue Configured: configmaps “istio” not found Isito-EnvoyFilter
[Metrics Server] Install metrics-server on Kubernetes. AWS - Amazon Web Service

Comments (2) on “[ArgoCD] Add other Cluster ranchers, k8s, or EKS into ArgoCD.”

  1. med says:
    April 21, 2022 at 1:39 pm

    If it’s EKS type of cluster you have to run cluster add command with additional flag if you are running it on same cluster you will be managing.
    argocd cluster add –in-cluster

    Reply
    1. nim says:
      April 21, 2022 at 1:57 pm

      Thank you for proposing your opinion. it’s very helpful.

      Reply

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

  • [Smartctl] Instruction check the health disk of Raspberry. January 16, 2023
  • [kubectl/Argocd] How to create a kubectl config file for serviceaccount or from the cluster secret of Argocd January 12, 2023
  • [Helm/Github] Create a public Helm chart repository with GitHub Pages January 8, 2023
  • [AWS] How to increase the disk size of a Windows EC2 machine? January 4, 2023
  • [Redis] ElastiCache-Redis Cross-Region Replication|Global DataStore January 3, 2023

Archives

  • 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
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Git
      • Bitbucket
    • Harbor
    • Jenkins
    • Spinnaker
    • TeamCity
  • Coding
    • Golang
    • Jquery & JavaScript
    • Laravel
    • Python
    • 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 © 2023 NimTechnology.