This page discusses how to set up Skaffold to run container structure tests after building an artifact.

Container structure tests are consistency checks for containers. Skaffold relies on container-structure-test to execute those tests, and requires its binary to be installed.

Container structure tests are defined per image in the Skaffold config. Every time an artifact is rebuilt, Skaffold runs the associated structure tests on that image. If the tests fail, Skaffold will not continue on to the deploy stage. If frequent tests are prohibitive, long-running tests should be moved to a dedicated Skaffold profile.


This following example shows the test section from a skaffold.yaml. It instructs Skaffold to run all container structure tests in the structure-test folder relative to the Skaffold root directory:

  - image: gcr.io/k8s-skaffold/skaffold-example
      - './structure-test/*'

The files matched by the structureTests key are container-structure-test test configurations, such as:

schemaVersion: 2.0.0

  - name: 'no go binary'
    path: '/usr/bin/go'
    shouldExist: false

For a reference how to write container structure tests, see its documentation.

In order to restrict the executed structure tests, a profile section can override the file pattern:

  - name: quickcheck
      - image: gcr.io/k8s-skaffold/skaffold-example
          - './structure-test/profile_structure_test.yaml'

To execute the tests once, run skaffold build --profile quickcheck.