From 33d0541a00e947d07ccd9f3246244b89f6de499d Mon Sep 17 00:00:00 2001 From: Justin Santa Barbara Date: Tue, 6 Oct 2015 14:55:04 -0400 Subject: [PATCH] AWS: Add configuration for ENABLE_EXPERIMENTAL We need this for some tests; not all the options are fully plumbed in, but should enable experimental/v1alpha1, as needed for jobs tests. In particular, ENABLE_NODE_AUTOSCALER is not yet actually implemented. --- cluster/aws/config-default.sh | 24 +++++++++++++++++++ cluster/aws/config-test.sh | 24 +++++++++++++++++++ .../templates/create-dynamic-salt-files.sh | 6 +++++ cluster/aws/templates/salt-master.sh | 6 +++++ cluster/aws/util.sh | 14 +++++++++++ 5 files changed, 74 insertions(+) diff --git a/cluster/aws/config-default.sh b/cluster/aws/config-default.sh index 84569818f5cd3..d0548fbe7e506 100644 --- a/cluster/aws/config-default.sh +++ b/cluster/aws/config-default.sh @@ -58,6 +58,8 @@ MASTER_IP_RANGE="${MASTER_IP_RANGE:-10.246.0.0/24}" # If set to auto, a new Elastic IP will be acquired # Otherwise amazon-given public ip will be used (it'll change with reboot). MASTER_RESERVED_IP="${MASTER_RESERVED_IP:-}" +RUNTIME_CONFIG="${KUBE_RUNTIME_CONFIG:-}" +ENABLE_EXPERIMENTAL_API="${KUBE_ENABLE_EXPERIMENTAL_API:-false}" # Optional: Cluster monitoring to setup as part of the cluster bring up: # none - No cluster monitoring setup @@ -86,6 +88,28 @@ DNS_REPLICAS=1 # Optional: Install Kubernetes UI ENABLE_CLUSTER_UI="${KUBE_ENABLE_CLUSTER_UI:-true}" +# Optional: Create autoscaler for cluster's nodes. +ENABLE_NODE_AUTOSCALER="${KUBE_ENABLE_NODE_AUTOSCALER:-false}" +if [[ "${ENABLE_NODE_AUTOSCALER}" == "true" ]]; then + # TODO: actually configure ASG or similar + 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 + +# Optional: Enable feature for autoscaling number of pods +# Experimental feature, not ready for production use. +ENABLE_HORIZONTAL_POD_AUTOSCALER="${KUBE_ENABLE_HORIZONTAL_POD_AUTOSCALER:-false}" +if [[ "${ENABLE_HORIZONTAL_POD_AUTOSCALER}" == "true" ]]; then + ENABLE_EXPERIMENTAL_API=true +fi + +# Optional: Enable deployment experimental feature, not ready for production use. +ENABLE_DEPLOYMENTS="${KUBE_ENABLE_DEPLOYMENTS:-false}" +if [[ "${ENABLE_DEPLOYMENTS}" == "true" ]]; then + ENABLE_EXPERIMENTAL_API=true +fi + # Admission Controllers to invoke prior to persisting objects in cluster ADMISSION_CONTROL=NamespaceLifecycle,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota diff --git a/cluster/aws/config-test.sh b/cluster/aws/config-test.sh index 9bce781d45b28..685eaf48d65b1 100755 --- a/cluster/aws/config-test.sh +++ b/cluster/aws/config-test.sh @@ -54,6 +54,8 @@ MASTER_IP_RANGE="${MASTER_IP_RANGE:-10.246.0.0/24}" # If set to auto, a new Elastic IP will be acquired # Otherwise amazon-given public ip will be used (it'll change with reboot). MASTER_RESERVED_IP="${MASTER_RESERVED_IP:-}" +RUNTIME_CONFIG="${KUBE_RUNTIME_CONFIG:-}" +ENABLE_EXPERIMENTAL_API="${KUBE_ENABLE_EXPERIMENTAL_API:-false}" # Optional: Cluster monitoring to setup as part of the cluster bring up: # none - No cluster monitoring setup @@ -82,6 +84,28 @@ DNS_REPLICAS=1 # Optional: Install Kubernetes UI ENABLE_CLUSTER_UI="${KUBE_ENABLE_CLUSTER_UI:-true}" +# Optional: Create autoscaler for cluster's nodes. +ENABLE_NODE_AUTOSCALER="${KUBE_ENABLE_NODE_AUTOSCALER:-false}" +if [[ "${ENABLE_NODE_AUTOSCALER}" == "true" ]]; then + # TODO: actually configure ASG or similar + 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 + +# Optional: Enable feature for autoscaling number of pods +# Experimental feature, not ready for production use. +ENABLE_HORIZONTAL_POD_AUTOSCALER="${KUBE_ENABLE_HORIZONTAL_POD_AUTOSCALER:-false}" +if [[ "${ENABLE_HORIZONTAL_POD_AUTOSCALER}" == "true" ]]; then + ENABLE_EXPERIMENTAL_API=true +fi + +# Optional: Enable deployment experimental feature, not ready for production use. +ENABLE_DEPLOYMENTS="${KUBE_ENABLE_DEPLOYMENTS:-false}" +if [[ "${ENABLE_DEPLOYMENTS}" == "true" ]]; then + ENABLE_EXPERIMENTAL_API=true +fi + # Admission Controllers to invoke prior to persisting objects in cluster ADMISSION_CONTROL=NamespaceLifecycle,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota diff --git a/cluster/aws/templates/create-dynamic-salt-files.sh b/cluster/aws/templates/create-dynamic-salt-files.sh index 40ffee2c20a12..6366074215629 100644 --- a/cluster/aws/templates/create-dynamic-salt-files.sh +++ b/cluster/aws/templates/create-dynamic-salt-files.sh @@ -42,6 +42,12 @@ opencontrail_kubernetes_tag: '$(echo "$OPENCONTRAIL_KUBERNETES_TAG")' opencontrail_public_subnet: '$(echo "$OPENCONTRAIL_PUBLIC_SUBNET")' EOF +if [ -n "${ENABLE_EXPERIMENTAL_API:-}" ]; then + cat <>/srv/salt-overlay/pillar/cluster-params.sls +enable_experimental_api: '$(echo "$ENABLE_EXPERIMENTAL_API" | sed -e "s/'/''/g")' +EOF +fi + readonly BASIC_AUTH_FILE="/srv/salt-overlay/salt/kube-apiserver/basic_auth.csv" if [ ! -e "${BASIC_AUTH_FILE}" ]; then mkdir -p /srv/salt-overlay/salt/kube-apiserver diff --git a/cluster/aws/templates/salt-master.sh b/cluster/aws/templates/salt-master.sh index f9871b5738f47..b8480e2b2cadf 100755 --- a/cluster/aws/templates/salt-master.sh +++ b/cluster/aws/templates/salt-master.sh @@ -50,6 +50,12 @@ if [[ -n "${MASTER_EXTRA_SANS}" ]]; then EOF fi +if [[ ! -z "${RUNTIME_CONFIG:-}" ]]; then + cat <>/etc/salt/minion.d/grains.conf + runtime_config: '$(echo "$RUNTIME_CONFIG" | sed -e "s/'/''/g")' +EOF +fi + # Auto accept all keys from minions that try to join mkdir -p /etc/salt/master.d cat </etc/salt/master.d/auto-accept.conf diff --git a/cluster/aws/util.sh b/cluster/aws/util.sh index 5660bad6ef59d..0a42999c3fd79 100644 --- a/cluster/aws/util.sh +++ b/cluster/aws/util.sh @@ -441,6 +441,18 @@ function create-dhcp-option-set () { # Verify prereqs function verify-prereqs { + if [[ "${ENABLE_EXPERIMENTAL_API}" == "true" ]]; then + if [[ -z "${RUNTIME_CONFIG}" ]]; then + RUNTIME_CONFIG="experimental/v1alpha1=true" + else + # TODO: add checking if RUNTIME_CONFIG contains "experimental/v1alpha1=false" and appending "experimental/v1alpha1=true" if not. + if echo "${RUNTIME_CONFIG}" | grep -q -v "experimental/v1alpha1=true"; then + echo "Experimental API should be turned on, but is not turned on in RUNTIME_CONFIG!" + exit 1 + fi + fi + fi + if [[ "$(which aws)" == "" ]]; then echo "Can't find aws in PATH, please fix and retry." exit 1 @@ -830,6 +842,8 @@ function kube-up { echo "readonly ELASTICSEARCH_LOGGING_REPLICAS='${ELASTICSEARCH_LOGGING_REPLICAS:-}'" echo "readonly ENABLE_CLUSTER_DNS='${ENABLE_CLUSTER_DNS:-false}'" echo "readonly ENABLE_CLUSTER_UI='${ENABLE_CLUSTER_UI:-false}'" + echo "readonly ENABLE_EXPERIMENTAL_API='${ENABLE_EXPERIMENTAL_API:-false}'" + echo "readonly RUNTIME_CONFIG='${RUNTIME_CONFIG}'" echo "readonly DNS_REPLICAS='${DNS_REPLICAS:-}'" echo "readonly DNS_SERVER_IP='${DNS_SERVER_IP:-}'" echo "readonly DNS_DOMAIN='${DNS_DOMAIN:-}'"