Skip to content

Conversation

kristofferchr
Copy link
Contributor

@kristofferchr kristofferchr commented Aug 7, 2024

Solves: #8183

Changes

Add a flag to enable setting the readOnlyRootFilesystem field in the securityContext for containers used in pipelinerun, taskrun and affinity assistants

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • pre-commit Passed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

New feature flag `set-security-context-read-only-root-filesystem` in ConfigMap `feature-flags`. The new feature sets readOnlyRootFilesystem in securityContext for taskrun and affinity assistant containers.

@tekton-robot tekton-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesnt merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 7, 2024
@tekton-robot
Copy link
Collaborator

Hi @kristofferchr. Thanks for your PR.

I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@kristofferchr
Copy link
Contributor Author

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Aug 7, 2024
@kristofferchr
Copy link
Contributor Author

/test pull-tekton-pipeline-go-coverage-df

@tekton-robot
Copy link
Collaborator

@kristofferchr: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test pull-tekton-pipeline-go-coverage-df

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesnt merit a release note. labels Aug 7, 2024
@kristofferchr kristofferchr changed the title Enable read only root filesystem Add feature flag set-security-context-read-only-root-filesystem to add readOnlyRootFilesystem to containers Aug 7, 2024
@kristofferchr kristofferchr changed the title Add feature flag set-security-context-read-only-root-filesystem to add readOnlyRootFilesystem to containers Add feature flag set-security-context-read-only-root-filesystem to set readOnlyRootFilesystem to containers Aug 7, 2024
@kristofferchr kristofferchr changed the title Add feature flag set-security-context-read-only-root-filesystem to set readOnlyRootFilesystem to containers Add feature flag set-security-context-read-only-root-filesystem to set readOnlyRootFilesystem for containers Aug 7, 2024
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.1% 94.4% -0.7
pkg/pod/SecurityContext.go Do not exist 85.7%
pkg/pod/pod.go 93.9% 94.2% 0.3
pkg/pod/script.go 99.0% 99.0% -0.0
pkg/pod/workingdir_init.go 95.0% 94.1% -0.9
pkg/reconciler/pipelinerun/affinity_assistant.go 96.9% 97.0% 0.1

@kristofferchr kristofferchr force-pushed the enable-read-only-root-filesystem branch from acd8516 to f0fecb9 Compare August 7, 2024 10:54
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.1% 94.4% -0.7
pkg/pod/pod.go 93.9% 94.2% 0.3
pkg/pod/script.go 99.0% 99.0% -0.0
pkg/pod/security_context_config.go Do not exist 85.7%
pkg/pod/workingdir_init.go 95.0% 94.1% -0.9
pkg/reconciler/pipelinerun/affinity_assistant.go 96.9% 97.0% 0.1

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 22, 2024
@kristofferchr kristofferchr force-pushed the enable-read-only-root-filesystem branch from f0fecb9 to 46cb332 Compare February 6, 2025 12:04
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 6, 2025
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.1% 94.4% -0.7
pkg/pod/pod.go 93.0% 93.3% 0.3
pkg/pod/script.go 99.1% 99.1% -0.0
pkg/pod/security_context_config.go Do not exist 85.7%
pkg/pod/workingdir_init.go 95.0% 94.1% -0.9

@kristofferchr
Copy link
Contributor Author

/retest

@tekton-robot
Copy link
Collaborator

@kristofferchr: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@kristofferchr kristofferchr force-pushed the enable-read-only-root-filesystem branch from 46cb332 to 68f73c6 Compare February 6, 2025 13:39
@tekton-robot tekton-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 Feb 6, 2025
@kristofferchr kristofferchr force-pushed the enable-read-only-root-filesystem branch from 68f73c6 to 1c3c312 Compare February 6, 2025 13:46
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.1% 94.4% -0.7
pkg/pod/pod.go 93.0% 93.3% 0.3
pkg/pod/script.go 99.1% 99.1% -0.0
pkg/pod/security_context_config.go Do not exist 85.7%
pkg/pod/workingdir_init.go 95.0% 94.1% -0.9

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.1% 94.4% -0.7
pkg/pod/pod.go 93.0% 93.3% 0.3
pkg/pod/script.go 99.1% 99.1% -0.0
pkg/pod/security_context_config.go Do not exist 85.7%
pkg/pod/workingdir_init.go 95.0% 94.1% -0.9

