19
19
set -o errexit -o nounset -o pipefail
20
20
21
21
OPENSTACK_CLOUD_YAML_FILE=${OPENSTACK_CLOUD_YAML_FILE:- " /tmp/clouds.yaml" }
22
+ IMAGE_URL=" https://github.com/kubernetes-sigs/cluster-api-provider-openstack/releases/download/v0.3.0/ubuntu-1910-kube-v1.17.3.qcow2"
23
+ CIRROS_URL=" http://download.cirros-cloud.net/0.5.1/cirros-0.5.1-x86_64-disk.img"
22
24
OPENSTACK_IMAGE_NAME=" ubuntu-1910-kube-v1.17.3"
25
+ OPENSTACK_BASTION_IMAGE_NAME=" cirros"
23
26
OPENSTACK_DNS_NAMESERVERS=${OPENSTACK_DNS_NAMESERVERS:- " 192.168.200.1" }
24
27
OPENSTACK_NODE_MACHINE_FLAVOR=${OPENSTACK_NODE_MACHINE_FLAVOR:- " m1.small" }
25
28
OPENSTACK_CONTROL_PLANE_MACHINE_FLAVOR=${OPENSTACK_CONTROL_PLANE_MACHINE_FLAVOR:- " m1.medium" }
29
+ OPENSTACK_BASTION_MACHINE_FLAVOR=${OPENSTACK_BASTION_MACHINE_FLAVOR:- " m1.tiny" }
26
30
OPENSTACK_CLUSTER_TEMPLATE=${OPENSTACK_CLUSTER_TEMPLATE:- " ./templates/cluster-template-without-lb.yaml" }
27
31
CLUSTER_NAME=${CLUSTER_NAME:- " capi-quickstart" }
28
32
OPENSTACK_SSH_KEY_NAME=${OPENSTACK_SSH_KEY_NAME:- " ${CLUSTER_NAME} -key" }
@@ -119,7 +123,7 @@ dump_capo_logs() {
119
123
openstack console log show " ${node} " > " ${dir} /console.log" || true
120
124
121
125
ssh_key_pem=" /tmp/${OPENSTACK_SSH_KEY_NAME} .pem"
122
- PROXY_COMMAND=" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=30 -x -W %h:22 -i ${ssh_key_pem} ubuntu @${jump_node} "
126
+ PROXY_COMMAND=" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=30 -x -W %h:22 -i ${ssh_key_pem} cirros @${jump_node} "
123
127
node=$( openstack port show ${node} -f json -c fixed_ips | jq ' .fixed_ips[0].ip_address' -r)
124
128
125
129
ssh-to-node " ${node} " " ${jump_node} " " sudo chmod -R a+r /var/log" || true
@@ -154,9 +158,9 @@ function ssh-to-node() {
154
158
155
159
ssh_key_pem=" /tmp/${OPENSTACK_SSH_KEY_NAME} .pem"
156
160
ssh_params=" -o LogLevel=quiet -o ConnectTimeout=30 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
157
- scp $ssh_params -i $ssh_key_pem $ssh_key_pem " ubuntu @${jump} :$ssh_key_pem "
161
+ scp $ssh_params -i $ssh_key_pem $ssh_key_pem " cirros @${jump} :$ssh_key_pem "
158
162
ssh $ssh_params -i $ssh_key_pem \
159
- -o " ProxyCommand ssh $ssh_params -W %h:%p -i $ssh_key_pem ubuntu @${jump} " \
163
+ -o " ProxyCommand ssh $ssh_params -W %h:%p -i $ssh_key_pem cirros @${jump} " \
160
164
ubuntu@" ${node} " " ${cmd} "
161
165
}
162
166
@@ -170,33 +174,32 @@ create_key_pair() {
170
174
}
171
175
172
176
upload_image () {
177
+ # $1: image name
178
+ # $2: image url
179
+
173
180
echo " Upload image"
174
181
175
182
# Remove old image if we don't want to reuse it
176
183
if [[ " ${REUSE_OLD_IMAGES:- true} " == " false" ]]; then
177
- image_id=$( openstack image list --name=${OPENSTACK_IMAGE_NAME} -f value -c ID)
184
+ image_id=$( openstack image list --name=$1 -f value -c ID)
178
185
if [[ ! -z " $image_id " ]]; then
179
- echo " Deleting old image ${OPENSTACK_IMAGE_NAME} with id: ${image_id} "
186
+ echo " Deleting old image $1 with id: ${image_id} "
180
187
openstack image delete ${image_id}
181
188
fi
182
189
fi
183
190
184
- image=$( openstack image list --name=${OPENSTACK_IMAGE_NAME} -f value -c Name)
191
+ image=$( openstack image list --name=$1 -f value -c Name)
185
192
if [[ ! -z " $image " ]]; then
186
- echo " Image ${OPENSTACK_IMAGE_NAME} already exists"
193
+ echo " Image $1 already exists"
187
194
return
188
195
fi
189
196
190
- source_image_url=" https://github.com/kubernetes-sigs/cluster-api-provider-openstack/releases/download/v0.3.0/ubuntu-1910-kube-v1.17.3.qcow2"
191
- echo " Download image ${OPENSTACK_IMAGE_NAME} from ${source_image_url} "
192
- tmp_source_image=/tmp/ubuntu-1910.ova.qcow2
193
- wget -q -c ${source_image_url} -O ${tmp_source_image}
197
+ tmpfile=$( mktemp)
198
+ echo " Download image $1 from $2 "
199
+ wget -q -c $2 -O ${tmpfile}
194
200
195
- echo " Uploading image ${tmp_source_image} as ${OPENSTACK_IMAGE_NAME} "
196
- openstack image create --disk-format qcow2 \
197
- --private \
198
- --container-format bare \
199
- --file " ${tmp_source_image} " ${OPENSTACK_IMAGE_NAME}
201
+ echo " Uploading image $1 "
202
+ openstack image create --disk-format qcow2 --private --container-format bare --file " ${tmpfile} " $1
200
203
}
201
204
202
205
install_prereqs () {
@@ -397,7 +400,8 @@ main() {
397
400
fi
398
401
if [[ -z " ${SKIP_UPLOAD_IMAGE:- } " ]]; then
399
402
echo " Uploading image..."
400
- upload_image
403
+ upload_image ${OPENSTACK_IMAGE_NAME} ${IMAGE_URL}
404
+ upload_image ${OPENSTACK_BASTION_IMAGE_NAME} ${CIRROS_URL}
401
405
fi
402
406
403
407
build
0 commit comments