Skip to content

Commit 74aadf7

Browse files
authored
Merge pull request #452 from andyzhangx/remove-0777
test: add nonroot application tests
2 parents 8d12648 + 2211016 commit 74aadf7

File tree

5 files changed

+150
-2
lines changed

5 files changed

+150
-2
lines changed

deploy/example/deployment-nfs.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
kind: PersistentVolumeClaim
3+
apiVersion: v1
4+
metadata:
5+
name: pvc-blob-nfs
6+
spec:
7+
accessModes:
8+
- ReadWriteMany
9+
resources:
10+
requests:
11+
storage: 1Gi
12+
storageClassName: blob-nfs
13+
---
14+
apiVersion: apps/v1
15+
kind: Deployment
16+
metadata:
17+
labels:
18+
app: nginx
19+
name: deployment-blob-nfs
20+
spec:
21+
replicas: 1
22+
selector:
23+
matchLabels:
24+
app: nginx
25+
template:
26+
metadata:
27+
labels:
28+
app: nginx
29+
name: deployment-blob-nfs
30+
spec:
31+
nodeSelector:
32+
"kubernetes.io/os": linux
33+
containers:
34+
- name: deployment-blob-nfs
35+
image: mcr.microsoft.com/oss/nginx/nginx:1.17.3-alpine
36+
command:
37+
- "/bin/sh"
38+
- "-c"
39+
- while true; do echo $(date) >> /mnt/blob/outfile; sleep 1; done
40+
volumeMounts:
41+
- name: blob
42+
mountPath: "/mnt/blob"
43+
readOnly: false
44+
volumes:
45+
- name: blob
46+
persistentVolumeClaim:
47+
claimName: pvc-blob-nfs
48+
strategy:
49+
rollingUpdate:
50+
maxSurge: 0
51+
maxUnavailable: 1
52+
type: RollingUpdate

deploy/example/statefulset-nfs.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: StatefulSet
4+
metadata:
5+
name: statefulset-blob-nfs
6+
labels:
7+
app: nginx
8+
spec:
9+
serviceName: statefulset-blob-nfs
10+
replicas: 1
11+
template:
12+
metadata:
13+
labels:
14+
app: nginx
15+
spec:
16+
nodeSelector:
17+
"kubernetes.io/os": linux
18+
containers:
19+
- name: statefulset-blob-nfs
20+
image: mcr.microsoft.com/oss/nginx/nginx:1.19.5
21+
command:
22+
- "/bin/bash"
23+
- "-c"
24+
- set -euo pipefail; while true; do echo $(date) >> /mnt/blob/outfile; sleep 1; done
25+
volumeMounts:
26+
- name: persistent-storage
27+
mountPath: /mnt/blob
28+
updateStrategy:
29+
type: RollingUpdate
30+
selector:
31+
matchLabels:
32+
app: nginx
33+
volumeClaimTemplates:
34+
- metadata:
35+
name: persistent-storage
36+
annotations:
37+
volume.beta.kubernetes.io/storage-class: blob-nfs
38+
spec:
39+
accessModes: ["ReadWriteMany"]
40+
resources:
41+
requests:
42+
storage: 100Gi
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: StatefulSet
4+
metadata:
5+
name: statefulset-blob-nonroot-nfs
6+
labels:
7+
app: nginx
8+
spec:
9+
serviceName: statefulset-blob-nonroot-nfs
10+
replicas: 1
11+
template:
12+
metadata:
13+
labels:
14+
app: nginx
15+
spec:
16+
securityContext: # optional just to make sure user is non-root
17+
runAsUser: 10001
18+
runAsGroup: 10001
19+
fsGroup: 10001
20+
nodeSelector:
21+
"kubernetes.io/os": linux
22+
containers:
23+
- name: statefulset-blob
24+
image: andyzhangx/ubuntu1604:nonroot
25+
command:
26+
- "/bin/bash"
27+
- "-c"
28+
- set -euo pipefail; while true; do echo $(date) >> /mnt/blob/outfile; sleep 1; done
29+
volumeMounts:
30+
- name: persistent-storage
31+
mountPath: /mnt/blob
32+
updateStrategy:
33+
type: RollingUpdate
34+
selector:
35+
matchLabels:
36+
app: nginx
37+
volumeClaimTemplates:
38+
- metadata:
39+
name: persistent-storage
40+
annotations:
41+
volume.beta.kubernetes.io/storage-class: blob-nfs
42+
spec:
43+
accessModes: ["ReadWriteMany"]
44+
resources:
45+
requests:
46+
storage: 100Gi

hack/verify-examples.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,22 @@ set -euo pipefail
1717

1818
echo "begin to create deployment examples ..."
1919
kubectl apply -f deploy/example/storageclass-blobfuse.yaml
20+
kubectl apply -f deploy/example/storageclass-blob-nfs.yaml
2021
kubectl apply -f deploy/example/deployment.yaml
2122
kubectl apply -f deploy/example/statefulset.yaml
2223
kubectl apply -f deploy/example/statefulset-nonroot.yaml
24+
kubectl apply -f deploy/example/deployment-nfs.yaml
25+
kubectl apply -f deploy/example/statefulset-nfs.yaml
26+
kubectl apply -f deploy/example/statefulset-nonroot-nfs.yaml
2327

24-
echo "sleep 60s ..."
25-
sleep 60
28+
echo "sleep 90s ..."
29+
sleep 90
2630

2731
kubectl get pods --field-selector status.phase=Running | grep deployment-blob
2832
kubectl get pods --field-selector status.phase=Running | grep statefulset-blob-0
2933
kubectl get pods --field-selector status.phase=Running | grep statefulset-blob-nonroot-0
34+
kubectl get pods --field-selector status.phase=Running | grep deployment-blob-nfs
35+
kubectl get pods --field-selector status.phase=Running | grep statefulset-blob-nfs-0
36+
kubectl get pods --field-selector status.phase=Running | grep statefulset-blob-nonroot-nfs-0
3037

3138
echo "deployment examples running completed."

test/external-e2e/run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ setup_e2e_binaries() {
3939
}
4040

4141
print_logs() {
42+
bash ./hack/verify-examples.sh
4243
echo "print out driver logs ..."
4344
bash ./test/utils/blob_log.sh
4445
}

0 commit comments

Comments
 (0)