Scenario

Namespace won't terminate

$ kubectl describe ns flux-system 
Name:         flux-system
Labels:       app.kubernetes.io/instance=flux-system
              app.kubernetes.io/part-of=flux
              app.kubernetes.io/version=v0.28.2
              kubernetes.io/metadata.name=flux-system
              kustomize.toolkit.fluxcd.io/name=flux-system
              kustomize.toolkit.fluxcd.io/namespace=flux-system
              pod-security.kubernetes.io/warn=restricted
              pod-security.kubernetes.io/warn-version=latest
Annotations:  <none>
Status:       Terminating
Conditions:
  Type                                         Status  LastTransitionTime               Reason                Message
  ----                                         ------  ------------------               ------                -------
  NamespaceDeletionDiscoveryFailure            False   Mon, 30 Jan 2023 08:39:28 -0500  ResourcesDiscovered   All resources successfully discovered
  NamespaceDeletionGroupVersionParsingFailure  False   Fri, 27 Jan 2023 16:36:06 -0500  ParsedGroupVersions   All legacy kube types successfully parsed
  NamespaceDeletionContentFailure              False   Fri, 27 Jan 2023 16:36:06 -0500  ContentDeleted        All content successfully deleted, may be waiting on finalization
  NamespaceContentRemaining                    True    Fri, 27 Jan 2023 16:36:06 -0500  SomeResourcesRemain   Some resources are remaining: gitrepositories.source.toolkit.fluxcd.io has 1 resource instances, helmcharts.source.toolkit.fluxcd.io has 3 resource instances
  NamespaceFinalizersRemaining                 True    Fri, 27 Jan 2023 16:36:06 -0500  SomeFinalizersRemain  Some content in the namespace has finalizers remaining: finalizers.fluxcd.io in 4 resource instances

No resource quota.

No LimitRange resource.


Find the CRDS

$ kubectl get crds
NAME                                             CREATED AT
gitrepositories.source.toolkit.fluxcd.io         2022-09-01T22:08:23Z
helmcharts.source.toolkit.fluxcd.io              2022-09-01T22:08:22Z
volumesnapshotclasses.snapshot.storage.k8s.io    2022-09-01T21:38:23Z
volumesnapshotcontents.snapshot.storage.k8s.io   2022-09-01T21:38:23Z
volumesnapshots.snapshot.storage.k8s.io          2022-09-01T21:38:23Z


Get the instances of helm charts

$ kubectl -n flux-system get helmcharts

NAME                                 CHART                    VERSION          SOURCE KIND      SOURCE NAME         AGE    READY   STATUS
flux-system-apiserver-subscription   apiserver-subscription   22.0.1-2506283   HelmRepository   ncydacrcandidates   103d   False   failed to get source: HelmRepository.source.toolkit.fluxcd.io "ncydacrcandidates" not found
flux-system-config-provider          config-provider          22.0.1-2506283   HelmRepository   ncydacrcandidates   150d   False   failed to get source: HelmRepository.source.toolkit.fluxcd.io "ncydacrcandidates" not found
flux-system-dashboard-5g-security    dashboard-5g-security    22.0.1-2506283   HelmRepository   ncydacrcandidates   150d   False   failed to get source: HelmRepository.source.toolkit.fluxcd.io "ncydacrcandidates" not found


Get the instances of gitrepositories

$ kubectl -n flux-system get gitrepositories
NAME          URL                                                                   AGE    READY   STATUS
flux-system   ssh://git@10.0.2.4/ncyd/ncyd_flux_ottawa_team1_integration_test.git   150d   True    stored artifact for revision 'main/d4ffbcf4ade0a551a3f8b47637516e95d2e766b0'


Delete the instances

$ kubectl -n flux-system delete gitrepository flux-system
gitrepository.source.toolkit.fluxcd.io "flux-system" deleted

...


Edit Finalizers of Instances

$ kubectl -n flux-system edit gitrepository flux-system
Name:         flux-system
Namespace:    flux-system
Labels:       <none>
Annotations:  reconcile.fluxcd.io/requestedAt: 2023-01-27T16:37:26.4522483-05:00
API Version:  source.toolkit.fluxcd.io/v1beta2
Kind:         GitRepository
Metadata:
  Creation Timestamp:             2022-09-01T22:08:38Z
  Deletion Grace Period Seconds:  0
  Deletion Timestamp:             2023-01-27T21:36:00Z
  Finalizers:
    finalizers.fluxcd.io
  Generation:  2

Delete LINE under Finalizers 'finalizers.fluxcd.io' and save.


Repeat above for other Instances.


Verify that the Namespace is now Deleted

kubectl describe ns flux-system                         
Error from server (NotFound): namespaces "flux-system" not found
  • No labels