github.com/verrazzano/verrazzano@v1.7.0/platform-operator/build/scripts/cleanup.sh (about)

     1  #!/bin/bash
     2  #
     3  # Copyright (c) 2020, 2022, Oracle and/or its affiliates.
     4  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     5  #
     6  # Cleanup Kind cluster and docker containers
     7  # delete kind cluster if it exists
     8  echo "Doing cleanup of KIND clusters and Docker containers"
     9  kind delete cluster --name "$1"
    10  
    11  if [ -f "${KUBECONFIG}" ]
    12  then
    13    echo "Deleting the kubeconfig '${KUBECONFIG}' ..."
    14    rm ${KUBECONFIG}
    15  fi
    16  
    17  containers=$(docker ps -q --filter label=io.x-k8s.kind.cluster | wc -l)
    18  if [ "$containers" -gt 1 ]
    19  then
    20    # stop all running Kind containers
    21    echo "Stopping Kind Containers ..."
    22    docker stop $(docker ps -q --filter label=io.x-k8s.kind.cluster)
    23  
    24    echo "Deleting Kind Containers ..."
    25    # delete all Kind containers
    26    docker rm $(docker ps -aq --filter label=io.x-k8s.kind.cluster)
    27  fi