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

     1  ---
     2  title: "Verify [NEW]"
     3  linkTitle: "Verify [NEW]"
     4  weight: 44
     5  featureId: verify
     6  aliases: [/docs/how-tos/verify, /docs/pipeline-stages/verify]
     7  ---
     8  
     9  Skaffold `v2.0.0`+ supports running post-deployment verification tests. You define these tests as a list of test containers that are either standalone or built by Skaffold. Skaffold runs these containers after the [deploy]({{< relref "/docs/deployers/" >}}) stage and monitors them for success or failure.
    10  
    11  You can configure and execute post-deployment verification tests using the [`verify` command]({{< relref "/docs/references/cli/#skaffold-verify" >}}) and associated [`skaffold.yaml` schema configuration]({{< relref "/docs/references/yaml#verify" >}}).
    12  
    13  ## Execution modes
    14  
    15  You can run post-deployment verification tests in the following execution environments:
    16  
    17  * A local Docker environment
    18  * A Kubernetes cluster environment
    19  
    20  ### Local
    21  
    22  When Skaffold runs a post-deployment verifications test in the local execution mode, it uses the `docker` CLI to run the test container on the host machine. This is the default execution mode.
    23  
    24  ### Kubernetes cluster
    25  
    26  When Skaffold runs a post-deployment verification test in the Kubernetes cluster execution mode, it uses the `kubectl` CLI to run the test container as a Kubernetes Job.
    27  
    28  There are two ways to optionally customize the Skaffold-generated Kubernetes Job:
    29  
    30  * To selectively overwrite the configuration of the Skaffold-generated Kubernetes Job with inline JSON, use the `overrides` configuration option. This is similar to the `--overrides` option provided by `kubectl run`.
    31  * To use your own Kubernetes Job manifest and have Skaffold replace the containers with those specified in the `containers` stanza of your `verify` configuration, use the `jobManifestPath` configuration option.
    32  
    33  ## Examples
    34  
    35  Below is an example of a `skaffold.yaml` file with a `verify` configuration that runs three successful verification tests against deployments:
    36  
    37  * A user-built `integration-test-container`, run in the Kubernetes cluster execution mode with optional `overrides` specified.
    38  * A user-built `metrics-test-container`, run in the Kubernetes cluster execution mode with optional `jobManifestPath` specified.
    39  * A simple health check done via "off the shelf" alpine using its installed `wget`, run in the local execution mode.
    40  
    41  `skaffold.yaml`
    42  {{% readfile file="samples/verify/verify.yaml" %}}
    43  
    44  
    45  Running `skaffold verify` against this `skaffold.yaml` (and associated Dockerfiles where relevant) yields:
    46  ``` console
    47  $ skaffold verify -a build.artifacts 
    48  Tags used in verification:
    49   - integration-test-container -> gcr.io/aprindle-test-cluster/integration-test-container:latest@sha256:6d6da2378765cd9dda71cbd20f3cf5818c92d49ab98a2554de12d034613dfa6a
    50   - metrics-test-container -> gcr.io/aprindle-test-cluster/metrics-test-container:latest@sha256:3fbce881177ead1c2ae00d58974fd6959c648d7691593f6448892c04139355f7
    51  3.15.4: Pulling from library/alpine
    52  Digest: sha256:4edbd2beb5f78b1014028f4fbb99f3237d9561100b6881aabbf5acce2c4f9454
    53  Status: Downloaded newer image for alpine:3.15.4
    54  [integration-test-container] Integration Test 1/4 Running ...
    55  [metrics-test-container] Metrics test in progress...
    56  [metrics-test-container] Metrics test passed!
    57  [alpine-wget] Connecting to www.google.com (142.251.46.196:80)
    58  [alpine-wget] saving to 'index.html'
    59  [alpine-wget] index.html           100% |********************************| 13990  0:00:00 ETA
    60  [alpine-wget] 'index.html' saved
    61  [integration-test-container] Integration Test 1/4 Passed!
    62  [integration-test-container] Integration Test 2/4 Running...!
    63  [integration-test-container] Integration Test 2/4 Passed!
    64  [integration-test-container] Integration Test 3/4 Running...!
    65  [integration-test-container] Integration Test 3/4 Passed!
    66  [integration-test-container] Integration Test 4/4 Running...!
    67  [integration-test-container] Integration Test 4/4 Passed!
    68  $ echo $?
    69  0
    70  ```
    71  and `skaffold verify` will exit with error code `0`
    72  
    73  If a test fails, for example changing the `alpine-wget` test to point to a URL that doesn't exist:
    74  ```yaml
    75  - name: alpine-wget
    76    container:
    77      name: alpine-wget
    78      image: alpine:3.15.4
    79      command: ["/bin/sh"]
    80      args: ["-c", "wget http://incorrect-url"]
    81  ```
    82  
    83  The following will occur (simulating a single test failure on one of the three tests):
    84  ```console
    85  $ skaffold verify -a build.artifacts 
    86  Tags used in verification:
    87   - integration-test-container -> gcr.io/aprindle-test-cluster/integration-test-container:latest@sha256:6d6da2378765cd9dda71cbd20f3cf5818c92d49ab98a2554de12d034613dfa6a
    88   - metrics-test-container -> gcr.io/aprindle-test-cluster/metrics-test-container:latest@sha256:3fbce881177ead1c2ae00d58974fd6959c648d7691593f6448892c04139355f7
    89  3.15.4: Pulling from library/alpine
    90  Digest: sha256:4edbd2beb5f78b1014028f4fbb99f3237d9561100b6881aabbf5acce2c4f9454
    91  Status: Image is up to date for alpine:3.15.4
    92  [integration-test-container] Integration Test 1/4 Running ...
    93  [metrics-test-container] Metrics test in progress...
    94  [metrics-test-container] Metrics test passed!
    95  [integration-test-container] Integration Test 1/4 Passed!
    96  [alpine-wget] wget: bad address 'incorrect-url'
    97  [integration-test-container] Integration Test 2/4 Running...!
    98  [integration-test-container] Integration Test 2/4 Passed!
    99  [integration-test-container] Integration Test 3/4 Running...!
   100  [integration-test-container] Integration Test 3/4 Passed!
   101  [integration-test-container] Integration Test 4/4 Running...!
   102  [integration-test-container] Integration Test 4/4 Passed!
   103  1 error(s) occurred:
   104  * verify test failed: "alpine-wget" running container image "alpine:3.15.4" errored during run with status code: 1
   105  $ echo $?
   106  1
   107  ```
   108  and `skaffold verify` will exit with error code `1`