Skip to content

Commit 48c2535

Browse files
authored
Merge pull request #27957 from saschagrunert/seccomp-default
Add documentation about `SeccompDefault` feature
2 parents 165247a + 27a74df commit 48c2535

File tree

3 files changed

+70
-8
lines changed

3 files changed

+70
-8
lines changed

content/en/docs/reference/command-line-tools-reference/feature-gates.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ different Kubernetes components.
156156
| `RotateKubeletServerCertificate` | `false` | Alpha | 1.7 | 1.11 |
157157
| `RotateKubeletServerCertificate` | `true` | Beta | 1.12 | |
158158
| `RunAsGroup` | `true` | Beta | 1.14 | |
159+
| `SeccompDefault` | `false` | Alpha | 1.22 | |
159160
| `ServiceInternalTrafficPolicy` | `false` | Alpha | 1.21 | |
160161
| `ServiceLBNodePortControl` | `false` | Alpha | 1.20 | |
161162
| `ServiceLoadBalancerClass` | `false` | Alpha | 1.21 | |
@@ -783,6 +784,8 @@ Each feature gate is designed for enabling/disabling a specific feature:
783784
instead of the DaemonSet controller.
784785
- `SCTPSupport`: Enables the _SCTP_ `protocol` value in Pod, Service,
785786
Endpoints, EndpointSlice, and NetworkPolicy definitions.
787+
- `SeccompDefault`: Enables the use of `RuntimeDefault` as the default seccomp profile for all workloads.
788+
The seccomp profile is specified in the `securityContext` of a Pod and/or a Container.
786789
- `ServerSideApply`: Enables the [Sever Side Apply (SSA)](/docs/reference/using-api/server-side-apply/)
787790
feature on the API Server.
788791
- `ServiceAccountIssuerDiscovery`: Enable OIDC discovery endpoints (issuer and

content/en/docs/reference/command-line-tools-reference/kubelet.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ RemoveSelfLink=true|false (BETA - default=true)<br/>
514514
RootCAConfigMap=true|false (BETA - default=true)<br/>
515515
RotateKubeletServerCertificate=true|false (BETA - default=true)<br/>
516516
RunAsGroup=true|false (BETA - default=true)<br/>
517+
SeccompDefault=true|false (ALPHA - default=false)<br/>
517518
ServerSideApply=true|false (BETA - default=true)<br/>
518519
ServiceAccountIssuerDiscovery=true|false (BETA - default=true)<br/>
519520
ServiceLBNodePortControl=true|false (ALPHA - default=false)<br/>
@@ -1073,6 +1074,13 @@ WindowsEndpointSliceProxying=true|false (ALPHA - default=false)<br/>
10731074
<td></td><td style="line-height: 130%; word-wrap: break-word;">Timeout of all runtime requests except long running request - `pull`, `logs`, `exec` and `attach`. When timeout exceeded, kubelet will cancel the request, throw out an error and retry later. (DEPRECATED: This parameter should be set via the config file specified by the Kubelet's `--config` flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.)</td>
10741075
</tr>
10751076

1077+
<tr>
1078+
<td colspan="2">--seccomp-default RuntimeDefault&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default: `false`</td>
1079+
</tr>
1080+
<tr>
1081+
<td></td><td style="line-height: 130%; word-wrap: break-word;">&lt;Warning: Alpha feature&gt; Enable the use of RuntimeDefault as the default seccomp profile for all workloads. The SeccompDefault feature gate must be enabled to allow this flag, which is disabled per default.</td>
1082+
</tr>
1083+
10761084
<tr>
10771085
<td colspan="2">--seccomp-profile-root string&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default: `/var/lib/kubelet/seccomp`</td>
10781086
</tr>

content/en/docs/tutorials/clusters/seccomp.md

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@ reviewers:
33
- hasheddan
44
- pjbgf
55
- saschagrunert
6-
title: Restrict a Container's Syscalls with Seccomp
6+
title: Restrict a Container's Syscalls with seccomp
77
content_type: tutorial
88
weight: 20
9+
min-kubernetes-server-version: v1.22
910
---
1011

1112
<!-- overview -->
1213

1314
{{< feature-state for_k8s_version="v1.19" state="stable" >}}
1415

1516
Seccomp stands for secure computing mode and has been a feature of the Linux
16-
kernel since version 2.6.12. It can be used to sandbox the privileges of a
17+
kernel since version 2.6.12. It can be used to sandbox the privileges of a
1718
process, restricting the calls it is able to make from userspace into the
1819
kernel. Kubernetes lets you automatically apply seccomp profiles loaded onto a
1920
Node to your Pods and containers.
@@ -35,16 +36,66 @@ profiles that give only the necessary privileges to your container processes.
3536

3637
## {{% heading "prerequisites" %}}
3738

39+
{{< version-check >}}
40+
3841
In order to complete all steps in this tutorial, you must install
3942
[kind](https://kind.sigs.k8s.io/docs/user/quick-start/) and
4043
[kubectl](/docs/tasks/tools/). This tutorial will show examples
41-
with both alpha (pre-v1.19) and generally available seccomp functionality, so
44+
both alpha (new in v1.22) and generally available seccomp functionality. You should
4245
make sure that your cluster is [configured
4346
correctly](https://kind.sigs.k8s.io/docs/user/quick-start/#setting-kubernetes-version)
4447
for the version you are using.
4548

4649
<!-- steps -->
4750

51+
## Enable the use of `RuntimeDefault` as the default seccomp profile for all workloads
52+
53+
{{< feature-state state="alpha" for_k8s_version="v1.22" >}}
54+
55+
`SeccompDefault` is an optional kubelet
56+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates) as
57+
well as corresponding `--seccomp-default`
58+
[command line flag](/docs/reference/command-line-tools-reference/kubelet).
59+
Both have to be enabled simultaneously to use the feature.
60+
61+
If enabled, the kubelet will use the `RuntimeDefault` seccomp profile by default, which is
62+
defined by the container runtime, instead of using the `Unconfined` (seccomp disabled) mode.
63+
The default profiles aim to provide a strong set
64+
of security defaults while preserving the functionality of the workload. It is
65+
possible that the default profiles differ between container runtimes and their
66+
release versions, for example when comparing those from CRI-O and containerd.
67+
68+
Some workloads may require a lower amount of syscall restrictions than others.
69+
This means that they can fail during runtime even with the `RuntimeDefault`
70+
profile. To mitigate such a failure, you can:
71+
72+
- Run the workload explicitly as `Unconfined`.
73+
- Disable the `SeccompDefault` feature for the nodes. Also making sure that
74+
workloads get scheduled on nodes where the feature is disabled.
75+
- Create a custom seccomp profile for the workload.
76+
77+
If you were introducing this feature into production-like cluster, the Kubernetes project
78+
recommends that you enable this feature gate on a subset of your nodes and then
79+
test workload execution before rolling the change out cluster-wide.
80+
81+
More detailed information about a possible upgrade and downgrade strategy can be
82+
found in the [related Kubernetes Enhancement Proposal (KEP)](https://github.com/kubernetes/enhancements/tree/a70cc18/keps/sig-node/2413-seccomp-by-default#upgrade--downgrade-strategy).
83+
84+
Since the feature is in alpha state it is disabled per default. To enable it,
85+
pass the flags `--feature-gates=SeccompDefault=true --seccomp-default` to the
86+
`kubelet` CLI or enable it via the [kubelet configuration
87+
file](/docs/tasks/administer-cluster/kubelet-config-file/). To enable the
88+
feature gate in [kind](https://kind.sigs.k8s.io), ensure that `kind` provides
89+
the minimum required Kubernetes version and enables the `SeccompDefault` feature
90+
[in the kind configuration](https://kind.sigs.k8s.io/docs/user/quick-start/#enable-feature-gates-in-your-cluster):
91+
92+
```yaml
93+
kind: Cluster
94+
apiVersion: kind.x-k8s.io/v1alpha4
95+
featureGates:
96+
SeccompDefault: true
97+
```
98+
4899
## Create Seccomp Profiles
49100
50101
The contents of these profiles will be explored later on, but for now go ahead
@@ -108,7 +159,7 @@ docker exec -it 6a96207fed4b ls /var/lib/kubelet/seccomp/profiles
108159
audit.json fine-grained.json violation.json
109160
```
110161
111-
## Create a Pod with a Seccomp profile for syscall auditing
162+
## Create a Pod with a seccomp profile for syscall auditing
112163
113164
To start off, apply the `audit.json` profile, which will log all syscalls of the
114165
process, to a new Pod.
@@ -208,7 +259,7 @@ kubectl delete pod/audit-pod
208259
kubectl delete svc/audit-pod
209260
```
210261
211-
## Create Pod with Seccomp Profile that Causes Violation
262+
## Create Pod with seccomp Profile that Causes Violation
212263
213264
For demonstration, apply a profile to the Pod that does not allow for any
214265
syscalls.
@@ -255,7 +306,7 @@ kubectl delete pod/violation-pod
255306
kubectl delete svc/violation-pod
256307
```
257308
258-
## Create Pod with Seccomp Profile that Only Allows Necessary Syscalls
309+
## Create Pod with seccomp Profile that Only Allows Necessary Syscalls
259310
260311
If you take a look at the `fine-pod.json`, you will notice some of the syscalls
261312
seen in the first example where the profile set `"defaultAction":
@@ -339,7 +390,7 @@ kubectl delete pod/fine-pod
339390
kubectl delete svc/fine-pod
340391
```
341392
342-
## Create Pod that uses the Container Runtime Default Seccomp Profile
393+
## Create Pod that uses the Container Runtime Default seccomp Profile
343394
344395
Most container runtimes provide a sane set of default syscalls that are allowed
345396
or not. The defaults can easily be applied in Kubernetes by using the
@@ -364,5 +415,5 @@ The default seccomp profile should provide adequate access for most workloads.
364415
365416
Additional resources:
366417
367-
* [A Seccomp Overview](https://lwn.net/Articles/656307/)
418+
* [A seccomp Overview](https://lwn.net/Articles/656307/)
368419
* [Seccomp Security Profiles for Docker](https://docs.docker.com/engine/security/seccomp/)

0 commit comments

Comments
 (0)