-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[TEP-0091] Add Verification at reconciler #5581
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright 2022 The Tekton Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: config-trusted-resources | ||
namespace: tekton-pipelines | ||
labels: | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: tekton-pipelines | ||
data: | ||
_example: | | ||
################################ | ||
# # | ||
# EXAMPLE CONFIGURATION # | ||
# # | ||
################################ | ||
# This block is not actually functional configuration, | ||
# but serves to illustrate the available configuration | ||
# options and document them in a way that is accessible | ||
# to users that `kubectl edit` this config map. | ||
# | ||
# These sample configuration options may be copied out of | ||
# this example block and unindented to be in the data block | ||
# to actually change the configuration. | ||
|
||
# publickeys specifies the list of public keys, the paths are separated by comma | ||
# publickeys: "/etc/verification-secrets/cosign.pub, | ||
# gcpkms://projects/tekton/locations/us/keyRings/trusted-resources/cryptoKeys/trusted-resources" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Trusted Resources | ||
|
||
- [Overview](#overview) | ||
- [Instructions](#Instructions) | ||
- [Sign Resources](#sign-resources) | ||
- [Enable Trusted Resources](#enable-trusted-resources) | ||
|
||
## Overview | ||
|
||
Trusted Resources is a feature which can be used to sign Tekton Resources and verify them. Details of design can be found at [TEP--0091](https://github.com/tektoncd/community/blob/main/teps/0091-trusted-resources.md). This feature is under `alpha` version and support `v1beta1` version of `Task` and `Pipeline`. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add some details around what behavior is expected if a resource fails verification? The PR also mentioned that there are some details around what is supported and what isn't, e.g. KMS isn't supported, only PEM files - can you explain about that in this docs as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure! The expected behaviour is mentioned in the |
||
Verification failure will mark corresponding taskrun/pipelinerun as Failed status and stop the execution. | ||
|
||
**Note:** KMS is not currently supported and will be supported in the following work. | ||
|
||
|
||
## Instructions | ||
|
||
### Sign Resources | ||
For `Sign` cli you may refer to [experimental repo](https://github.com/tektoncd/experimental/tree/main/pipeline/trusted-resources) to sign the resources. We're working to add `sign` and `verify` into [Tekton Cli](https://github.com/tektoncd/cli) as a subcommand. | ||
|
||
A signed task example: | ||
```yaml | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
annotations: | ||
tekton.dev/signature: MEYCIQDM8WHQAn/yKJ6psTsa0BMjbI9IdguR+Zi6sPTVynxv6wIhAMy8JSETHP7A2Ncw7MyA7qp9eLsu/1cCKOjRL1mFXIKV | ||
creationTimestamp: null | ||
name: example-task | ||
namespace: tekton-trusted-resources | ||
spec: | ||
steps: | ||
- image: ubuntu | ||
name: echo | ||
``` | ||
|
||
### Enable Trusted Resources | ||
|
||
#### Enable feature flag | ||
|
||
Update the config map: | ||
```yaml | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: feature-flags | ||
namespace: tekton-pipelines | ||
labels: | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: tekton-pipelines | ||
data: | ||
resource-verification-mode: "enforce" | ||
``` | ||
|
||
**Note:** `resource-verification-mode` needs to be set as `enforce` or `warn` to enable resource verification. | ||
|
||
`resource-verification-mode` configurations: | ||
* `enforce`: Failing verification will mark the taskruns/pipelineruns as failed. | ||
* `warn`: Log warning but don't fail the taskruns/pipelineruns. | ||
* `skip`: Directly skip the verification. | ||
|
||
Or patch the new values: | ||
```bash | ||
kubectl patch configmap feature-flags -n tekton-pipelines -p='{"data":{"resource-verification-mode":"enforce"}} | ||
``` | ||
|
||
#### Config key at configmap | ||
Note that multiple keys reference should be separated by comma. If the resource can pass any key in the list, it will pass the verification. | ||
|
||
We currently hardcode SHA256 as hashfunc for loading public keys as verifiers. | ||
|
||
Public key files should be added into secret and mounted into controller volumes. To add keys into secret you may execute: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to volume mount the secrets, or should we just reference them via the sigstore There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you suggesting we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking more specifying these values in the config map - I'm fine with punting on this as a TODO if you want, wanted to ask what the long term plan is since there's a few places where we assume local keys and my guess is that probably won't be the case forever. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see, that seems better! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a todo for this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Yongxuanzhang is the updated plan for this reflected in the TEP? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Not yet, I will change this in the tep pr |
||
|
||
```shell | ||
kubectl create secret generic verification-secrets \ | ||
--from-file=cosign.pub=./cosign.pub \ | ||
--from-file=cosign.pub=./cosign2.pub \ | ||
-n tekton-pipelines | ||
Yongxuanzhang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: config-trusted-resources | ||
namespace: tekton-pipelines | ||
labels: | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: tekton-pipelines | ||
data: | ||
publickeys: "/etc/verification-secrets/cosign.pub, /etc/verification-secrets/cosign2.pub" | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might make sense to add some docs to the install instructions as well on the new config option(s) - maybe linking to the separate doc you've written?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!! added