Elastic Google Container Engine cluster?

1/8/2016

When you create a Google Container Engine (GKE) cluster you specify what the number and what types of machines you want to use in the cluster.

  1. Is it possible to auto-scale the number of cluster machines based on (for example) CPU load?
  2. If this is not supported, is there a reason why or is Google working on something like this for the future?
-- Johan
google-kubernetes-engine
kubernetes

3 Answers

1/8/2016

You can definitely create an autoscaler that automatically chooses and sets the number of pods that run in a kubernetes cluster. So the autoscaler will be created and will be using the replication controller as a reference to automatically increase or decrease the number of pods as needed. You can have more information in this Help Center article.

-- George
Source: StackOverflow

1/8/2016

Yes, it is. To attach an autoscaler to your existing GKE cluster:

  1. Find the name of your cluster's instance group:

    $ gcloud compute instance-groups managed list
    NAME                         ZONE          BASE_INSTANCE_NAME          SIZE TARGET_SIZE INSTANCE_TEMPLATE            AUTOSCALED
    gke-buildlets-69898e2d-group us-central1-f gke-buildlets-69898e2d-node 1    1           gke-buildlets-69898e2d-1-1-3 yes

    Here I have a GKE cluster named buildlets, and its instance group is named gke-buildlets-6989e2d-group

  2. Enable autoscaling. This particular example will scale on a target CPU utilization of 70%:

    gcloud compute instance-groups managed set-autoscaling YOUR_INSTANCE_GROUP_NAME \
      --zone=YOUR_INSTANCE_GROUP_ZONE \
      --min-num-replicas=1 \
      --max-num-replicas=8 \
      --scale-based-on-cpu \
      --target-cpu-utilization=.7

You can also use Google Cloud Deployment manager to create your GKE cluster, and create/attach an autoscaler right along with it:

resources:
- name: buildlets
  type: container.v1.cluster
  properties:
    zone: us-central1-f
    cluster:
      initial_node_count: 1
      network: "default"
      logging_service: "logging.googleapis.com"
      monitoring_service: "monitoring.googleapis.com"
      node_config:
        machine_type: n1-standard-1
        oauth_scopes: 
          - "https://www.googleapis.com/auth/cloud-platform"
      master_auth: 
        username: admin
        password: password123
- name: autoscaler
  type: compute.v1.autoscaler
  properties:
    zone: us-central1-f
    name: buildlets
    target: "$(ref.buildlets.instanceGroupUrls[0])"
    autoscalingPolicy: 
      minNumReplicas: 2
      maxNumReplicas: 8
      coolDownPeriodSec: 600 
      cpuUtilization: 
        utilizationTarget: .7`
-- Evan Brown
Source: StackOverflow

1/8/2016

It is possible to manually resize a GKE cluster, yes. AFAIK you'd need to do the 'elastic' part yourself ATM, for example based on Heapster output.

-- Michael Hausenblas
Source: StackOverflow