Skip to content

Commit ac4ce13

Browse files
authored
add --spot flag (#380)
1 parent cc4450c commit ac4ce13

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

dist/bin/kctf-cluster

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,7 @@ function kctf_cluster_resize_usage {
795795
echo -e " -h|--help print this help" >&2
796796
echo -e " --machine-type machine type to use" >&2
797797
echo -e " to list available types, run: gcloud compute machine-types list --zones=\"${ZONE}\"" >&2
798+
echo -e " --spot use spot VMs (reduced cost but no availability guarantees)" >&2
798799
echo -e " --min-nodes (required) minimum number of nodes in the cluster" >&2
799800
echo -e " --max-nodes (required) maximum number of nodes in the cluster" >&2
800801
echo -e " --num-nodes (required) initial number of nodes in the cluster" >&2
@@ -809,7 +810,7 @@ function kctf_cluster_resize {
809810
fi
810811

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

820821
MACHINE_TYPE="n2-standard-4"
822+
SPOT=
821823
MIN_NODES=
822824
MAX_NODES=
823825
NUM_NODES=
@@ -833,6 +835,10 @@ function kctf_cluster_resize {
833835
MACHINE_TYPE="$2"
834836
shift 2
835837
;;
838+
--spot)
839+
SPOT=1
840+
shift 1
841+
;;
836842
--min-nodes)
837843
MIN_NODES="$2"
838844
shift 2
@@ -900,6 +906,7 @@ function kctf_cluster_resize {
900906
gcloud container node-pools create "${NEW_POOL_NAME}" \
901907
--cluster="${CLUSTER_NAME}" \
902908
--machine-type="${MACHINE_TYPE}" \
909+
${SPOT:+--spot} \
903910
--enable-autorepair \
904911
--enable-autoupgrade \
905912
--num-nodes="${NUM_NODES}" \

dist/bin/kctf-completion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function _kctf_complete_cluster() {
120120
fi
121121
return 0
122122
fi
123-
COMPREPLY=($(compgen -W "--machine-type --min-nodes --max-nodes --num-nodes --pool-name --old-pool" -- "${COMP_WORDS[${COMP_CWORD}]}"))
123+
COMPREPLY=($(compgen -W "--machine-type --spot --min-nodes --max-nodes --num-nodes --pool-name --old-pool" -- "${COMP_WORDS[${COMP_CWORD}]}"))
124124
return
125125
;;
126126
create)

0 commit comments

Comments
 (0)