Skip to content

Commit 4e5f9a1

Browse files
authored
Merge pull request #318 from andyzhangx/nonroot-container-test
test: run non-root container test
2 parents 10aa6c2 + 62d5932 commit 4e5f9a1

File tree

6 files changed

+39
-10
lines changed

6 files changed

+39
-10
lines changed

Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,7 @@ create-metrics-svc:
143143

144144
.PHONY: create-example-deployment
145145
create-example-deployment:
146-
kubectl apply -f deploy/example/storageclass-blobfuse.yaml
147-
kubectl apply -f deploy/example/deployment.yaml
148-
kubectl apply -f deploy/example/statefulset.yaml
146+
./hack/verify-examples.sh
149147

150148
.PHONY: delete-metrics-svc
151149
delete-metrics-svc:

deploy/example/statefulset-nonroot.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
apiVersion: apps/v1
33
kind: StatefulSet
44
metadata:
5-
name: statefulset-blob
5+
name: statefulset-blob-nonroot
66
labels:
77
app: nginx
88
spec:
9-
serviceName: statefulset-blob
9+
serviceName: statefulset-blob-nonroot
1010
replicas: 1
1111
template:
1212
metadata:
@@ -23,9 +23,9 @@ spec:
2323
- name: statefulset-blob
2424
image: andyzhangx/ubuntu1604:nonroot
2525
command:
26-
- "/bin/sh"
26+
- "/bin/bash"
2727
- "-c"
28-
- while true; do echo $(date) >> /mnt/blob/outfile; sleep 1; done
28+
- set -euo pipefail; while true; do echo $(date) >> /mnt/blob/outfile; sleep 1; done
2929
volumeMounts:
3030
- name: persistent-storage
3131
mountPath: /mnt/blob

deploy/example/statefulset.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ spec:
1717
"kubernetes.io/os": linux
1818
containers:
1919
- name: statefulset-blob
20-
image: mcr.microsoft.com/oss/nginx/nginx:1.17.3-alpine
20+
image: mcr.microsoft.com/oss/nginx/nginx:1.19.5
2121
command:
22-
- "/bin/sh"
22+
- "/bin/bash"
2323
- "-c"
24-
- while true; do echo $(date) >> /mnt/blob/outfile; sleep 1; done
24+
- set -euo pipefail; while true; do echo $(date) >> /mnt/blob/outfile; sleep 1; done
2525
volumeMounts:
2626
- name: persistent-storage
2727
mountPath: /mnt/blob

hack/verify-examples.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
# Copyright 2020 The Kubernetes Authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -euo pipefail
17+
18+
echo "begin to create deployment examples ..."
19+
kubectl apply -f deploy/example/storageclass-blobfuse.yaml
20+
kubectl apply -f deploy/example/deployment.yaml
21+
kubectl apply -f deploy/example/statefulset.yaml
22+
kubectl apply -f deploy/example/statefulset-nonroot.yaml
23+
24+
echo "sleep 90s ..."
25+
sleep 90
26+
27+
kubectl get pods --field-selector status.phase=Running | grep deployment-blob
28+
kubectl get pods --field-selector status.phase=Running | grep statefulset-blob-0
29+
kubectl get pods --field-selector status.phase=Running | grep statefulset-blob-nonroot-0
30+
31+
echo "deployment examples running completed."

test/utils/check_driver_pods_restart.sh

100644100755
File mode changed.

test/utils/get_storage_account_secret_name.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)