|
| 1 | +--- |
| 2 | +title: Verify Signed Container Images |
| 3 | +content_type: task |
| 4 | +min-kubernetes-server-version: v1.24 |
| 5 | +--- |
| 6 | + |
| 7 | +<!-- overview --> |
| 8 | + |
| 9 | +{{< feature-state state="alpha" for_k8s_version="v1.24" >}} |
| 10 | + |
| 11 | +## {{% heading "prerequisites" %}} |
| 12 | + |
| 13 | +These instructions are for Kubernetes {{< skew currentVersion >}}. If you want |
| 14 | +to check the integrity of components for a different version of Kubernetes, |
| 15 | +check the documentation for that Kubernetes release. |
| 16 | + |
| 17 | +You will need to have the following tools installed: |
| 18 | + |
| 19 | +- `cosign` ([install guide](https://docs.sigstore.dev/cosign/installation/)) |
| 20 | +- `curl` (often provided by your operating system) |
| 21 | + |
| 22 | +## Verifying image signatures |
| 23 | + |
| 24 | +For a complete list of images that are signed please refer |
| 25 | +to [Releases](/releases/download/). |
| 26 | + |
| 27 | +Let's pick one image from this list and verify its signature using |
| 28 | +the `cosign verify` command: |
| 29 | + |
| 30 | +```shell |
| 31 | +COSIGN_EXPERIMENTAL=1 cosign verify k8s.gcr.io/kube-apiserver-amd64:v1.24.0 |
| 32 | +``` |
| 33 | + |
| 34 | +{{< note >}} |
| 35 | +`COSIGN_EXPERIMENTAL=1` is used to allow verification of images signed |
| 36 | +in `KEYLESS` mode. To learn more about keyless signing, please refer to |
| 37 | +[Keyless Signatures](https://github.com/sigstore/cosign/blob/main/KEYLESS.md#keyless-signatures) |
| 38 | +. {{< /note >}} |
| 39 | + |
| 40 | +### Verifying images for all control plane components |
| 41 | + |
| 42 | +To verify all signed control plane images, please run this command: |
| 43 | + |
| 44 | +```shell |
| 45 | +curl -Ls https://sbom.k8s.io/$(curl -Ls https://dl.k8s.io/release/latest.txt)/release | grep 'PackageName: k8s.gcr.io/' | awk '{print $2}' > images.txt |
| 46 | +input=images.txt |
| 47 | +while IFS= read -r image |
| 48 | +do |
| 49 | + COSIGN_EXPERIMENTAL=1 cosign verify "$image" |
| 50 | +done < "$input" |
| 51 | +``` |
| 52 | + |
| 53 | +Once you have verified an image, specify that image by its digest in your Pod |
| 54 | +manifests as per this |
| 55 | +example: `registry-url/image-name@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2` |
| 56 | +. |
| 57 | + |
| 58 | +For more information, please refer |
| 59 | +to [Image Pull Policy](/docs/concepts/containers/images/#image-pull-policy) |
| 60 | +section. |
| 61 | + |
| 62 | +## Verifying Image Signatures with Admission Controller |
| 63 | + |
| 64 | +For non-control plane images ( |
| 65 | +e.g. [conformance image](https://github.com/kubernetes/kubernetes/blob/master/test/conformance/image/README.md)) |
| 66 | +, signatures can also be verified at deploy time using |
| 67 | +[cosigned](https://docs.sigstore.dev/cosign/kubernetes/#cosigned-admission-controller) |
| 68 | +admission controller. To get started with `cosigned` here are a few helpful |
| 69 | +resources: |
| 70 | + |
| 71 | +* [Installation](https://github.com/sigstore/helm-charts/tree/main/charts/cosigned) |
| 72 | +* [Configuration Options](https://github.com/sigstore/cosign/tree/main/config) |
0 commit comments