github.com/GoogleContainerTools/skaffold/v2@v2.13.2/docs-v2/content/en/docs/cleanup.md (about)

     1  ---
     2  title: "Cleanup"
     3  linkTitle: "Cleanup"
     4  weight: 47
     5  featureId: cleanup
     6  aliases: [/docs/pipeline-stages/cleanup]
     7  ---
     8  
     9  Skaffold works with [image builders]({{<relref "/docs/builders">}}) and [deployers]({{<relref "/docs/deployers">}}) 
    10  that both have side effects on both your local and deployment environments: 
    11  
    12  - resources are created in one or more namespaces in a Kubernetes cluster 
    13  - images might be created on the local Docker daemon
    14  - images might be pushed to registries
    15  - application might have arbitrary side effects 
    16      
    17  Skaffold offers cleanup functionality to negate some of these side effects:
    18  
    19  - Kubernetes resource cleanup - `skaffold delete`, and automatic cleanup on `Ctrl+C` for `skaffold dev` and `skaffold debug`   
    20  - Image pruning - for local Docker daemon images only, automatically on `Ctrl+C` for `skaffold dev` and `skaffold debug` 
    21  
    22  For pushed images in registries and application side effects the user has to take care of cleanup. 
    23  
    24  ## Kubernetes resource cleanup 
    25   
    26  After running `skaffold run` or `skaffold deploy` and deploying your application to a cluster, running `skaffold delete` will remove all the resources you deployed.
    27  Cleanup is enabled by default, it can be turned off by `--cleanup=false`. 
    28  
    29  ## Ctrl + C 
    30  
    31  When running `skaffold dev` or `skaffold debug`, pressing `Ctrl+C` (`SIGINT` signal) will kick off the cleanup process which will mimic the behavior of `skaffold delete`.
    32  If for some reason the Skaffold process was unable to catch the `SIGINT` signal, `skaffold delete` can always be run later to clean up the deployed Kubernetes resources.
    33   
    34  ### Image pruning 
    35   
    36  Images that are built by Skaffold and stored on the local Docker daemon can easily pile up, taking up a significant amount of disk space.
    37  To avoid this, users can turn on image pruning that deletes the images built by Skaffold on `SIGTERM` from `skaffold dev` and `skaffold debug`.  
    38  
    39  {{< alert title="Note" >}}
    40  Image pruning is only available if artifact caching is disabled.<br>
    41  As artifact caching is enabled by default, image pruning is disabled by default.
    42  {{</alert>}}
    43  
    44  To enable image pruning, you can run Skaffold with both `--no-prune=false` and `--cache-artifacts=false`:
    45  
    46   ```bash
    47  skaffold dev --no-prune=false --cache-artifacts=false
    48  ```
    49  
    50  outputs: 
    51  
    52  ```bash
    53  Listing files to watch...
    54   - gcr.io/k8s-skaffold/skaffold-example
    55  Generating tags...
    56   - gcr.io/k8s-skaffold/skaffold-example -> gcr.io/k8s-skaffold/skaffold-example:v0.41.0-148-gd2f3e0539
    57  Building [gcr.io/k8s-skaffold/skaffold-example]...
    58  Sending build context to Docker daemon  3.072kB
    59  Step 1/6 : FROM golang:1.12.9-alpine3.10 as builder
    60   ---> e0d646523991
    61  Step 2/6 : COPY main.go .
    62   ---> Using cache
    63   ---> 964ce43c7a63
    64  Step 3/6 : RUN go build -o /app main.go
    65   ---> Using cache
    66   ---> 1fece4643da6
    67  Step 4/6 : FROM alpine:3.10
    68   ---> 961769676411
    69  Step 5/6 : CMD ["./app"]
    70   ---> Using cache
    71   ---> 256b146875d2
    72  Step 6/6 : COPY --from=builder /app .
    73   ---> Using cache
    74   ---> f7a2f5c3a2f6
    75  Successfully built f7a2f5c3a2f6
    76  Successfully tagged gcr.io/k8s-skaffold/skaffold-example:v0.41.0-148-gd2f3e0539
    77  Tags used in deployment:
    78   - gcr.io/k8s-skaffold/skaffold-example -> gcr.io/k8s-skaffold/skaffold-example:v0.41.0-148-gd2f3e0539@sha256:00d7fa06c313f7d06ad3d4701026e0ee65f8f437c703172f160df37c0059b3b1
    79  Starting deploy...
    80   - pod/getting-started created
    81  Watching for changes...
    82  [getting-started] Hello world!
    83  [getting-started] Hello world!
    84  [getting-started] Hello world!
    85  ```
    86  
    87  And after hitting Ctrl+C:
    88  
    89  ```bash 
    90  ^CCleaning up...
    91   - pod "getting-started" deleted
    92  Pruning images...
    93  untagged image gcr.io/k8s-skaffold/skaffold-example:v0.41.0-148-gd2f3e0539
    94  untagged image gcr.io/k8s-skaffold/skaffold-example:v0.41.0-58-g8c428b975
    95  untagged image gcr.io/k8s-skaffold/skaffold-example@sha256:00d7fa06c313f7d06ad3d4701026e0ee65f8f437c703172f160df37c0059b3b1
    96  deleted image sha256:f7a2f5c3a2f6721989598d09a09ad70134936db398d93303ebb3545de2d32e22
    97  deleted image sha256:c069434a51c8d96f68a95c13bbccd3512849f9ccfe5defbb80af7e342a48bbba
    98  
    99  ```
   100