Skip to content

Commit 53b976a

Browse files
authored
Merge pull request #98353 from Dhruv-Soni11/RHDEVDOCS-6531
RHDEVDOCS-6531: Adding content for buildah-ns task
2 parents 1c8173e + 336d1b1 commit 53b976a

6 files changed

+194
-0
lines changed

_topic_maps/_topic_map.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ Topics:
117117
File: authenticating-pipelines-repos-using-secrets
118118
- Name: Unprivileged building of container images using Buildah
119119
File: unprivileged-building-of-container-images-using-buildah
120+
- Name: Using buildah-ns tekton task
121+
File: using-buildah-ns-tekton-task
120122
---
121123
Name: Custom Tekton Hub instance
122124
Dir: hub
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// This module is included in the following assemblies:
2+
// * secure/using-buildah-ns-tekton-task.adoc
3+
4+
:_mod-docs-content-type: CONCEPT
5+
6+
[id="op-differences-between-buildah-buildah-ns-tasks_{context}"]
7+
= Differences between `buildah` and `buildah-ns` tasks
8+
9+
The buildah-ns task extends the standard buildah task with the following security-focused changes:
10+
11+
* **Task name**: The task is named `buildah-ns` instead of `buildah`.
12+
* **Annotations**: The task includes security annotations that enable automatic user namespace mapping:
13+
+
14+
----
15+
io.kubernetes.cri-o.userns-mode: "auto"
16+
io.openshift.builder: "true"
17+
----
18+
19+
* **Security model**: User namespace separation improves privilege isolation and limits the impact of potential container escape vulnerabilities.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// This module is included in the following assemblies:
2+
// * secure/using-buildah-ns-tekton-task.adoc
3+
4+
:_mod-docs-content-type: CONCEPT
5+
6+
[id="running-buildah-ns-task_{context}"]
7+
= Running the `buildah-ns` task
8+
9+
You can run the `buildah-ns` task as part of a `PipelineRun` resource.
10+
11+
[source,yaml]
12+
----
13+
apiVersion: tekton.dev/v1beta1
14+
kind: PipelineRun
15+
metadata: {}
16+
spec:
17+
pipelineRef:
18+
name: task-buildah-ns
19+
params:
20+
- name: IMAGE
21+
value: your-image-name # <1>
22+
- name: TLS_VERIFY
23+
value: true
24+
- name: VERBOSE
25+
value: false
26+
workspaces:
27+
- name: source
28+
persistentVolumeClaim:
29+
claimName: your-pvc-name # <2>
30+
----
31+
<1> Replace `your-image-name` with the full name of the container image that you want to build.
32+
<2> Replace `your-pvc-name` with the name of the `PersistentVolumeClaim` (PVC) that stores the application source code.
33+
34+
[NOTE]
35+
====
36+
If the target container registry requires authentication, configure a Kubernetes secret for registry access and link it to the service account that runs the `TaskRun` or `PipelineRun` resources.
37+
====
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// This module is included in the following assemblies:
2+
// * secure/using-buildah-ns-tekton-task.adoc
3+
4+
:_mod-docs-content-type: CONCEPT
5+
6+
[id="security-model-buildah-ns-task_{context}"]
7+
= Security model of the `buildah-ns` task
8+
9+
The `buildah-ns` task applies user namespace isolation to provide privilege separation between containers and the host system.
10+
11+
== UID mapping behavior
12+
13+
When the task runs with namespace annotations, user IDs (UIDs) are mapped as follows:
14+
15+
* **Inside the container**: Processes run as UID 0, which appears as the root user.
16+
* **Outside the container**: The same processes run as a non-zero UID on the host system.
17+
18+
This mapping allows processes inside the container to behave as if they have root privileges while restricting their privileges on the host system.
19+
20+
== Security benefits
21+
22+
User namespace isolation provides the following security advantages:
23+
24+
* **Kernel-level isolation**: Adds an extra isolation boundary between containers.
25+
* **Reduced privilege exposure**: Limits the impact of compromised workloads by running them as non-root users on the host.
26+
* **Container escape protection**: Helps mitigate potential vulnerabilities that allow escaping from the container runtime environment.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// This module is included in the following assemblies:
2+
// * secure/using-buildah-ns-tekton-task.adoc
3+
4+
:_mod-docs-content-type: CONCEPT
5+
6+
[id="workspaces-parameters-results-buildah-ns-task_{context}"]
7+
= Workspaces, parameters, and results for the `buildah-ns` task
8+
9+
The `buildah-ns` task requires a workspace, accepts several parameters for image build customization, and provides results that contain information about the built image.
10+
11+
== Workspace
12+
13+
[options="header"]
14+
|===
15+
| Name | Required | Description
16+
17+
| source
18+
| Yes
19+
| The build context for the container image. Typically contains application source code and a `Containerfile` or `Dockerfile`.
20+
|===
21+
22+
== Parameters
23+
24+
[options="header"]
25+
|===
26+
| Name | Type | Default | Description
27+
28+
| IMAGE
29+
| string
30+
| Required
31+
| Fully qualified name of the image to build, including tag.
32+
33+
| CONTAINERFILE_PATH
34+
| string
35+
| Containerfile
36+
| Path to the container build file relative to the source workspace.
37+
38+
| TLS_VERIFY
39+
| string
40+
| true
41+
| Whether to verify TLS when pushing images. Setting this value to `true` is recommended.
42+
43+
| VERBOSE
44+
| string
45+
| false
46+
| Enables verbose build output.
47+
48+
| SUBDIRECTORY
49+
| string
50+
| .
51+
| Subdirectory in the workspace to use as the build context.
52+
53+
| STORAGE_DRIVER
54+
| string
55+
| overlay
56+
| Storage driver for Buildah, aligned with the cluster node configuration.
57+
58+
| BUILD_EXTRA_ARGS
59+
| string
60+
| Empty
61+
| Additional flags for the `Buildah` build command.
62+
63+
| PUSH_EXTRA_ARGS
64+
| string
65+
| Empty
66+
| Additional flags for the `Buildah` push command.
67+
68+
| SKIP_PUSH
69+
| string
70+
| false
71+
| If set to `true`, the image is not pushed to the registry.
72+
|===
73+
74+
== Results
75+
76+
[options="header"]
77+
|===
78+
| Name | Description
79+
80+
| IMAGE_URL
81+
| Fully qualified name of the built image.
82+
83+
| IMAGE_DIGEST
84+
| SHA256 digest of the built image.
85+
|===
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
:_mod-docs-content-type: ASSEMBLY
2+
include::_attributes/common-attributes.adoc[]
3+
[id="using-buildah-ns-tekton-task"]
4+
= Using buildah-ns Tekton task
5+
:context: using-buildah-ns-tekton-task
6+
7+
toc::[]
8+
9+
The `buildah-ns` Tekton task builds Open Container Initiative (OCI) images without requiring a container runtime daemon, such as the Docker daemon. The task uses `buildah` and applies user namespace isolation to provide enhanced security.
10+
11+
After a successful build, the task produces the following results:
12+
13+
* The fully qualified image name
14+
* The SHA256 digest of the image
15+
16+
The `buildah-ns` task is functionally identical to the standard `buildah` Tekton task, but applies additional security mechanisms to improve container isolation at the kernel level.
17+
18+
include::modules/op-differences-between-buildah-buildah-ns-tasks.adoc[leveloffset=+1]
19+
include::modules/op-security-model-buildah-ns-task.adoc[leveloffset=+1]
20+
include::modules/op-workspaces-parameters-results-buildah-ns-task.adoc[leveloffset=+1]
21+
include::modules/op-running-buildah-ns-task.adoc[leveloffset=+1]
22+
23+
.Additional resources
24+
25+
* link:https://docs.openshift.com/container-platform/latest/authentication/managing-security-context-constraints.html[Managing security context constraints (SCCs)]

0 commit comments

Comments
 (0)