Skip to content

Instantly share code, notes, and snippets.

@claudioacioli
Last active June 12, 2021 12:00
Show Gist options
  • Save claudioacioli/05176c31b7aae0165c176a067aa234d7 to your computer and use it in GitHub Desktop.
Save claudioacioli/05176c31b7aae0165c176a067aa234d7 to your computer and use it in GitHub Desktop.

Revisions

  1. claudioacioli revised this gist Jun 12, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ Download and make it executable:

    ```bash
    curl -LO "https://gist.github.com/claudioacioli/05176c31b7aae0165c176a067aa234d7/raw/64e6f283c6a22e1d75b3d5f56c09016f02fbb25e/clearkube"
    chmod 544 clearkube
    chmod 744 clearkube
    ```
    ### Usage

  2. claudioacioli revised this gist Jun 12, 2021. 1 changed file with 24 additions and 0 deletions.
    24 changes: 24 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    # clearkube

    When you are studding k8s and you need to clear your minikube cluster all time.
    ### Install

    Download and make it executable:

    ```bash
    curl -LO "https://gist.github.com/claudioacioli/05176c31b7aae0165c176a067aa234d7/raw/64e6f283c6a22e1d75b3d5f56c09016f02fbb25e/clearkube"
    chmod 544 clearkube
    ```
    ### Usage

    Create a sample deployment and expose it on port 8080: [See more on minikube start](https://minikube.sigs.k8s.io/docs/start/)

    ```bash
    kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4
    kubectl expose deployment hello-minikube --type=NodePort --port=8080
    ```
    Then clear it with:

    ```bash
    ./clearkube hello-minikube
    ```
  3. claudioacioli created this gist Jun 12, 2021.
    12 changes: 12 additions & 0 deletions clearkube
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #!/bin/sh

    if [ -n "$1" ]
    then
    POD_NAME=$(kubectl get pods -o go-template --template '{{range.items}}{{.metadata.name}}{{"\n"}}{{end}}')
    fi;

    [ -n "$1" ] && kubectl delete -n default deployment "$1"
    [ -n "$POD_NAME" ] && kubectl delete -n default pod "$POD_NAME"
    [ -n "$1" ] && kubectl delete -n default service "$1"

    [ -z "$1" ] && printf "\nYou need pass a deployment name like:\n\n \$ clearkube my_deployment_name\n"