Skip to content

Commit bf3bc89

Browse files
doc/samples: update pod security standards to clarifies usage (#5867)
* doc: update pod security standards to clarifies usage * Update website/content/en/docs/best-practices/pod-security-standards.md Co-authored-by: Bryce Palmer <[email protected]> * Update website/content/en/docs/best-practices/pod-security-standards.md Co-authored-by: Bryce Palmer <[email protected]> Co-authored-by: Bryce Palmer <[email protected]>
1 parent 013d9c8 commit bf3bc89

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

hack/generate/samples/internal/go/v3/memcached_with_webhooks.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,10 @@ func (r *MemcachedReconciler) deploymentForMemcached(m *cachev1alpha1.Memcached)
413413
// More info: https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted
414414
SecurityContext: &corev1.PodSecurityContext{
415415
RunAsNonRoot: &[]bool{true}[0],
416+
// Please ensure that you can use SeccompProfile and do NOT use
417+
// this field if your project must work on old Kubernetes
418+
// versions < 1.19 or on vendors versions which
419+
// do NOT support this field by default (i.e. Openshift < 4.11)
416420
SeccompProfile: &corev1.SeccompProfile{
417421
Type: corev1.SeccompProfileTypeRuntimeDefault,
418422
},

testdata/go/v3/memcached-operator/controllers/memcached_controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ func (r *MemcachedReconciler) deploymentForMemcached(m *cachev1alpha1.Memcached)
159159
// More info: https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted
160160
SecurityContext: &corev1.PodSecurityContext{
161161
RunAsNonRoot: &[]bool{true}[0],
162+
// Please ensure that you can use SeccompProfile and do NOT use
163+
// this field if your project must work on old Kubernetes
164+
// versions < 1.19 or on vendors versions which
165+
// do NOT support this field by default (i.e. Openshift < 4.11)
162166
SeccompProfile: &corev1.SeccompProfile{
163167
Type: corev1.SeccompProfileTypeRuntimeDefault,
164168
},

website/content/en/docs/best-practices/pod-security-standards.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,23 @@ on the namespace level will **not** be admitted. In this way, it will not be pos
2020

2121
#### How should I configure my Operators and Operands to comply with the criteria?
2222

23-
- **For common cases that do not require escalating privileges:** configure all containers to comply with the [restrictive][restricted] policy as shown in the following the examples:
23+
- **For common cases that do not require escalating privileges:** configure all containers to comply with the [restricted][restricted] policy as shown in the following the examples:
2424

25-
**On Kubernetes manifests:**
25+
**IMPORTANT NOTE** The `seccompProfile` field to define that a container is [restricted][restricted] was introduced with K8s `1.19` and might **not** be supported on some vendors by default.
26+
Please, do **not** use this field if you are looking to build Operators that work on K8s versions < `1.19` or on vendors that do **not** support this field. Having this field when it is not supported can result in your Pods/Containers **not** being allowed to run (i.e. On Openshift versions < `4.11` with its default configuration the deployments will fail with errors like `Forbidden: seccomp`.)
27+
However, if you are developing solutions to be distributed on Kubernetes versions => `1.19` and or for example, Openshift versions >= `4.11` it is highly recommended that this field is used to
28+
ensure that all your Pods/Containers are [restricted][restricted] unless they require escalated privileges.
29+
30+
**In Kubernetes manifests:**
2631

2732
```yaml
2833
spec:
2934
securityContext:
3035
runAsNonRoot: true
36+
# Please ensure that you can use SeccompProfile and do not use
37+
# if your project must work on old Kubernetes
38+
# versions < 1.19 or on vendors versions which
39+
# do NOT support this field by default (i.e. Openshift < 4.11 )
3140
seccompProfile:
3241
type: RuntimeDefault
3342
...
@@ -56,6 +65,10 @@ dep:= &appsv1.Deployment{
5665
// Ensure restrictive context for the Pod
5766
SecurityContext: &corev1.PodSecurityContext{
5867
RunAsNonRoot: &[]bool{true}[0],
68+
// Please ensure that you can use SeccompProfile and do NOT use
69+
// this filed if your project must work on old Kubernetes
70+
// versions < 1.19 or on vendors versions which
71+
// do NOT support this field by default (i.e. Openshift < 4.11)
5972
SeccompProfile: &corev1.SeccompProfile{
6073
Type: corev1.SeccompProfileTypeRuntimeDefault,
6174
},

0 commit comments

Comments
 (0)