Skip to content

add imgcrypt stream processors to the default config#5135

Merged
fuweid merged 3 commits intocontainerd:masterfrom
AkihiroSuda:default-config-crypt
Mar 25, 2021
Merged

add imgcrypt stream processors to the default config#5135
fuweid merged 3 commits intocontainerd:masterfrom
AkihiroSuda:default-config-crypt

Conversation

@AkihiroSuda
Copy link
Copy Markdown
Member

@AkihiroSuda AkihiroSuda commented Mar 8, 2021

Enable the following config by default:

version = 2

[plugins."io.containerd.grpc.v1.cri".image_decryption]
  key_model = "node"

[stream_processors]
  [stream_processors."io.containerd.ocicrypt.decoder.v1.tar.gzip"]
    accepts = ["application/vnd.oci.image.layer.v1.tar+gzip+encrypted"]
    returns = "application/vnd.oci.image.layer.v1.tar+gzip"
    path = "ctd-decoder"
    args = ["--decryption-keys-path", "/etc/containerd/ocicrypt/keys"]
    env = ["OCICRYPT_KEYPROVIDER_CONFIG=/etc/containerd/ocicrypt/ocicrypt_keyprovider.conf"]

  [stream_processors."io.containerd.ocicrypt.decoder.v1.tar"]
    accepts = ["application/vnd.oci.image.layer.v1.tar+encrypted"]
    returns = "application/vnd.oci.image.layer.v1.tar"
    path = "ctd-decoder"
    args = ["--decryption-keys-path", "/etc/containerd/ocicrypt/keys"]
    env = ["OCICRYPT_KEYPROVIDER_CONFIG=/etc/containerd/ocicrypt/ocicrypt_keyprovider.conf"]

Fix #5128

Comment thread cmd/containerd/command/config.go Outdated
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Bike shedding: should this be "imgcrypt" or "ocicrypt"?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

imgcrypt is the project where ctd-decorder is coming from but ocicrypt could be a more generic name for a directory for looking for keys used generally for image encryption. -> "ocicrypt" ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Changed to ocicrypt

@AkihiroSuda AkihiroSuda force-pushed the default-config-crypt branch from d9b56da to f44f652 Compare March 8, 2021 13:06
@containerd containerd deleted a comment from theopenlab-ci Bot Mar 8, 2021
@containerd containerd deleted a comment from theopenlab-ci Bot Mar 8, 2021
@AkihiroSuda
Copy link
Copy Markdown
Member Author

/test pull-containerd-node-e2e

@AkihiroSuda AkihiroSuda force-pushed the default-config-crypt branch 3 times, most recently from 5fb3841 to 0d2be78 Compare March 8, 2021 17:33
Comment thread docs/cri/decryption.md Outdated
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@stefanberger Can we have some default value for this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would call it /etc/ocicrypt_keyprovider.conf. I would NOT call it ocicrypt.conf, because this is the default name used by an other config file that was introduced earlier: https://github.com/containers/ocicrypt/blob/master/config/pkcs11config/config.go#L35

@lumjjb ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/etc/ocicrypt_keyprovider.conf sounds fine. We probably want to test this first with ctd-decoder tests to see if it will ignore the case of a file that isn't present.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added test : containerd/imgcrypt#40

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If we are going to place /etc/ocicrypt_keyprovider.conf outside /etc/containerd, do we want to have decryption-keys-path outside /etc/containerd too?

Or can we have everything under /etc/containerd/ocicrypt?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am fine with putting it in /etc/containerd/ocicrypt/ocicrypt_keyprovider.conf, i like the idea, would probably prevent some conflicts with other tools.

Btw, would the ctd-decoder also be packaged with the installation?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated PR to add env = ["OCICRYPT_KEYPROVIDER_CONFIG=/etc/containerd/ocicrypt/ocicrypt_keyprovider.conf"]

Btw, would the ctd-decoder also be packaged with the installation?

SGTM, but out of the scope of this PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Opened #5265 for discussing inclusion of ctd-decoder

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Mar 8, 2021

Build succeeded.

`config_linux.go` and `config_windows.go` are identical.

`config_unsupported.go` is also almost identical but enables debug logs by default.

Signed-off-by: Akihiro Suda <[email protected]>
Enable the following config by default:

```toml
version = 2

[plugins."io.containerd.grpc.v1.cri".image_decryption]
  key_model = "node"

[stream_processors]
  [stream_processors."io.containerd.ocicrypt.decoder.v1.tar.gzip"]
    accepts = ["application/vnd.oci.image.layer.v1.tar+gzip+encrypted"]
    returns = "application/vnd.oci.image.layer.v1.tar+gzip"
    path = "ctd-decoder"
    args = ["--decryption-keys-path", "/etc/containerd/ocicrypt/keys"]
    env = ["OCICRYPT_KEYPROVIDER_CONFIG=/etc/containerd/ocicrypt/ocicrypt_keyprovider.conf"]
  [stream_processors."io.containerd.ocicrypt.decoder.v1.tar"]
    accepts = ["application/vnd.oci.image.layer.v1.tar+encrypted"]
    returns = "application/vnd.oci.image.layer.v1.tar"
    path = "ctd-decoder"
    args = ["--decryption-keys-path", "/etc/containerd/ocicrypt/keys"]
    env = ["OCICRYPT_KEYPROVIDER_CONFIG=/etc/containerd/ocicrypt/ocicrypt_keyprovider.conf"]
```

Fix issue 5128

Signed-off-by: Akihiro Suda <[email protected]>
@AkihiroSuda AkihiroSuda force-pushed the default-config-crypt branch from 0d2be78 to ecb881e Compare March 15, 2021 04:28
@AkihiroSuda AkihiroSuda added this to the 1.5 milestone Mar 15, 2021
@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Mar 15, 2021

Build succeeded.

Copy link
Copy Markdown
Contributor

@lumjjb lumjjb left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment thread images/mediatypes.go
MediaTypeDockerSchema1Manifest = "application/vnd.docker.distribution.manifest.v1+prettyjws"
// Encypted media types
MediaTypeImageLayerEncrypted = ocispec.MediaTypeImageLayer + "+encrypted"
MediaTypeImageLayerGzipEncrypted = ocispec.MediaTypeImageLayerGzip + "+encrypted"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FYI. There is a definition of the media type in https://github.com/containers/ocicrypt/blob/master/spec/spec.go. I'm guessing it may cause more dependencies for building certain builds though, so not sure what the implications there are if imported.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd prefer not to add Go dependency on ocicrypt here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Mark it as followup ~

Copy link
Copy Markdown
Member

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ocicrypt stream processor to the default config

5 participants