Skip to content

Commit

Permalink
Add pod examples for user namespace support
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriciovasquezbernal committed Jul 3, 2020
1 parent dc7798d commit 31640cb
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 0 deletions.
15 changes: 15 additions & 0 deletions userns-tests/default-standard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Pod without the userns annotation and without any feature that would cause
# the user namespace support to be disable if available in the runtime.
# User namespace should be used if available in the runtime.
apiVersion: v1
kind: Pod
metadata:
name: default-standard
namespace: default
spec:
restartPolicy: Never
containers:
- name: container1
image: busybox
command: ["sh"]
args: ["-c", "sleep infinity"]
15 changes: 15 additions & 0 deletions userns-tests/detault-special.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Pod without the userns annotation and with special features that would cause
# the user namespace support to be disabled.
apiVersion: v1
kind: Pod
metadata:
name: default-special
namespace: default
spec:
restartPolicy: Never
containers:
- name: container1
image: busybox
command: ["sh"]
args: ["-c", "sleep infinity"]
hostNetwork: true
19 changes: 19 additions & 0 deletions userns-tests/ipc/test-dev-shm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Pod
metadata:
name: test-dev-shm
namespace: default
annotations:
alpha.kinvolk.io/userns: "pod"
spec:
restartPolicy: Never
containers:
- name: reader
image: busybox
command: ["sh"]
args: ["-c", 'content=$(cat /dev/shm//foo.txt); if [[ "$content" != "bar" ]]; then exit 1; else exit 0; fi']
initContainers:
- name: writer
image: busybox
command: ["sh"]
args: ["-c", "echo 'bar' > /dev/shm/foo.txt"]
28 changes: 28 additions & 0 deletions userns-tests/ipc/test-empty-volume.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v1
kind: Pod
metadata:
name: test-empty-volume
namespace: default
annotations:
alpha.kinvolk.io/userns: "pod"
spec:
restartPolicy: Never
containers:
- name: reader
image: busybox
command: ["sh"]
args: ["-c", 'content=$(cat /cache2/foo.txt); if [[ "$content" != "bar" ]]; then exit 1; else exit 0; fi']
volumeMounts:
- mountPath: /cache2
name: cache-volume
initContainers:
- name: writer
image: busybox
command: ["sh"]
args: ["-c", "echo 'bar' > /cache1/foo.txt"]
volumeMounts:
- mountPath: /cache1
name: cache-volume
volumes:
- name: cache-volume
emptyDir: {}
19 changes: 19 additions & 0 deletions userns-tests/ipc/test-shm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Pod
metadata:
name: test-shm
namespace: default
annotations:
alpha.kinvolk.io/userns: "pod"
spec:
restartPolicy: Never
containers:
- name: reader
image: mauriciovasquezbernal/sharedmemoryexample
command: ["bash"]
args: ["-c", 'content=$(/reader); if [[ "$content" != "bar" ]]; then exit 1; else exit 0; fi']
initContainers:
- name: writer
image: mauriciovasquezbernal/sharedmemoryexample
command: ["/writer"]
args: ["bar"]
16 changes: 16 additions & 0 deletions userns-tests/node-special.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Pod user with userns set to "node" mode and special features.
apiVersion: v1
kind: Pod
metadata:
name: node-special
namespace: default
annotations:
alpha.kinvolk.io/userns: "node"
spec:
restartPolicy: Never
containers:
- name: container1
image: busybox
command: ["sh"]
args: ["-c", "sleep infinity"]
hostNetwork: true
15 changes: 15 additions & 0 deletions userns-tests/node-standard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Pod user with userns set to "node" mode.
apiVersion: v1
kind: Pod
metadata:
name: node-standard
namespace: default
annotations:
alpha.kinvolk.io/userns: "node"
spec:
restartPolicy: Never
containers:
- name: container1
image: busybox
command: ["sh"]
args: ["-c", "sleep infinity"]
17 changes: 17 additions & 0 deletions userns-tests/pod-special.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Pod user with userns set to "pod" mode and special features.
# The pod creation will fail.
apiVersion: v1
kind: Pod
metadata:
name: pod-special
namespace: default
annotations:
alpha.kinvolk.io/userns: "pod"
spec:
restartPolicy: Never
containers:
- name: container1
image: busybox
command: ["sh"]
args: ["-c", "sleep infinity"]
hostNetwork: true
16 changes: 16 additions & 0 deletions userns-tests/pod-standard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Pod user with userns set to "pod" mode. Pod creation would fail if userns
# not supported by runtime.
apiVersion: v1
kind: Pod
metadata:
name: pod-standard
namespace: default
annotations:
alpha.kinvolk.io/userns: "pod"
spec:
restartPolicy: Never
containers:
- name: container1
image: busybox
command: ["sh"]
args: ["-c", "sleep infinity"]
33 changes: 33 additions & 0 deletions userns-tests/volumes/pod-with-config-map.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: test-config-map
namespace: default
data:
content: '"This is a ConfigMap"'
---
apiVersion: v1
kind: Pod
metadata:
name: pod-with-configmap
namespace: default
spec:
securityContext:
# Uncomment the following lines to get different behaviours
#runAsUser: 1000
#runAsGroup: 3000
#fsGroup: 2000
restartPolicy: Never
containers:
- name: pod-with-configmap
image: busybox
command: ["sh"]
args: ["-c", "sleep infinity"]
volumeMounts:
- name: config-volume
mountPath: /etc/userns-cm/content
volumes:
- name: config-volume
configMap:
name: test-config-map
defaultMode: 0400

0 comments on commit 31640cb

Please sign in to comment.