diff --git a/cluster/aws/config-default.sh b/cluster/aws/config-default.sh index 84569818f5..d0548fbe7e 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 9bce781d45..685eaf48d6 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 40ffee2c20..6366074215 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 f9871b5738..b8480e2b2c 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 5660bad6ef..0a42999c3f 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:-}'"