From 24b06d805a575ea2795d8982c2e8422ae8b70f47 Mon Sep 17 00:00:00 2001 From: Warren Strange Date: Wed, 3 Feb 2016 19:34:27 -0700 Subject: [PATCH 1/2] Add preemtible option to master --- cluster/gce/config-default.sh | 2 ++ cluster/gce/config-test.sh | 2 ++ cluster/gce/coreos/helper.sh | 8 +++++++- cluster/gce/debian/helper.sh | 7 ++++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cluster/gce/config-default.sh b/cluster/gce/config-default.sh index 4e4a08d9079..d0a989deb79 100755 --- a/cluster/gce/config-default.sh +++ b/cluster/gce/config-default.sh @@ -27,6 +27,8 @@ NODE_DISK_TYPE=${NODE_DISK_TYPE:-pd-standard} NODE_DISK_SIZE=${NODE_DISK_SIZE:-100GB} REGISTER_MASTER_KUBELET=${REGISTER_MASTER:-true} PREEMPTIBLE_NODE=${PREEMPTIBLE_NODE:-false} +PREEMPTIBLE_MASTER=${PREEMPTIBLE_MASTER:-false} + OS_DISTRIBUTION=${KUBE_OS_DISTRIBUTION:-debian} MASTER_IMAGE=${KUBE_GCE_MASTER_IMAGE:-container-vm-v20160127} diff --git a/cluster/gce/config-test.sh b/cluster/gce/config-test.sh index df1d359a657..65396e91ee7 100755 --- a/cluster/gce/config-test.sh +++ b/cluster/gce/config-test.sh @@ -28,6 +28,8 @@ NODE_DISK_SIZE=${NODE_DISK_SIZE:-100GB} REGISTER_MASTER_KUBELET=${REGISTER_MASTER:-false} KUBE_APISERVER_REQUEST_TIMEOUT=300 PREEMPTIBLE_NODE=${PREEMPTIBLE_NODE:-false} +PREEMPTIBLE_MASTER=${PREEMPTIBLE_MASTER:-false} + OS_DISTRIBUTION=${KUBE_OS_DISTRIBUTION:-debian} MASTER_IMAGE=${KUBE_GCE_MASTER_IMAGE:-container-vm-v20160127} diff --git a/cluster/gce/coreos/helper.sh b/cluster/gce/coreos/helper.sh index 15bd768194c..78aa002cfcc 100755 --- a/cluster/gce/coreos/helper.sh +++ b/cluster/gce/coreos/helper.sh @@ -46,6 +46,11 @@ function create-master-instance() { local address_opt="" [[ -n ${1:-} ]] && address_opt="--address ${1}" + local preemptible_master="" + if [[ "${PREEMPTIBLE_MASTER}" == "true" ]]; then + preemptible_master="--preemptible --maintenance-policy TERMINATE" + fi + write-master-env gcloud compute instances create "${MASTER_NAME}" \ ${address_opt} \ @@ -60,5 +65,6 @@ function create-master-instance() { --can-ip-forward \ --metadata-from-file \ "kube-env=${KUBE_TEMP}/master-kube-env.yaml,user-data=${KUBE_ROOT}/cluster/gce/coreos/master.yaml,configure-node=${KUBE_ROOT}/cluster/gce/coreos/configure-node.sh,configure-kubelet=${KUBE_ROOT}/cluster/gce/coreos/configure-kubelet.sh" \ - --disk "name=${MASTER_NAME}-pd,device-name=master-pd,mode=rw,boot=no,auto-delete=no" + --disk "name=${MASTER_NAME}-pd,device-name=master-pd,mode=rw,boot=no,auto-delete=no" \ + ${preemptible_master} } diff --git a/cluster/gce/debian/helper.sh b/cluster/gce/debian/helper.sh index 32a90f1cc10..71d5418f18c 100755 --- a/cluster/gce/debian/helper.sh +++ b/cluster/gce/debian/helper.sh @@ -33,6 +33,10 @@ function create-master-instance { local address_opt="" [[ -n ${1:-} ]] && address_opt="--address ${1}" + local preemptible_master="" + if [[ "${PREEMPTIBLE_MASTER}" == "true" ]]; then + preemptible_master="--preemptible --maintenance-policy TERMINATE" + fi write-master-env gcloud compute instances create "${MASTER_NAME}" \ @@ -48,7 +52,8 @@ function create-master-instance { --can-ip-forward \ --metadata-from-file \ "startup-script=${KUBE_ROOT}/cluster/gce/configure-vm.sh,kube-env=${KUBE_TEMP}/master-kube-env.yaml" \ - --disk "name=${MASTER_NAME}-pd,device-name=master-pd,mode=rw,boot=no,auto-delete=no" + --disk "name=${MASTER_NAME}-pd,device-name=master-pd,mode=rw,boot=no,auto-delete=no" \ + ${preemptible_master} } # $1: template name (required) From fed1d947bcbd926853441c5984fb74d9004f150a Mon Sep 17 00:00:00 2001 From: Warren Strange Date: Thu, 4 Feb 2016 16:45:20 -0700 Subject: [PATCH 2/2] added shell guard in case var is not set --- cluster/gce/coreos/helper.sh | 2 +- cluster/gce/debian/helper.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cluster/gce/coreos/helper.sh b/cluster/gce/coreos/helper.sh index 78aa002cfcc..400cab9c335 100755 --- a/cluster/gce/coreos/helper.sh +++ b/cluster/gce/coreos/helper.sh @@ -47,7 +47,7 @@ function create-master-instance() { [[ -n ${1:-} ]] && address_opt="--address ${1}" local preemptible_master="" - if [[ "${PREEMPTIBLE_MASTER}" == "true" ]]; then + if [[ "${PREEMPTIBLE_MASTER:-}" == "true" ]]; then preemptible_master="--preemptible --maintenance-policy TERMINATE" fi diff --git a/cluster/gce/debian/helper.sh b/cluster/gce/debian/helper.sh index 71d5418f18c..946a3816008 100755 --- a/cluster/gce/debian/helper.sh +++ b/cluster/gce/debian/helper.sh @@ -34,7 +34,7 @@ function create-master-instance { local address_opt="" [[ -n ${1:-} ]] && address_opt="--address ${1}" local preemptible_master="" - if [[ "${PREEMPTIBLE_MASTER}" == "true" ]]; then + if [[ "${PREEMPTIBLE_MASTER:-}" == "true" ]]; then preemptible_master="--preemptible --maintenance-policy TERMINATE" fi