Open bigkevmcd opened 11 months ago
This was generated with a GitopsCluster manually added to the WGE management cluster:
apiVersion: gitops.weave.works/v1alpha1
kind: GitopsCluster
metadata:
name: test
namespace: default
The spec is missing as well as any labels, which could be causing this issue.
The in-cluster object was:
apiVersion: gitops.weave.works/v1alpha1
kind: GitopsCluster
metadata:
creationTimestamp: '2023-11-23T13:56:27Z'
generation: 1
labels:
kustomize.toolkit.fluxcd.io/name: flux-system
kustomize.toolkit.fluxcd.io/namespace: flux-system
managedFields:
- apiVersion: gitops.weave.works/v1alpha1
fieldsType: FieldsV1
fieldsV1:
f:metadata:
f:labels:
f:kustomize.toolkit.fluxcd.io/name: {}
f:kustomize.toolkit.fluxcd.io/namespace: {}
manager: kustomize-controller
operation: Apply
time: '2023-11-23T13:56:27Z'
name: test
namespace: default
resourceVersion: '148517'
uid: a52a145d-d278-4ecc-980c-0b24f32139a2
selfLink: /apis/gitops.weave.works/v1alpha1/namespaces/default/gitopsclusters/test
which of course has labels, but still no spec.
Two things to fix then...
I added the spec to the object and it didn't fix the issue, I still get the same error.
I created an empty secret for the kubeconfig reference, in case it needed to exist, but I still get the same error.
I added data for a kubeconfig to the secret, same error.
I added an empty secret for certs too, but the same error.
I haven't found a way to avoid it yet, so no clue what is wrong here. Something missing probably. I tried with debug, but I don't get much more information, just that it detects the GitopsCluster object exists, then I hit the error.
If it's the same error, it's failing here: https://github.com/weaveworks/weave-gitops-enterprise/blob/498fa43fe1a6e5515ba8a2e70c2ffbbe8a6a3301/pkg/cluster/connector/secret.go#L38
Which implies that the secretRef
isn't configured?
Can you paste the YAML for your GitopsCluster
?
For reference, here is the GitopsCluster object with the reference added.
apiVersion: gitops.weave.works/v1alpha1
kind: GitopsCluster
metadata:
creationTimestamp: '2023-11-23T13:56:27Z'
generation: 2
labels:
kustomize.toolkit.fluxcd.io/name: flux-system
kustomize.toolkit.fluxcd.io/namespace: flux-system
managedFields:
- apiVersion: gitops.weave.works/v1alpha1
fieldsType: FieldsV1
fieldsV1:
f:metadata:
f:labels:
f:kustomize.toolkit.fluxcd.io/name: {}
f:kustomize.toolkit.fluxcd.io/namespace: {}
f:spec:
f:capiClusterRef:
f:name: {}
manager: kustomize-controller
operation: Apply
time: '2023-11-23T17:07:15Z'
name: test
namespace: default
resourceVersion: '193300'
uid: a52a145d-d278-4ecc-980c-0b24f32139a2
selfLink: /apis/gitops.weave.works/v1alpha1/namespaces/default/gitopsclusters/test
spec:
capiClusterRef:
name: test
Ahh...you don't need to connect a capi cluster...it just "works"?
But we can definitely detect this and improve the message.
Of course it does, I copied it from another GitopsCluster object. I have now added the correct secretRef and removed the extra secrets I manually created. That has solved the problem, so the missing secretRef was the issue.
Output now:
gitops-ee connect cluster test
{"level":"info","ts":1700760829.72523,"logger":"gitops","caller":"connector/connector.go:117","msg":"Successfully connected cluster","cluster":{"name":"test","namespace":"default"}}
We'll definitely improve the errors around this.
this cluster does not reference a secret - can only connect clusters that reference a secret
Describe the bug
To Reproduce
Actual behaviour
Expected behaviour
Additional context