Delete stateful workloads

Delete your stateful workloads using standard Kubernetes deletion methodologies.

Before you begin

To run commands against a user cluster, use the gdcloud CLI to access its kubeconfig file.

  1. Ensure that you have downloaded, installed, and configured the gdcloud CLI.

  2. Run gdcloud auth login to log in to the org admin cluster.

  3. Locate the user cluster name, or ask your Platform Administrator what the cluster name is.

  4. To generate the kubeconfig file of the user cluster, run:

    gdcloud clusters get-credentials USER_CLUSTER_NAME
    
  5. Record the path to the generated file, such as /tmp/user-cluster-kubeconfig-with-user-identity.yaml.

  6. Use the path to replace USER_CLUSTER_KUBECONFIG in these instructions.

To get the required permissions to delete stateful workloads, ask your Organization IAM Admin to grant you the Namespace Admin role.

Delete a StatefulSet resource

Delete a StatefulSet resource if you no longer have a use for its associated stateful container workloads.

  1. To delete a StatefulSet resource, run:

    kubectl --kubeconfig USER_CLUSTER_KUBECONFIG \
        delete statefulset STATEFULSET_NAME
    

    Replace the following:

    • USER_CLUSTER_KUBECONFIG: the kubeconfig file for the user cluster.

    • STATEFULSET_NAME: the name of the StatefulSet object to delete.

    When deleting a StatefulSet resource, all of its pods are also deleted. If you prefer to only delete the StatefulSet resource and not its pods, include the --cascade=orphan parameter.

  2. Delete the associated service:

    kubectl --kubeconfig USER_CLUSTER_KUBECONFIG \
        delete service SERVICE_NAME
    

    Replace the following variables:

    • USER_CLUSTER_KUBECONFIG: the kubeconfig file for the user cluster.

    • SERVICE_NAME: the name of the Service object to delete.