Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sign container images #501

Merged
merged 16 commits into from
Mar 21, 2022
Merged

Sign container images #501

merged 16 commits into from
Mar 21, 2022

Conversation

puerco
Copy link
Member

@puerco puerco commented Feb 15, 2022

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR introduces digital signing into the promoter. The signing flow is enabled by default and will use the default kubernetes service account ([email protected]).

Signing is controlled by two new flags in kpromo cip:

  --sign                          when true, sign promoted images (default true)
  --signer-account string         service account to use as signing identity (default "[email protected]")

Image signing involves four steps which begin after promotion. After promoting, kpromo will look for signatures attached to images in the original registry and copy them to the destination registries. It will generate tokens for the signer account to invoke the keyless signing flow. Once the tokens are available, it will sign one of the images and copy the resulting combined signature to the rest of the mirrors (if any).

Which issue(s) this PR fixes:

Part of: kubernetes/release#2383

Special notes for your reviewer:

/assign @justaugustus

Stephen I think this is ready, please take a look when you can!

Does this PR introduce a user-facing change?

`kpromo` now signs container images using the sigstore keyless flow. Signing identity can be specified with a new flag `--signer-account`. In addition, image signing can be enabled/disabled using `--sign`.  

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/artifacts Issues or PRs related to the hosting of release artifacts for subprojects labels Feb 15, 2022
@k8s-ci-robot k8s-ci-robot added area/release-eng Issues or PRs related to the Release Engineering subproject size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. sig/release Categorizes an issue or PR as relevant to SIG Release. labels Feb 15, 2022
@puerco
Copy link
Member Author

puerco commented Feb 16, 2022

We need to pass the signer an external identity token, if not the cli will ask the user to follow the OIDC flow from the browser:

Enter the verification code XXXX-XXXX in your browser at: https://oauth2.sigstore.dev/auth/device?user_code=XXX-XXXX

This PR enables that: kubernetes-sigs/release-sdk#42

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 16, 2022
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 17, 2022
@ameukam
Copy link
Member

ameukam commented Feb 17, 2022

We need to pass the signer an external identity token, if not the cli will ask the user to follow the OIDC flow from the browser:

Enter the verification code XXXX-XXXX in your browser at: https://oauth2.sigstore.dev/auth/device?user_code=XXX-XXXX

This PR enables that: kubernetes-sigs/release-sdk#42

Do you plan to use Github as an identity provider ?

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 22, 2022
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 23, 2022
@puerco
Copy link
Member Author

puerco commented Feb 23, 2022

Hey @ameukam sorry, I missed your message last week. No, since we will run everything in GCP the identity will come from GCP service accounts. The idea is that the service account that runs the promoter will impersonate a service account that will eventually do the signing.

I'm thinking that we should have two accounts: One for the actual signing of the artifacts and one that we can impersonate while we run the tests. I still have to decipher which service accounts are working in the promoter and then we need to set permissions and roles for all of them.

@puerco puerco force-pushed the sign-images branch 6 times, most recently from e588d4d to df609be Compare February 23, 2022 07:37
Before comparing pre and after snapshots, remove the signature
layers to ensure images match.

Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
In order to ensure the same blobs in all images, we now sign one
image of a set of mirrors and replicate the signature to the rest.

This avoids signing multiple times, ensure one operation in the
transparency log and identical blobs (and therefore digests) whe
signing promoted images.

Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 13, 2022
@puerco
Copy link
Member Author

puerco commented Mar 15, 2022

/test pull-cip-e2e

This commit modifies the signature copy to crane and ensures
we have the SA token ready if we need to pass it to crane.

Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
@puerco
Copy link
Member Author

puerco commented Mar 16, 2022

/test pull-cip-verify
/test pull-cip-unit-tests

Add OCIManifestSchema1 from GGCR to supported media types
to ensure we copy existing images.

Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
@puerco
Copy link
Member Author

puerco commented Mar 16, 2022

I tracked a problem where the staging images were getting wiped out when adding the k8s-org signatures to a problem in cosign. Fixed it here: sigstore/cosign#1616.

Before that PR merges and we pull the commit into our deps, the promoter will copy the signatures from staging but will delete them when re-signing.

At some point, attaching signatures will be performed via
OCI reference types or other mechanism. Therefore, we will
not be "promoting" the sig/sbom layers, ie copying them by
listing them in the manifest.

The promoter will verify any signed images, if sigs are found
and valid, the signatures will be copied to the newly promoted
images before signing them with the K8s-wide signature.

Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
Signed-off-by: Adolfo García Veytia (Puerco) <[email protected]>
This commit creates a new option `--signer-account` which defines
the service account that the promoter will use to sign promoted
images.

Signed-off-by: Adolfo García Veytia <[email protected]>
This commit adds a new `--sign` flag to `kpromo cip` that allows
to enable disable signing of container images.

Signed-off-by: Adolfo García Veytia <[email protected]>
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 21, 2022
Signed-off-by: Adolfo García Veytia <[email protected]>
@puerco puerco changed the title WIP Sign container images Sign container images Mar 21, 2022
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Mar 21, 2022
@puerco
Copy link
Member Author

puerco commented Mar 21, 2022

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 21, 2022
Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I'll not block in my two findings.

)
srcRef, err := name.ParseReference(sourceRefStr)
if err != nil {
return fmt.Errorf("parsing reference %q: %w", sourceRefStr, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking nit: either use consistently errors.Wrap or wrapping with %w.

gopts.WithCredentialsFile(opts.SignerInitCredentials),
}
}
ctx := context.Background()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking nit: consider using a context with timeout here.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 21, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: puerco, saschagrunert

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [puerco,saschagrunert]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 7096c35 into kubernetes-sigs:main Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/artifacts Issues or PRs related to the hosting of release artifacts for subprojects area/release-eng Issues or PRs related to the Release Engineering subproject cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/release Categorizes an issue or PR as relevant to SIG Release. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants