Skip to content

Commit

Permalink
fix(delete): recreate cluster when deleted via argocd-ui
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Haar <[email protected]>
  • Loading branch information
haarchri committed Nov 29, 2023
1 parent 22cda7d commit 1324b37
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 17 deletions.
36 changes: 30 additions & 6 deletions examples/cluster/cluster-kubeconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,38 @@
apiVersion: cluster.argocd.crossplane.io/v1alpha1
kind: Cluster
metadata:
name: example-cluster-kubeconfig
name: upbound-saas-byoc
spec:
forProvider:
name: example-cluster-kubeconfig
name: upbound-saas-byoc
config:
kubeconfigSecretRef:
name: cluster-conn
namespace: crossplane-system
name: upbound-saas-byoc
namespace: upbound-system
key: kubeconfig
providerConfigRef:
name: argocd-provider
---
apiVersion: v1
kind: Secret
metadata:
name: upbound-saas-byoc
namespace: upbound-system
type: Opaque
stringData:
kubeconfig: |
apiVersion: v1
clusters:
- cluster:
server: https://proxy.upbound.io/v1/controlPlanes/upbound/saas-byoc/k8s
name: upbound-upbound-saas-byoc
contexts:
- context:
cluster: upbound-upbound-saas-byoc
user: upbound-upbound-saas-byoc
name: upbound-upbound-saas-byoc
current-context: upbound-upbound-saas-byoc
kind: Config
preferences: {}
users:
- name: upbound-upbound-saas-byoc
user:
token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjMmJlMTVjNi1hZWIwLTRkNDQtYTMyZi1kMWYwZWIxNDhmYTkiLCJzdWIiOiJ1c2VyfDMwOTYifQ.fEgH3KCWVUW3fs9t2nO1NR0s5DUu9c9EgKinQaLrEQCWd9-9gyWeWTmEDMqBkDQThP-r5TqsuWuXxXnOhEfLBJE_RBwAphKqbcmGwxDokhYycgXWwW5dzGMLLX08OwnR9xIPHKfaBbawA-cIDZrqyE516qcb5RqHmfzOW8ouDdjBCUwOkvjXYFTu8zRkPaVZHo9Yh4FHrgJIuljuo9Kn8-1qZ3J1xQ33Bgwwg3xkfCFcXYabbsysnGuwSkEJIW0xGcBD2Gkji5RekLX0wKHsG4QunY6gSnoGIKOc40pvC1VlRFPFctbJY2J57cv4lyu4T95rzUyXWjhJRhDEo1bIbw
10 changes: 5 additions & 5 deletions examples/cluster/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
apiVersion: cluster.argocd.crossplane.io/v1alpha1
kind: Cluster
metadata:
name: example-cluster
name: test-123
spec:
forProvider:
server: https://kubernetes.default.svc
name: example-cluster
server: https://proxy.upbound.io
name: test-123
config:
tlsClientConfig:
insecure: true
providerConfigRef:
name: argocd-provider
# providerConfigRef:
# name: argocd-provider
11 changes: 5 additions & 6 deletions pkg/controller/cluster/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,12 @@ func (e *external) Observe(ctx context.Context, mg resource.Managed) (managed.Ex
// Case: Cluster is deleted,
// and the managed resource has a deletion timestamp
return managed.ExternalObservation{}, nil
} else {
// Case: Cluster is deleted via argocd-ui,
// but the managed resource still exists
return managed.ExternalObservation{
ResourceExists: false,
}, nil
}
// Case: Cluster is deleted via argocd-ui,
// but the managed resource still exists
return managed.ExternalObservation{
ResourceExists: false,
}, nil

default:
// Default case: Handle other errors
Expand Down

0 comments on commit 1324b37

Please sign in to comment.