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://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ó
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)
Đầ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
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
Thank you for proposing your opinion. it’s very helpful.