forked from openshift/release
-
Notifications
You must be signed in to change notification settings - Fork 0
/
master-sidecar-3.yaml
128 lines (116 loc) · 3.14 KB
/
master-sidecar-3.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
kind: Template
apiVersion: template.openshift.io/v1
parameters:
- name: JOB_NAME_SAFE
required: true
- name: IMAGE_CONTROL_PLANE
required: true
- name: LOCAL_IMAGE_TEST_BIN
required: true
- name: COMMAND
required: true
- name: NAMESPACE
required: true
objects:
# We want the cluster to be able to access these images
- kind: RoleBinding
apiVersion: authorization.openshift.io/v1
metadata:
name: ${JOB_NAME_SAFE}-image-puller
namespace: ${NAMESPACE}
roleRef:
name: system:image-puller
subjects:
- kind: SystemGroup
name: system:unauthenticated
- kind: SystemGroup
name: system:authenticated
# The pod spins up a simple openshift control plane as a sidecar and waits for the
# COMMAND specified to the template to be executed, before itself exiting. The test
# container is given access to the generated config and the admin.kubeconfig.
- kind: Pod
apiVersion: v1
metadata:
name: ${JOB_NAME_SAFE}
namespace: ${NAMESPACE}
spec:
restartPolicy: Never
activeDeadlineSeconds: 7200
terminationGracePeriodSeconds: 600
volumes:
- name: artifacts
emptyDir: {}
- name: shared-tmp
emptyDir: {}
containers:
# Once admin.kubeconfig exists, executes shared tests
- name: test
image: ${LOCAL_IMAGE_TEST_BIN}
terminationMessagePolicy: FallbackToLogsOnError
volumeMounts:
- name: shared-tmp
mountPath: /tmp/shared
- name: artifacts
mountPath: /tmp/artifacts
env:
- name: ARTIFACT_DIR
value: /tmp/artifacts
command:
- /bin/bash
- -c
- |
#!/bin/bash
set -euo pipefail
trap 'touch /tmp/shared/exit' EXIT
trap 'jobs -p | xargs -r kill || true; exit 0' TERM
# wait until the master job creates admin.kubeconfig
while true; do
if [[ ! -f /tmp/shared/admin.kubeconfig ]]; then
sleep 5 & wait
continue
fi
break
done
echo "Found kubeconfig"
export KUBECONFIG=/tmp/shared/admin.kubeconfig
${COMMAND}
# Start a standalone master
- name: control-plane
image: ${IMAGE_CONTROL_PLANE}
terminationMessagePolicy: FallbackToLogsOnError
volumeMounts:
- name: shared-tmp
mountPath: /tmp/shared
- name: artifacts
mountPath: /tmp/artifacts
env:
- name: ARTIFACT_DIR
value: /tmp/artifacts
- name: TYPE
value: ${CLUSTER_TYPE}
command:
- /bin/bash
- -c
- |
#!/bin/bash
set -euo pipefail
function teardown() {
set +e
echo "Gathering artifacts ..."
}
trap 'teardown' EXIT
trap 'jobs -p | xargs -r kill || true; exit 0' TERM
(
while true; do
if [[ -f /tmp/shared/exit ]]; then
echo "Shutting down"
kill 1
exit 0
fi
sleep 5
done
) &
mkdir /tmp/cluster && cd /tmp/cluster
openshift start master --write-config=/tmp/shared
openshift start master --config=/tmp/shared/master-config.yaml &
wait $!