@kristofferchr kristofferchr marked this pull request as ready for review February 6, 2025 14:29
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 6, 2025
@kristofferchr kristofferchr force-pushed the enable-read-only-root-filesystem branch from 1c3c312 to 1bbd67c Compare February 7, 2025 07:57
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.1% 94.4% -0.7
pkg/pod/pod.go 93.0% 93.3% 0.3
pkg/pod/script.go 99.1% 99.1% -0.0
pkg/pod/security_context_config.go Do not exist 85.7%
pkg/pod/workingdir_init.go 95.0% 94.1% -0.9

@kristofferchr kristofferchr force-pushed the enable-read-only-root-filesystem branch from 1bbd67c to 5516ec0 Compare February 7, 2025 10:00
@tekton-robot tekton-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 Feb 7, 2025
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.1% 94.4% -0.7
pkg/pod/pod.go 93.0% 93.3% 0.3
pkg/pod/script.go 99.1% 99.1% -0.0
pkg/pod/security_context_config.go Do not exist 100.0%
pkg/pod/workingdir_init.go 95.0% 94.1% -0.9

Prior to this change it was not possible to set readOnlyRootFilesystem for tekton pipeline containers.

This change allows users to set readOnlyRootFilesystem in container securityContext for all containers.
Aligns tekton with industry best practices for kuberenetes security, such as Azure Kubernetes Services deployment safeguards.
@kristofferchr kristofferchr force-pushed the enable-read-only-root-filesystem branch from 5516ec0 to 1fe2500 Compare February 7, 2025 10:52
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/config/feature_flags.go 95.1% 95.2% 0.1
pkg/pod/pod.go 93.0% 93.3% 0.3
pkg/pod/script.go 99.1% 99.1% -0.0
pkg/pod/security_context_config.go Do not exist 100.0%
pkg/pod/workingdir_init.go 95.0% 94.1% -0.9

@kristofferchr
Copy link
Contributor Author

Is this ok-to-test @vdemeester ?

@vdemeester
Copy link
Member

@kristofferchr yes, it is ok, and test rans.. But you will probably need to rebase or commit/amend/push to force the new workflow to run (we moved some of them 🙏🏼 )

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

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:

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

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 24, 2025
@afrittoli afrittoli closed this Feb 24, 2025
@afrittoli afrittoli reopened this Feb 24, 2025
@afrittoli
Copy link
Member

/ok-to-test

@tekton-robot tekton-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 24, 2025
Copy link
Member

@afrittoli afrittoli left a comment

Choose a reason for hiding this comment

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

Thank you for this!
/lgtm

@@ -0,0 +1,21 @@
# Copyright 2021 The Tekton Authors
Copy link
Member

Choose a reason for hiding this comment

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

NIT: this is a new file, so the data should be 2025

@@ -0,0 +1,67 @@
/*
Copyright 2024 The Tekton Authors
Copy link
Member

Choose a reason for hiding this comment

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

NIT: 2025

- `set-security-context-read-only-root-filesystem`: Set this flag to `true` to enable `readOnlyRootFilesystem` in the
security context for containers injected by Tekton. This makes the root filesystem of the container read-only,
enhancing security. Note that this requires `set-security-context` to be enabled. By default, this flag is set
to `false`. Note: This feature does not work in windows as it is not supported there, [Comparison with linux](https://kubernetes.io/docs/concepts/windows/intro/#compatibility-linux-similarities).
Copy link
Member

Choose a reason for hiding this comment

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

+1

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 24, 2025
@tekton-robot tekton-robot merged commit a44d224 into tektoncd:main Feb 24, 2025
29 checks passed
@kristofferchr kristofferchr deleted the enable-read-only-root-filesystem branch February 25, 2025 13:05
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. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants