Removing Management subsystem postgres resources on Kubernetes

When you remove the API Connect Management subsystem by deleting its files, some postgres resources from Crunchy Data remain, and must be deleted manually before you attempt to re-install the Management subsystem.

About this task

Sometimes when you remove the Management subsystem, some postgres resources remain and must be deleted manually.

To determine whether you need to delete any postgres resources, use the kubectl get command and specify vendor=crunchydata; as shown in the following example.

$ kubectl get pods -n apic -l vendor=crunchydata
NAME                                                              READY   STATUS      RESTARTS   AGE
backrest-backup-production-mgmt-mymgmtsite123-postgres-k77xj      0/1     Completed   0          17h
production-mgmt-mymgmtsite123-postgres-backrest-shared-repk4kzc   1/1     Running     0          2d21h
production-mgmt-mymgmtsite123-postgres-full-sch-backup-9ktp5      0/1     Completed   0          164m

$ kubectl get deployments -n apic -l vendor=crunchydata
NAME                                                          READY   UP-TO-DATE   AVAILABLE   AGE
production-mgmt-mymgmtsite123-postgres-backrest-shared-repo   1/1     1            1           2d21h

$ kubectl get sa -n apic -l vendor=crunchydata
No resources found in apic namespace.

$ kubectl get jobs -n apic -l vendor=crunchydata
NAME                                                     COMPLETIONS   DURATION   AGE
backrest-backup-production-mgmt-mymgmtsite123-postgres   1/1           10s        17h
production-mgmt-mymgmtsite123-postgres-full-sch-backup   1/1           37s        164m
production-mgmt-mymgmtsite123-postgres-rmdata-cemg       1/1           20s        14m

$ kubectl get roles -n apic -l vendor=crunchydata
No resources found in apic namespace.

$ kubectl get rolebindings -n apic -l vendor=crunchydata
No resources found in apic namespace.

$ kubectl get secrets -n apic -l vendor=crunchydata
NAME                                                          TYPE     DATA   AGE
production-mgmt-7bc754c7-postgres-backrest-repo-config        Opaque   9      6d23h
production-mgmt-7bc754c7-postgres-postgres-secret             Opaque   2      6d23h
production-mgmt-7bc754c7-postgres-primaryuser-secret          Opaque   2      6d23h
production-mgmt-7bc754c7-postgres-testuser-secret             Opaque   2      6d23h
production-mgmt-8aac6b4e-postgres-backrest-repo-config        Opaque   9      6d22h
production-mgmt-8aac6b4e-postgres-postgres-secret             Opaque   2      6d22h
production-mgmt-8aac6b4e-postgres-primaryuser-secret          Opaque   2      6d22h
production-mgmt-8aac6b4e-postgres-testuser-secret             Opaque   2      6d22h
production-mgmt-mymgmtsite123-postgres-backrest-repo-config   Opaque   9      2d21h
production-mgmt-mymgmtsite123-postgres-postgres-secret        Opaque   2      2d21h
production-mgmt-mymgmtsite123-postgres-primaryuser-secret     Opaque   2      2d21h
production-mgmt-mymgmtsite123-postgres-testuser-secret        Opaque   2      2d21h

$ kubectl get cm -n apic -l vendor=crunchydata
NAME                                                  DATA   AGE
production-mgmt-mymgmtsite123-postgres-config         0      2d21h
production-mgmt-mymgmtsite123-postgres-leader         0      2d21h
production-mgmt-mymgmtsite123-postgres-pgbouncer-cm   2      2d21h
production-mgmt-mymgmtsite123-postgres-pgha-config    5      2d21h


For each type of postgres resource, check to see if any resources are available and if so, delete the resources:
  • pods:
    kubectl get pods -n <namespace> -l vendor=crunchydata
    kubectl delete pods -n <namespace> -l vendor=crunchydata
  • deployments:
    kubectl get deployments -n <namespace> -l vendor=crunchydata
    kubectl delete deployments -n <namespace> -l vendor=crunchydata
  • service accounts:
    kubectl get sa -n <namespace> -l vendor=crunchydata
    kubectl delete sa -n <namespace> -l vendor=crunchydata
  • jobs:
    kubectl get jobs -n <namespace> -l vendor=crunchydata
    kubectl delete jobs -n <namespace> -l vendor=crunchydata
  • roles:
    kubectl get roles -n <namespace> -l vendor=crunchydata
    kubectl delete roles -n <namespace> -l vendor=crunchydata
  • rolebindings:
    kubectl get rolebindings -n <namespace> -l vendor=crunchydata
    kubectl delete rolebindings -n <namespace> -l vendor=crunchydata
  • secrets:
    kubectl get secrets -n <namespace> -l vendor=crunchydata
    kubectl delete secrets -n <namespace> -l vendor=crunchydata
  • cm:
    kubectl get cm -n <namespace> -l vendor=crunchydata
    kubectl delete cm -n <namespace> -l vendor=crunchydata
  • pgtasks:
    kubectl get -n <namespace> -l vendor=crunchydata
    kubectl delete -n <namespace>
  • pgreplica:
    kubectl get pgreplica -n <management_namespace> -l vendor=crunchydata
    kubectl delete pgreplica -n <management_namespace> -l vendor=crunchydata