mirror of https://github.com/k3s-io/k3s
Merge pull request #11742 from jszczepkowski/scaler-up
Optional creation of nodes autoscaler for GCE.pull/6/head
commit
b6b8056a73
|
@ -74,6 +74,15 @@ DNS_SERVER_IP="10.0.0.10"
|
||||||
DNS_DOMAIN="cluster.local"
|
DNS_DOMAIN="cluster.local"
|
||||||
DNS_REPLICAS=1
|
DNS_REPLICAS=1
|
||||||
|
|
||||||
|
# Optional: Create autoscaler for cluster's nodes.
|
||||||
|
# NOT WORKING YET!
|
||||||
|
ENABLE_NODE_AUTOSCALER="${KUBE_ENABLE_NODE_AUTOSCALER:-false}"
|
||||||
|
if [[ "${ENABLE_NODE_AUTOSCALER}" == "true" ]]; then
|
||||||
|
AUTOSCALER_MIN_NODES="${KUBE_AUTOSCALER_MIN_NODES:-1}"
|
||||||
|
AUTOSCALER_MAX_NODES="${KUBE_AUTOSCALER_MAX_NODES:-${NUM_MINIONS}}"
|
||||||
|
TARGET_NODE_UTILIZATION="${KUBE_TARGET_NODE_UTILIZATION:-0.7}"
|
||||||
|
fi
|
||||||
|
|
||||||
# Admission Controllers to invoke prior to persisting objects in cluster
|
# Admission Controllers to invoke prior to persisting objects in cluster
|
||||||
ADMISSION_CONTROL=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota
|
ADMISSION_CONTROL=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,15 @@ DNS_SERVER_IP="10.0.0.10"
|
||||||
DNS_DOMAIN="cluster.local"
|
DNS_DOMAIN="cluster.local"
|
||||||
DNS_REPLICAS=1
|
DNS_REPLICAS=1
|
||||||
|
|
||||||
|
# Optional: Create autoscaler for cluster's nodes.
|
||||||
|
# NOT WORKING YET!
|
||||||
|
ENABLE_NODE_AUTOSCALER="${KUBE_ENABLE_NODE_AUTOSCALER:-false}"
|
||||||
|
if [[ "${ENABLE_NODE_AUTOSCALER}" == "true" ]]; then
|
||||||
|
AUTOSCALER_MIN_NODES="${KUBE_AUTOSCALER_MIN_NODES:-1}"
|
||||||
|
AUTOSCALER_MAX_NODES="${KUBE_AUTOSCALER_MAX_NODES:-${NUM_MINIONS}}"
|
||||||
|
TARGET_NODE_UTILIZATION="${KUBE_TARGET_NODE_UTILIZATION:-0.7}"
|
||||||
|
fi
|
||||||
|
|
||||||
ADMISSION_CONTROL=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota
|
ADMISSION_CONTROL=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota
|
||||||
|
|
||||||
# Optional: if set to true kube-up will automatically check for existing resources and clean them up.
|
# Optional: if set to true kube-up will automatically check for existing resources and clean them up.
|
||||||
|
|
|
@ -708,6 +708,18 @@ function kube-up {
|
||||||
detect-minion-names
|
detect-minion-names
|
||||||
detect-master
|
detect-master
|
||||||
|
|
||||||
|
# Create autoscaler for nodes if requested
|
||||||
|
if [[ "${ENABLE_NODE_AUTOSCALER}" == "true" ]]; then
|
||||||
|
METRICS=""
|
||||||
|
METRICS+="--custom-metric-utilization metric=custom.cloudmonitoring.googleapis.com/kubernetes.io/cpu/node_utilization,"
|
||||||
|
METRICS+="utilization-target=${TARGET_NODE_UTILIZATION},utilization-target-type=GAUGE "
|
||||||
|
METRICS+="--custom-metric-utilization metric=custom.cloudmonitoring.googleapis.com/kubernetes.io/memory/node_utilization,"
|
||||||
|
METRICS+="utilization-target=${TARGET_NODE_UTILIZATION},utilization-target-type=GAUGE "
|
||||||
|
echo "Creating node autoscaler."
|
||||||
|
gcloud preview autoscaler --zone "${ZONE}" create "${NODE_INSTANCE_PREFIX}-autoscaler" --target "${NODE_INSTANCE_PREFIX}-group" \
|
||||||
|
--min-num-replicas "${AUTOSCALER_MIN_NODES}" --max-num-replicas "${AUTOSCALER_MAX_NODES}" ${METRICS} || true
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Waiting for cluster initialization."
|
echo "Waiting for cluster initialization."
|
||||||
echo
|
echo
|
||||||
echo " This will continually check to see if the API for kubernetes is reachable."
|
echo " This will continually check to see if the API for kubernetes is reachable."
|
||||||
|
@ -769,6 +781,15 @@ function kube-down {
|
||||||
echo "Bringing down cluster"
|
echo "Bringing down cluster"
|
||||||
set +e # Do not stop on error
|
set +e # Do not stop on error
|
||||||
|
|
||||||
|
# Delete autoscaler for nodes if present.
|
||||||
|
local autoscaler
|
||||||
|
autoscaler=( $(gcloud preview autoscaler --zone "${ZONE}" list \
|
||||||
|
| awk 'NR >= 2 { print $1 }' \
|
||||||
|
| grep "${NODE_INSTANCE_PREFIX}-autoscaler") )
|
||||||
|
if [[ "${autoscaler:-}" != "" ]]; then
|
||||||
|
gcloud preview autoscaler --zone "${ZONE}" delete "${NODE_INSTANCE_PREFIX}-autoscaler"
|
||||||
|
fi
|
||||||
|
|
||||||
# Get the name of the managed instance group template before we delete the
|
# Get the name of the managed instance group template before we delete the
|
||||||
# managed instange group. (The name of the managed instnace group template may
|
# managed instange group. (The name of the managed instnace group template may
|
||||||
# change during a cluster upgrade.)
|
# change during a cluster upgrade.)
|
||||||
|
|
Loading…
Reference in New Issue