Skip to content

Commit

Permalink
[git-clone] Update docs, etc for nonroot user
Browse files Browse the repository at this point in the history
This commit updates the docs, samples and tests required to run this
task as a non-root user.

Fix tektoncd#1044
  • Loading branch information
concaf authored and tekton-robot committed Aug 18, 2022
1 parent 231510b commit e91c913
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 1 deletion.
42 changes: 41 additions & 1 deletion task/git-clone/0.8/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# `git-clone`

**Please Note: this Task is only compatible with Tekton Pipelines versions 0.29.0 and greater!**
**Note: this Task is only compatible with Tekton Pipelines versions 0.29.0 and greater!**

**Note: this Task is not backwards compatible with the previous versions as it is now run as a non-root user!**

This `Task` has two required inputs:

Expand All @@ -20,6 +22,44 @@ workspace will end up owned by user 65532.

## Workspaces

**Note**: This task is run as a non-root user with UID 65532 and GID 65532.
Generally, the default permissions for storage volumes are configured for the
root user. To make the volumes accessible by the non-root user, you will need
to either configure the permissions manually or set the `fsGroup` field under
`PodSecurityContext` in your TaskRun or PipelineRun.

An example PipelineRun will look like:
```yaml
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: git-clone-
spec:
pipelineRef:
name: git-clone-pipeline
podTemplate:
securityContext:
fsGroup: 65532
...
...
```

An example TaskRun will look like:
```yaml
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: taskrun
spec:
taskRef:
name: git-clone
podTemplate:
securityContext:
fsGroup: 65532
...
...
```

* **output**: A workspace for this Task to fetch the git repository in to.
* **ssh-directory**: An optional workspace to provide SSH credentials. At
minimum this should include a private key but can also include other common
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ metadata:
spec:
pipelineRef:
name: cat-branch-readme
podTemplate:
securityContext:
fsGroup: 65532
workspaces:
- name: shared-data
volumeClaimTemplate:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ metadata:
spec:
pipelineRef:
name: checking-out-a-revision
podTemplate:
securityContext:
fsGroup: 65532
workspaces:
- name: shared-data
volumeClaimTemplate:
Expand Down
3 changes: 3 additions & 0 deletions task/git-clone/0.8/samples/git-clone-for-ssl-ca.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ metadata:
spec:
pipelineRef:
name: cat-branch-readme
podTemplate:
securityContext:
fsGroup: 65532
workspaces:
- name: shared-data
volumeClaimTemplate:
Expand Down
3 changes: 3 additions & 0 deletions task/git-clone/0.8/samples/git-clone-sparse-checkout.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ metadata:
spec:
pipelineRef:
name: sparse-checkout-list-dir
podTemplate:
securityContext:
fsGroup: 65532
workspaces:
- name: shared-data
volumeClaimTemplate:
Expand Down
3 changes: 3 additions & 0 deletions task/git-clone/0.8/samples/using-git-clone-result.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ metadata:
spec:
pipelineRef:
name: validate-tag-sha
podTemplate:
securityContext:
fsGroup: 65532
workspaces:
- name: output
emptyDir: {} # We don't care about the repo contents in this example, just the "commit" result
Expand Down
30 changes: 30 additions & 0 deletions task/git-clone/0.8/tests/run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ spec:
emptyDir: {}
taskRef:
name: git-clone
podTemplate:
securityContext:
fsGroup: 65532
params:
- name: url
value: https://github.com/kelseyhightower/nocode
Expand All @@ -23,6 +26,9 @@ spec:
emptyDir: {}
taskRef:
name: git-clone
podTemplate:
securityContext:
fsGroup: 65532
params:
- name: url
value: https://github.com/kelseyhightower/nocode
Expand All @@ -39,6 +45,9 @@ spec:
emptyDir: {}
taskRef:
name: git-clone
podTemplate:
securityContext:
fsGroup: 65532
params:
- name: url
value: https://github.com/githubtraining/example-dependency
Expand All @@ -53,6 +62,9 @@ spec:
workspaces:
- name: output
emptyDir: {}
podTemplate:
securityContext:
fsGroup: 65532
taskRef:
name: git-clone
params:
Expand All @@ -71,6 +83,9 @@ spec:
emptyDir: {}
taskRef:
name: git-clone
podTemplate:
securityContext:
fsGroup: 65532
params:
- name: url
value: https://github.com/kelseyhightower/nocode
Expand All @@ -89,6 +104,9 @@ spec:
emptyDir: {}
taskRef:
name: git-clone
podTemplate:
securityContext:
fsGroup: 65532
params:
- name: url
value: https://github.com/kelseyhightower/nocode
Expand All @@ -105,6 +123,9 @@ spec:
emptyDir: {}
taskRef:
name: git-clone
podTemplate:
securityContext:
fsGroup: 65532
params:
- name: url
value: https://github.com/kelseyhightower/nocode
Expand All @@ -121,6 +142,9 @@ spec:
emptyDir: {}
taskRef:
name: git-clone
podTemplate:
securityContext:
fsGroup: 65532
params:
- name: url
value: https://github.com/kelseyhightower/nocode
Expand All @@ -137,6 +161,9 @@ spec:
emptyDir: {}
taskRef:
name: git-clone
podTemplate:
securityContext:
fsGroup: 65532
params:
- name: url
value: https://github.com/kelseyhightower/nocode
Expand All @@ -153,6 +180,9 @@ spec:
emptyDir: {}
taskRef:
name: git-clone
podTemplate:
securityContext:
fsGroup: 65532
params:
- name: url
value: https://github.com/kelseyhightower/nocode
Expand Down

0 comments on commit e91c913

Please sign in to comment.