Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 62 additions & 2 deletions hack/libe2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,16 @@ function kube_create_pv() {
local name="${1}"
local capacity="${2}"
local storage_class="${3}"
local schedulable_nodes
schedulable_nodes=$(
kubectl get nodes \
--output \
'jsonpath={range $.items[*]}{.metadata.name} {.spec.taints[*].effect}{"\n"}{end}' \
| grep -v NoSchedule)
local node_name
node_name=$(python -c 'import random,sys; print(random.choice(sys.argv[1:]))' $schedulable_nodes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we assume python's going to be installed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, and we're eventually rewriting these tests in golang (#242) so this'll do for now.


local path="hostpath_pvs/${name}/"

kubectl create --filename - <<EOF
apiVersion: v1
Expand All @@ -261,15 +271,65 @@ metadata:
name: ${name}
labels:
purpose: test
annotations:
"volume.alpha.kubernetes.io/node-affinity": '{
"requiredDuringSchedulingIgnoredDuringExecution": {
"nodeSelectorTerms": [
{ "matchExpressions": [
{ "key": "kubernetes.io/hostname",
"operator": "In",
"values": ["${node_name}"]
}
]}
]}
}'
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: ${capacity}
hostPath:
path: /tmp/hostpath_pvs/${name}/
local:
path: /tmp/${path}/
storageClassName: ${storage_class}
persistentVolumeReclaimPolicy: Delete
EOF

# Run a job (on the target node) to create the host directory.
kubectl create --namespace kube-system --filename - <<EOF
apiVersion: batch/v1
kind: Job
metadata:
name: "navigator-e2e-create-pv-${name}"
labels:
purpose: test
spec:
template:
spec:
restartPolicy: "OnFailure"
nodeSelector:
kubernetes.io/hostname: "${node_name}"
containers:
- name: "mkdir"
image: "busybox:latest"
resources:
limits:
cpu: "10m"
memory: "8Mi"
requests:
cpu: "10m"
memory: "8Mi"
securityContext:
privileged: true
command:
- "/bin/mkdir"
- "-p"
- "/HOST_TMP/${path}"
volumeMounts:
- mountPath: /HOST_TMP
name: host-tmp
volumes:
- name: host-tmp
hostPath:
path: /tmp
EOF
}