weaveworks / gitopssets-controller

Manages the GitOpsSet CRDs.
Apache License 2.0
9 stars 5 forks source link

Cleanup cross-namespace resources from the inventory #64

Closed bigkevmcd closed 1 year ago

bigkevmcd commented 1 year ago

This adds a finalizer and removes the resources recorded in the inventory from the cluster.

foot commented 1 year ago

Tested it a bit, works great 💯 !

Only didn't work for:

This is rare, I sort of got it into this state by commenting out the namespace section as below, which removed the namespaces, (and so the configmaps), but the inv still had the configmaps.

Could we check for NotFound errors coming back from Delete? Not sure thats supported there. Anyway, lgtm!

[0]

apiVersion: templates.weave.works/v1alpha1
kind: GitOpsSet
metadata:
  name: gitopsset-configmaps
  namespace: default
spec:
  generators:
    - list:
        elements:
          - env: dev
            team: dev-team
          - env: production
            team: ops-team
          - env: staging
            team: ops-team
  templates:
    # - content:
    #     kind: Namespace
    #     apiVersion: v1
    #     metadata:
    #       name: "{{ .Element.env }}"
    - content:
        kind: ConfigMap
        apiVersion: v1
        metadata:
          name: "{{ .Element.env }}-info-configmap"
          namespace: "{{ .Element.env }}"
        spec:
          data:
            team: "{{ .Element.team }}"
            env: "{{ .Element.env }}"
            description: "This is a configmap for the {{ .Element.env }} environment"