You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -77,6 +78,89 @@ The configuration use the exact options that you find in the Kubernetes document
77
78
78
79
### Examples
79
80
81
+
#### Implement the restricted Pod Security Standard
82
+
83
+
This example requires OpenFaaS for Enterprises and is aimed at securing enterprise and multi-tenant workloads.
84
+
85
+
[Pod Security Standards](https://kubernetes.io/docs/concepts/security/pod-security-standards/) were introduced in K8s v1.25 and are a set of best practices for securing your Pods. The `restricted` profile is the most secure option.
86
+
87
+
The below example deploys a function which will pass the `restricted` Pod Security Standard.
88
+
89
+
It defines:
90
+
91
+
* A new namespace for functions called `restricted-fn`, which has been labeled with `pod-security.kubernetes.io/enforce: restricted`
92
+
* A new Profile called `restricted` which sets the Pod Security Context to use `RuntimeDefault` and `runAsNonRoot: true`
93
+
* A function called `env` which uses the `restricted` Profile
94
+
95
+
```yaml
96
+
---
97
+
# Namespace "restricted-fn"
98
+
apiVersion: v1
99
+
kind: Namespace
100
+
metadata:
101
+
name: restricted-fn
102
+
labels:
103
+
kubernetes.io/metadata.name: dev
104
+
pod-security.kubernetes.io/enforce: restricted
105
+
annotations:
106
+
openfaas: "1"
107
+
---
108
+
# Profile "restricted"
109
+
apiVersion: openfaas.com/v1
110
+
kind: Profile
111
+
metadata:
112
+
name: restricted
113
+
namespace: openfaas
114
+
spec:
115
+
podSecurityContext:
116
+
seccompProfile:
117
+
type: RuntimeDefault
118
+
runAsNonRoot: true
119
+
---
120
+
# Function "restricted-fn"
121
+
apiVersion: openfaas.com/v1
122
+
kind: Function
123
+
metadata:
124
+
name: env
125
+
namespace: restricted-fn
126
+
spec:
127
+
name: env
128
+
image: ghcr.io/openfaas/alpine:latest
129
+
environment:
130
+
fprocess: "env"
131
+
annotations:
132
+
com.openfaas.profile: restricted
133
+
```
134
+
135
+
The `securityContext` for the container is not exposed as a separate configuration item since all required values (apart from `capabilities` are set at the Pod level instead.
136
+
137
+
By default, OpenFaaS for Enterprises will drop all Linux capabilities from the container. This is a requirement of the `restricted` Pod Security Standard.
138
+
139
+
The following will be added to the container's securityContext:
140
+
141
+
```yaml
142
+
securityContext:
143
+
capabilities:
144
+
drop:
145
+
- ALL
146
+
allowPrivilegeEscalation: false
147
+
```
148
+
149
+
When the Helm chart has the following value set:
150
+
151
+
```yaml
152
+
functions:
153
+
setNonRootUser: true
154
+
```
155
+
156
+
Then the following additional fields will be set in the container's securityContext:
0 commit comments