Skip to content

Commit

Permalink
add --spot flag (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
arxenix authored Jul 7, 2022
1 parent cc4450c commit ac4ce13
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion dist/bin/kctf-cluster
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,7 @@ function kctf_cluster_resize_usage {
echo -e " -h|--help print this help" >&2
echo -e " --machine-type machine type to use" >&2
echo -e " to list available types, run: gcloud compute machine-types list --zones=\"${ZONE}\"" >&2
echo -e " --spot use spot VMs (reduced cost but no availability guarantees)" >&2
echo -e " --min-nodes (required) minimum number of nodes in the cluster" >&2
echo -e " --max-nodes (required) maximum number of nodes in the cluster" >&2
echo -e " --num-nodes (required) initial number of nodes in the cluster" >&2
Expand All @@ -809,7 +810,7 @@ function kctf_cluster_resize {
fi

OPTS="h"
LONGOPTS="help,machine-type:,min-nodes:,max-nodes:,num-nodes:,pool-name:,old-pool:"
LONGOPTS="help,machine-type:,spot,min-nodes:,max-nodes:,num-nodes:,pool-name:,old-pool:"
PARSED=$(${GETOPT} --options=$OPTS --longoptions=$LONGOPTS --name "kctf cluster resize" -- "$@")
if [[ $? -ne 0 ]]; then
kctf_cluster_resize_usage
Expand All @@ -818,6 +819,7 @@ function kctf_cluster_resize {
eval set -- "$PARSED"

MACHINE_TYPE="n2-standard-4"
SPOT=
MIN_NODES=
MAX_NODES=
NUM_NODES=
Expand All @@ -833,6 +835,10 @@ function kctf_cluster_resize {
MACHINE_TYPE="$2"
shift 2
;;
--spot)
SPOT=1
shift 1
;;
--min-nodes)
MIN_NODES="$2"
shift 2
Expand Down Expand Up @@ -900,6 +906,7 @@ function kctf_cluster_resize {
gcloud container node-pools create "${NEW_POOL_NAME}" \
--cluster="${CLUSTER_NAME}" \
--machine-type="${MACHINE_TYPE}" \
${SPOT:+--spot} \
--enable-autorepair \
--enable-autoupgrade \
--num-nodes="${NUM_NODES}" \
Expand Down
2 changes: 1 addition & 1 deletion dist/bin/kctf-completion
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function _kctf_complete_cluster() {
fi
return 0
fi
COMPREPLY=($(compgen -W "--machine-type --min-nodes --max-nodes --num-nodes --pool-name --old-pool" -- "${COMP_WORDS[${COMP_CWORD}]}"))
COMPREPLY=($(compgen -W "--machine-type --spot --min-nodes --max-nodes --num-nodes --pool-name --old-pool" -- "${COMP_WORDS[${COMP_CWORD}]}"))
return
;;
create)
Expand Down

0 comments on commit ac4ce13

Please sign in to comment.