Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ Search OperatorHub for "pattern" and accept all the defaults
## Create the Multi-Cloud GitOps pattern

```
kubectl create -f config/samples/gitops_v1alpha1_pattern.yaml
oc create -f config/samples/gitops_v1alpha1_pattern.yaml
```

### Check the status

```
kubectl get -f config/samples/gitops_v1alpha1_pattern.yaml -o yaml
oc get -f config/samples/gitops_v1alpha1_pattern.yaml -o yaml
oc get applications -A -w
```

Expand All @@ -36,21 +36,27 @@ secret and then add the secrets via the UI (this approach is a bit more work)
### Delete the pattern

```
kubectl delete -f config/samples/gitops_v1alpha1_pattern.yaml
oc delete -f config/samples/gitops_v1alpha1_pattern.yaml
```

This will only remove the top-level application.
The subscription and anything created by Argo will not be removed and canmust be removed manually.
Removing the top-level application ensures that Argo won't try to put back anything you delete.
This action removes the `Pattern` instance only.

## Watch the logs

When installing via UI the namespace will be `patterns-operator` (recommended)
If you annotate the Pattern instance with `patterns.gitops.hybrid-cloud-patterns.io/prune: "true"`:

```
oc logs -n patterns-operator `oc get -n patterns-operator pods -o name --field-selector status.phase=Running | grep patterns` -c manager -f
oc annotate -f config/samples/gitops_v1alpha1_pattern.yaml patterns.gitops.hybrid-cloud-patterns.io/prune='true'
```

Once the `Pattern` instance is deleted, the following resources will also be removed:

- The top-level application of the hub cluster.
- The child applications of the hub cluster.
- The top-level application of the spoke clusters.
- The child applications of the spoke clusters.
- The `ManagedCluster` instances (excluding the `local-cluster`).

**NOTE:** The GitOps Operator `Subscription` and the main `ArgoCD` instance will not be removed and must be removed manually.

## Development

### Test your changes locally against a remote cluster
Expand Down
7 changes: 4 additions & 3 deletions internal/controller/pattern_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import (
)

const ReconcileLoopRequeueTime = 180 * time.Second
const PruneAnnotation = "patterns.gitops.hybrid-cloud-patterns.io/prune"

// PatternReconciler reconciles a Pattern object
type PatternReconciler struct {
Expand Down Expand Up @@ -740,11 +741,11 @@ func (r *PatternReconciler) deleteHubApps(targetApp, app *argoapi.Application, n
}

func (r *PatternReconciler) finalizeObject(instance *api.Pattern) error {
// Add finalizer when object is created
log.Printf("Finalizing pattern object")

// The object is being deleted
if controllerutil.ContainsFinalizer(instance, api.PatternFinalizer) || controllerutil.ContainsFinalizer(instance, metav1.FinalizerOrphanDependents) {
// The object is being deleted and, if prune is enabled, we want to delete all the dependent objects in cascade
if strings.EqualFold(instance.Annotations[PruneAnnotation], "true") &&
(controllerutil.ContainsFinalizer(instance, api.PatternFinalizer) || controllerutil.ContainsFinalizer(instance, metav1.FinalizerOrphanDependents)) {
// Prepare the app for cascaded deletion
qualifiedInstance, err := r.applyDefaults(instance)
if err != nil {
Expand Down