@@ -2130,6 +2130,7 @@ function create-node-template() {
2130
2130
local template_name=" $1 "
2131
2131
local metadata_values=" $4 "
2132
2132
local os=" $5 "
2133
+ local machine_type=" $6 "
2133
2134
2134
2135
# First, ensure the template doesn't exist.
2135
2136
# TODO(zmerlynn): To make this really robust, we need to parse the output and
@@ -2216,7 +2217,7 @@ function create-node-template() {
2216
2217
if ! ${gcloud} compute instance-templates create \
2217
2218
" ${template_name} " \
2218
2219
--project " ${PROJECT} " \
2219
- --machine-type " ${NODE_SIZE } " \
2220
+ --machine-type " ${machine_type } " \
2220
2221
--boot-disk-type " ${NODE_DISK_TYPE} " \
2221
2222
--boot-disk-size " ${NODE_DISK_SIZE} " \
2222
2223
${node_image_flags} \
@@ -3068,6 +3069,10 @@ function create-nodes-template() {
3068
3069
local windows_template_name=" ${WINDOWS_NODE_INSTANCE_PREFIX} -template"
3069
3070
create-linux-node-instance-template $linux_template_name
3070
3071
create-windows-node-instance-template $windows_template_name " ${scope_flags[*]} "
3072
+ if [[ -n " ${ADDITIONAL_MACHINE_TYPE:- } " ]]; then
3073
+ local linux_extra_template_name=" ${NODE_INSTANCE_PREFIX} -extra-template"
3074
+ create-linux-node-instance-template $linux_extra_template_name " ${ADDITIONAL_MACHINE_TYPE} "
3075
+ fi
3071
3076
}
3072
3077
3073
3078
# Assumes:
@@ -3096,13 +3101,38 @@ function set_num_migs() {
3096
3101
# - ZONE
3097
3102
function create-linux-nodes() {
3098
3103
local template_name=" ${NODE_INSTANCE_PREFIX} -template"
3104
+ local extra_template_name=" ${NODE_INSTANCE_PREFIX} -extra-template"
3099
3105
3100
- if [[ -z " ${HEAPSTER_MACHINE_TYPE:- } " ]]; then
3101
- local -r nodes=" ${NUM_NODES} "
3102
- else
3106
+ local nodes=" ${NUM_NODES} "
3107
+ if [[ ! -z " ${HEAPSTER_MACHINE_TYPE:- } " ]]; then
3103
3108
echo " Creating a special node for heapster with machine-type ${HEAPSTER_MACHINE_TYPE} "
3104
3109
create-heapster-node
3105
- local -r nodes=$(( NUM_NODES - 1 ))
3110
+ nodes=$(( nodes - 1 ))
3111
+ fi
3112
+
3113
+ if [[ -n " ${ADDITIONAL_MACHINE_TYPE:- } " && " ${NUM_ADDITIONAL_NODES:- } " -gt 0 ]]; then
3114
+ local num_additional=" ${NUM_ADDITIONAL_NODES} "
3115
+ if [[ " ${NUM_ADDITIONAL_NODES:- } " -gt " ${nodes} " ]]; then
3116
+ echo " Capping NUM_ADDITIONAL_NODES to ${nodes} "
3117
+ num_additional=" ${nodes} "
3118
+ fi
3119
+ if [[ " ${num_additional:- } " -gt 0 ]]; then
3120
+ echo " Creating ${num_additional} special nodes with machine-type ${ADDITIONAL_MACHINE_TYPE} "
3121
+ local extra_group_name=" ${NODE_INSTANCE_PREFIX} -extra"
3122
+ gcloud compute instance-groups managed \
3123
+ create " ${extra_group_name} " \
3124
+ --project " ${PROJECT} " \
3125
+ --zone " ${ZONE} " \
3126
+ --base-instance-name " ${extra_group_name} " \
3127
+ --size " ${num_additional} " \
3128
+ --template " ${extra_template_name} " || true ;
3129
+ gcloud compute instance-groups managed wait-until-stable \
3130
+ " ${extra_group_name} " \
3131
+ --zone " ${ZONE} " \
3132
+ --project " ${PROJECT} " \
3133
+ --timeout " ${MIG_WAIT_UNTIL_STABLE_TIMEOUT} " || true
3134
+ nodes=$(( nodes - $num_additional ))
3135
+ fi
3106
3136
fi
3107
3137
3108
3138
local instances_left=${nodes}
@@ -3414,13 +3444,15 @@ function kube-down() {
3414
3444
3415
3445
local all_instance_groups=(${INSTANCE_GROUPS[@]:- } ${WINDOWS_INSTANCE_GROUPS[@]:- } )
3416
3446
for group in ${all_instance_groups[@]:- } ; do
3417
- if gcloud compute instance-groups managed describe " ${group} " --project " ${PROJECT} " --zone " ${ZONE} " & > /dev/null; then
3418
- gcloud compute instance-groups managed delete \
3419
- --project " ${PROJECT} " \
3420
- --quiet \
3421
- --zone " ${ZONE} " \
3422
- " ${group} " &
3423
- fi
3447
+ {
3448
+ if gcloud compute instance-groups managed describe " ${group} " --project " ${PROJECT} " --zone " ${ZONE} " & > /dev/null; then
3449
+ gcloud compute instance-groups managed delete \
3450
+ --project " ${PROJECT} " \
3451
+ --quiet \
3452
+ --zone " ${ZONE} " \
3453
+ " ${group} "
3454
+ fi
3455
+ } &
3424
3456
done
3425
3457
3426
3458
# Wait for last batch of jobs
@@ -3429,14 +3461,21 @@ function kube-down() {
3429
3461
}
3430
3462
3431
3463
for template in ${templates[@]:- } ; do
3432
- if gcloud compute instance-templates describe --project " ${PROJECT} " " ${template} " & > /dev/null; then
3433
- gcloud compute instance-templates delete \
3434
- --project " ${PROJECT} " \
3435
- --quiet \
3436
- " ${template} "
3437
- fi
3464
+ {
3465
+ if gcloud compute instance-templates describe --project " ${PROJECT} " " ${template} " & > /dev/null; then
3466
+ gcloud compute instance-templates delete \
3467
+ --project " ${PROJECT} " \
3468
+ --quiet \
3469
+ " ${template} "
3470
+ fi
3471
+ } &
3438
3472
done
3439
3473
3474
+ # Wait for last batch of jobs
3475
+ kube::util::wait-for-jobs || {
3476
+ echo -e " Failed to delete instance template(s)." >&2
3477
+ }
3478
+
3440
3479
# Delete the special heapster node (if it exists).
3441
3480
if [[ -n " ${HEAPSTER_MACHINE_TYPE:- } " ]]; then
3442
3481
local -r heapster_machine_name=" ${NODE_INSTANCE_PREFIX} -heapster"
@@ -3717,7 +3756,7 @@ function set-replica-name() {
3717
3756
#
3718
3757
# $1: project
3719
3758
function get-template() {
3720
- local linux_filter=" ${NODE_INSTANCE_PREFIX} -template(-(${KUBE_RELEASE_VERSION_DASHED_REGEX} |${KUBE_CI_VERSION_DASHED_REGEX} ))?"
3759
+ local linux_filter=" ${NODE_INSTANCE_PREFIX} -(extra-)? template(-(${KUBE_RELEASE_VERSION_DASHED_REGEX} |${KUBE_CI_VERSION_DASHED_REGEX} ))?"
3721
3760
local windows_filter=" ${WINDOWS_NODE_INSTANCE_PREFIX} -template(-(${KUBE_RELEASE_VERSION_DASHED_REGEX} |${KUBE_CI_VERSION_DASHED_REGEX} ))?"
3722
3761
3723
3762
gcloud compute instance-templates list \
0 commit comments