Skip to content

Commit 55df970

Browse files
committed
inits sec ctx
1 parent 62c855b commit 55df970

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

docs/policies.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1-
# Configuring pods to run securely
1+
# Policies
2+
3+
One important tool in the defense in depth strategy are policies. These define
4+
what is or is not allowed and part of it is usually an enforcement component.
5+
6+
In the context of policies, the concept of least privileges is an important one.
7+
So let's have a look at this.
28

39
## Least privileges
410

5-
http://canihaznonprivilegedcontainers.info/
11+
First off we start with the simple case of a Kubernetes security context,
12+
allowing you to specify runtime policies around privileges and access control.
13+
14+
We will be using an [example from the Kubernetes docs](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/)
15+
so that you can read up on the details later on.
16+
17+
```
18+
kubectl apply -f
19+
https://raw.githubusercontent.com/k8s-sec/cloud-native-security-tutorial/master/res/pod-security-context.yaml
20+
```
21+
22+
See more at http://canihaznonprivilegedcontainers.info/
623

724
## Network policies
825

res/pod-security-context.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: security-context
5+
spec:
6+
securityContext:
7+
runAsUser: 1000
8+
runAsGroup: 3000
9+
fsGroup: 2000
10+
volumes:
11+
- name: datavol
12+
emptyDir: {}
13+
containers:
14+
- name: main
15+
image: amazonlinux:2
16+
command: [ "sh", "-c", "sleep 3600" ]
17+
volumeMounts:
18+
- name: datavol
19+
mountPath: /data
20+
securityContext:
21+
allowPrivilegeEscalation: false

0 commit comments

Comments
 (0)