-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Declarative creation of clusters #8107
Comments
Hi @exocode, Argo CD uses secrets to represent clusters. You can find more details here https://argo-cd.readthedocs.io/en/stable/operator-manual/declarative-setup/#clusters |
@chetan-rns Thank you, I have to investigate that deeper. Nevertheless it would be really nice to have a more "simpler setup" (especially for Crossplane). Because - if I understand that correct, and please bear in mind, that I am a Argo noob - we have to "remap" a regular That opens another question to me as well another feature request if not already existing: When my cluster is created and ArgoCD has configred (somehow Gitops like) for accessing the cluster, I then do have to change ALL my Or is there an Argo-way to centrally change the server IPs (for example in a Something like this: apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
name: production
spec:
description: production deployment
serverDestinationConfigRefs: # <<< FEATURE REQUEST?
- name: "production-cluster-config-map" # <<< points to configMap containing cluster IPs That last lines avioding redundancy in configuration. Please help me to dissolve that knot in my brain. Thank you very much in advance |
@exocode you can use the cluster name instead of the IP/url instead. |
note that this kind of referencing is possible with crossplanes provider-argocd: https://doc.crds.dev/github.com/crossplane-contrib/provider-argocd/projects.argocd.crossplane.io/Project/[email protected]#spec-forProvider-destinations |
I have similar requirement. It looks right now I can only use argocd CLI to add cluster. Is there way to make it using |
This is not true. "Declarative Setup - Argo CD - Declarative GitOps CD for Kubernetes" https://argo-cd.readthedocs.io/en/stable/operator-manual/declarative-setup/#clusters |
I modified a script of @janwillies so, that my The result looks like this: apiVersion: v1
kind: Secret
metadata:
name: kubeconfig-demo-cluster
namespace: argocd
labels:
argocd.argoproj.io/secret-type: cluster
annotations:
managed-by: argocd.argoproj.io
data:
bearerToken: 'ARGOCD_USER_TOKEN_wljsdf7s&5$56' # optional
caData: >-
TFMwdExTMUNSVWR......TVU5CVkVVdExTMHRMUW89
certData: >-
TFMwdExTMUNSV.......TMHRDZz09
config: >-
eyJiZWFyZXJUb2tlbiI6IiI.......89In19
keyData: >-
TFMwdExTMUNSVWRKVGlCRlF5QlFVa2xX......FvPQ==
name: ZGVtby1jbHVzdGVy
server: aHR0cHM6Ly83NC4yMjAuMjcuMjQ3OjY0NDM=
serverName: ZGVtby1jbHVzdGVy
type: Opaque https://github.com/exocode/crossargo-sync Simply change the if a After that, your cluster is automatically listed in ArgoCD and can be consumed by AppProjects and Applications What it does not:
I know that is a bit clunky, because I am not a Go coder, but it does exaclt what I needed. Maybe some of the ArgoCD maintainers see what we try to achieve and what we need. |
@exocode I am reading your code, and wonder where the When I inspect the secrets created in my env, it looks something as below: apiVersion: v1
kind: Secret
metadata:
name: foo
namespace: argocd
labels:
argocd.argoproj.io/secret-type: cluster
annotations:
managed-by: argocd.argoproj.io
data:
config: eyJiZW...
name: bmVlZG...
server: aHR0cH...
type: Opaque And the config can be decoded as below: {
"bearerToken": "eyJhbG",
"tlsClientConfig": {
"insecure": true
}
} I don't know how to prepare the bearerToken, so that I can create the secret by myself. |
That token comes from an ArgoCD user created to access and create ArgoCD ressources for this Crossplane extension: https://github.com/crossplane-contrib/provider-argocd TLDR: ARGOCD_ADMIN_SECRET=$(kubectl view-secret argocd-initial-admin-secret -n argocd -q)
echo $ARGOCD_ADMIN_SECRET
ARGOCD_ADMIN_TOKEN=$(curl -X POST -k -H "Content-Type: application/json" --data '{"username":"admin","password":"'$ARGOCD_ADMIN_SECRET'"}' https://localhost:8443/api/v1/session | jq -r .token)
echo $ARGOCD_ADMIN_TOKEN
kubectl patch configmap/argocd-cm -n argocd --type merge -p '{"data":{"accounts.provider-argocd":"apiKey, login"}}'
kubectl patch configmap/argocd-rbac-cm -n argocd --type merge -p '{"data":{"policy.default":"role:admin"}}'
ARGOCD_PROVIDER_USER="provider-argocd"
ARGOCD_TOKEN=$(curl -s -X POST -k -H "Authorization: Bearer $ARGOCD_ADMIN_TOKEN" -H "Content-Type: application/json" https://localhost:8443/api/v1/account/$ARGOCD_PROVIDER_USER/token | jq -r .token)
echo $ARGOCD_TOKEN
kubectl create secret generic argocd-credentials -n crossplane-system --from-literal=authToken="$ARGOCD_TOKEN" |
Hi @exocode , |
Hi @sharadhirao, no, I still use a "last manual step", but my latest message shows exactly what I'm doing. It seems not that popular. |
Hi @exocode, |
I subscribe to the @exocode request, I am working on an automation and it would be very useful to have this crd. |
Close this now that Crossplane's provider-argocd can register the cluster? Demo: https://github.com/adavarski/k3d-crossplane-vcluster-playground
|
The ask in the issue is imo more that the argocd cluster secret supports a kubeconfig file so transformation to argocd format is not necessary. Crossplane is external tooling,which we do not use. |
@rouke-broersma the OP is using Crossplane and I wonder if their issue is now solved via provider-argocd. If support for kubeconfig is what is required, I think it maybe helpful to update the title and description. Or close this as a dup of #4651 ? There are a handful of issues related to cluster secrets. Most of them are old and it's difficult for me to determine what is being asked for and what remains to be done. |
Sorry you're right, I misunderstood! |
If anybody needs a full guide on how to
Here's also a full example project: https://github.com/jonashackt/crossplane-argocd |
Summary
Is there a way how to
kubeConfigSecretKeyRef: "cluster-details-my-cluster-kube-config"
?Motivation
I have the ArgoCD server running and wanna define a
Cluster
without the CLI. I wanna practice GitOps, so I have to declare and commit my ArgoCD-cluster config in Git.In the CLI I could do:
argocd cluster add
but how to do that with a Kubernetes manifest?I didn't found how to create that
Cluster
declarative. I found how to createRepositories
, andProjects
. But nothing for something likekind: cluster
. I have to manually intervent my cluster which breaks the GitOps practice.I am creating my clusters with Crossplane. Crossplane saves the
kubeconfig
of it's created cluster in aSecret
which looks like this:The
data.kubeconfig
content is a regular bas64 encodedkubeconfig
, so it's easy to decode, like this:Proposal
If that feature does not exist I propose a CRD for
kind: cluster
which can be applied bykubectl apply -f cluster.yml
How do you think this should be implemented?
Something like this:
The text was updated successfully, but these errors were encountered: