diff --git a/cluster/gce/config-default.sh b/cluster/gce/config-default.sh index 3a87d385091..1c4d8b95cc4 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 2887992736d..3c0f1b9c251 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..400cab9c335 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..946a3816008 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)