Skip to content

Commit

Permalink
Support for cluster autoscaler in GCE Trusty and GCI images
Browse files Browse the repository at this point in the history
  • Loading branch information
mwielgus committed May 27, 2016
1 parent 73a5a13 commit 5f2695b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,7 @@ function kube::release::package_kube_manifests_tarball() {
mkdir -p "${dst_dir}"

local salt_dir="${KUBE_ROOT}/cluster/saltbase/salt"
cp "${salt_dir}/cluster-autoscaler/cluster-autoscaler.manifest" "${dst_dir}/"
cp "${salt_dir}/fluentd-es/fluentd-es.yaml" "${release_stage}/"
cp "${salt_dir}/fluentd-gcp/fluentd-gcp.yaml" "${release_stage}/"
cp "${salt_dir}/kube-registry-proxy/kube-registry-proxy.yaml" "${release_stage}/"
Expand Down
17 changes: 17 additions & 0 deletions cluster/gce/gci/configure-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,22 @@ function start-kube-scheduler {
cp "${src_file}" /etc/kubernetes/manifests
}

# Starts cluster autoscaler.
function start-cluster-autoscaler {
if [ "${ENABLE_NODE_AUTOSCALER:-}" = "true" ]; then
touch /etc/kubernetes/start-cluster-autoscaler-enabled

# Remove salt comments and replace variables with values
src_file="${KUBE_HOME}/kube-manifests/kubernetes/gci-trusty/cluster-autoscaler.manifest"
remove-salt-config-comments "${src_file}"

local params=`sed 's/^/"/;s/ /","/g;s/$/",/' <<< "${AUTOSCALER_MIG_CONFIG}"`
sed -i -e "s@\"{{param}}\",@${params}@g" "${src_file}"
sed -i -e "s@{%.*%}@@g" "${src_file}"
cp "${src_file}" /etc/kubernetes/manifests
fi
}

# A helper function for copying addon manifests and set dir/files
# permissions.
#
Expand Down Expand Up @@ -812,6 +828,7 @@ if [[ "${KUBERNETES_MASTER:-}" == "true" ]]; then
start-kube-controller-manager
start-kube-scheduler
start-kube-addons
start-cluster-autoscaler
else
start-kube-proxy
# Kube-registry-proxy.
Expand Down
14 changes: 14 additions & 0 deletions cluster/gce/trusty/configure-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,20 @@ start_kube_scheduler() {
cp "${src_file}" /etc/kubernetes/manifests
}

# Starts k8s cluster autoscaler.
start_cluster_autoscaler() {
if [ "${ENABLE_NODE_AUTOSCALER:-}" = "true" ]; then
# Remove salt comments and replace variables with values
src_file="${kube_home}/kube-manifests/kubernetes/gci-trusty/cluster-autoscaler.manifest"
remove_salt_config_comments "${src_file}"

local params=`sed 's/^/"/;s/ /","/g;s/$/",/' <<< "${AUTOSCALER_MIG_CONFIG}"`

This comment has been minimized.

Copy link
@andyzheng0831

andyzheng0831 Jun 1, 2016

I guess you did not try to start a cluster on Ubuntu trusty to test the change in this file. It does not work. The shell functions running in upstarts do not support all shell functionalities. The key word "local" is one example, and "<<<" is another. I make a PR #26599 to fix it.

sed -i -e "s@\"{{param}}\",@${params}@g" "${src_file}"
sed -i -e "s@{%.*%}@@g" "${src_file}"

This comment has been minimized.

Copy link
@andyzheng0831

andyzheng0831 Jun 1, 2016

Is the above line for removing salt comments? If so, it is not needed as function remove_salt_config_comments is called at line 622.

cp "${src_file}" /etc/kubernetes/manifests
fi
}

# Starts a fluentd static pod for logging.
start_fluentd() {
if [ "${ENABLE_NODE_LOGGING:-}" = "true" ]; then
Expand Down
1 change: 1 addition & 0 deletions cluster/gce/trusty/master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ script
start_kube_controller_manager
start_kube_scheduler
start_kube_addons
start_cluster_autoscaler
} 2>&1 | logger --priority daemon.info -t ${UPSTART_JOB}
end script

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{% if pillar.get('enable_node_autoscaler', '').lower() == 'true' %}
{% set params = pillar['autoscaler_mig_config'] -%}
{
"kind": "Pod",
Expand Down Expand Up @@ -56,3 +57,4 @@
"restartPolicy": "Always"
}
}
{% endif %}

0 comments on commit 5f2695b

Please sign in to comment.