From 2a3607e7a6e951f5ceb2de6ed71ccdde068e6260 Mon Sep 17 00:00:00 2001 From: Giuseppe Attardi <giuseppe.attardi@garr.it> Date: Sat, 2 Dec 2017 20:00:59 +0100 Subject: [PATCH] Added autoscaler. --- README.md | 49 +++++++++++++++++- bundle.yaml | 126 ++++++++++++++++++++++++++++++++++++--------- loadgenerator.yaml | 15 ++++++ 3 files changed, 164 insertions(+), 26 deletions(-) create mode 100644 loadgenerator.yaml diff --git a/README.md b/README.md index 53b30bb..ef83fb6 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ## Overview -This is a scaled-out Kubernetes cluster composed of the following components and features: +This is an autoscale Kubernetes cluster composed of the following components and features: - Kubernetes (automated deployment, operations, and scaling) - Kubernetes cluster with one master and three worker nodes. @@ -19,6 +19,12 @@ This is a scaled-out Kubernetes cluster composed of the following components and to the requesting units of the cluster. - Etcd (distributed key value store) - Three node cluster for reliability. +- CharmScaler + - allows scaling the number of k8 nodes according to the CPU loads. +- Telegraf + - colletcs usage data. +- Inflixdb + - stores series data on the use of resources. # Usage @@ -520,6 +526,7 @@ documentation for more information. - [Official Bundle](https://api.jujucharms.com/charmstore/v5/canonical-kubernetes/archive/bundle.yaml) - [Bundle Source](https://github.com/juju-solutions/bundle-canonical-kubernetes) - [Bug tracker](https://github.com/juju-solutions/bundle-canonical-kubernetes/issues) +- [Autoscaled Kubernetes Bundle](https://jujucharms.com/u/elastisys/autoscaled-kubernetes/bundle/0) # Flannel @@ -554,3 +561,43 @@ on `Juju 2.0+` controllers. - [Flannel Charm Resource](https://jujucharms.com/u/containers/flannel/) - [Flannel Homepage](https://coreos.com/flannel/docs/latest/flannel-config.html) + +# Autoscaling + +Configure the CharmScaler to give it access to the Juju model. + +*For more details on the CharmScaler setup process, +[read this](https://github.com/elastisys/layer-charmscaler#quickstart)* + +Minimal config.yaml example: + + charmscaler: + juju_api_endpoint: "[API address]:17070" + juju_model_uuid: "[uuid]" + juju_username: "[username]" + juju_password: "[password]" + +Apply the configuration + + juju config charmscaler --file config.yaml + +Wait for the deployment to settle + + watch -c juju status --color + +Fetch the Kubernetes config and the `kubectl` binary + + mkdir ~/.kube + juju scp kubernetes-master/0:config ~/.kube/config + juju scp kubernetes-master/0:kubectl ./kubectl + +Make sure things are running + + ./kubectl cluster-info + ./kubectl get nodes + +----------------------- + +For more details read the documentation of the +[Kubernetes core bundle](https://jujucharms.com/kubernetes-core/) and the +[CharmScaler](https://jujucharms.com/u/elastisys/charmscaler/). \ No newline at end of file diff --git a/bundle.yaml b/bundle.yaml index 11a1417..9322197 100644 --- a/bundle.yaml +++ b/bundle.yaml @@ -2,11 +2,24 @@ # The server nodes to be used should be tagged as kubernetes. # At least one of them should also be tagged as ip-pub, to denote a machine configured with # a public IP. +# The server nodes with GPUs should be tagged as gpu. ## series: xenial description: A nine-machine Kubernetes cluster, appropriate for production. Includes a three-machine etcd cluster and three Kubernetes worker nodes. +# ---------------------------------------------------------------------- +machines: + "0": + series: xenial + constraints: "tags=kubernetes" + "1": + series: xenial + constraints: "tags=kubernetes" + "2": + series: xenial + constraints: "tags=kubernetes" + # ---------------------------------------------------------------------- services: @@ -17,6 +30,34 @@ services: charm: cs:~containers/easyrsa num_units: 1 constraints: tags=kubernetes + to: + - "lxd:charmscaler/0" + + charmscaler: + charm: "cs:~elastisys/charmscaler-5" + num_units: 1 + annotations: + gui-x: "400" + gui-y: "600" + to: + - "0" + + telegraf: + charm: "cs:telegraf" + annotations: + gui-x: "170" + gui-y: "600" + to: + - "0" + + influxdb: + charm: "cs:~chris.macnaughton/influxdb-6" + num_units: 1 + annotations: + gui-x: "100" + gui-y: "700" + to: + - "0" etcd: annotations: @@ -25,12 +66,18 @@ services: charm: cs:~containers/etcd num_units: 3 constraints: tags=kubernetes + to: + - "0" + - "1" + - "2" flannel: annotations: gui-x: '450' gui-y: '750' charm: cs:~containers/flannel + to: + - "0" kubeapi-load-balancer: annotations: @@ -40,16 +87,21 @@ services: expose: true num_units: 1 constraints: tags=kubernetes + to: + - "1" kubernetes-master: annotations: gui-x: '800' gui-y: '850' charm: cs:~containers/kubernetes-master + # charm: "cs:~tvansteenburgh/kubernetes-master" num_units: 1 constraints: tags=kubernetes,ip-pub options: channel: 1.8/stable + to: + - "1" kubernetes-worker: annotations: @@ -62,30 +114,54 @@ services: options: channel: 1.8/stable + # kubernetes-worker-gpu: + # charm: "cs:~tvansteenburgh/kubernetes-worker" + # num_units: 1 + # expose: true + # annotations: + # gui-x: "520" + # gui-y": "226" + # constraints: cores=4 mem=4G tags=kubernetes,gpu + # ---------------------------------------------------------------------- relations: -- - kubernetes-master:kube-api-endpoint - - kubeapi-load-balancer:apiserver -- - kubernetes-master:loadbalancer - - kubeapi-load-balancer:loadbalancer -- - kubernetes-master:kube-control - - kubernetes-worker:kube-control -- - kubernetes-master:certificates - - easyrsa:client -- - etcd:certificates - - easyrsa:client -- - kubernetes-master:etcd - - etcd:db -- - kubernetes-worker:certificates - - easyrsa:client -- - kubernetes-worker:kube-api-endpoint - - kubeapi-load-balancer:website -- - kubeapi-load-balancer:certificates - - easyrsa:client -- - flannel:etcd - - etcd:db -- - flannel:cni - - kubernetes-master:cni -- - flannel:cni - - kubernetes-worker:cni -# - [ "kubernetes-master:ceph-storage", "ceph-mon:admin" ] + - - kubernetes-master:kube-api-endpoint + - kubeapi-load-balancer:apiserver + - - kubernetes-master:loadbalancer + - kubeapi-load-balancer:loadbalancer + - - kubernetes-master:kube-control + - kubernetes-worker:kube-control + - - kubernetes-master:certificates + - easyrsa:client + - - etcd:certificates + - easyrsa:client + - - kubernetes-master:etcd + - etcd:db + - - kubernetes-worker:certificates + - easyrsa:client + - - kubernetes-worker:kube-api-endpoint + - kubeapi-load-balancer:website + - - kubeapi-load-balancer:certificates + - easyrsa:client + - - flannel:etcd + - etcd:db + - - flannel:cni + - kubernetes-master:cni + - - flannel:cni + - kubernetes-worker:cni + - - "charmscaler:db-api" + - "influxdb:api" + - - "telegraf:influxdb-api" + - "influxdb:api" + - - "charmscaler:scalable-charm" + - "kubernetes-worker:juju-info" + # - [ "kubernetes-master:ceph-storage", "ceph-mon:admin" ] + + # - - "kubernetes-worker-gpu:cni" + # - "flannel:cni" + # - - "kubernetes-worker-gpu:certificates" + # - "easyrsa:client" + # - - "kubernetes-master:kube-control" + # - "kubernetes-worker-gpu:kube-control" + # - - "kubernetes-master:kube-api-endpoint" + # - "kubernetes-worker-gpu:kube-api-endpoint" diff --git a/loadgenerator.yaml b/loadgenerator.yaml new file mode 100644 index 0000000..0162da5 --- /dev/null +++ b/loadgenerator.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: ReplicationController +metadata: + name: loadgenerator +spec: + replicas: 1 + template: + metadata: + labels: + app: stress + spec: + containers: + - name: stress + image: elastisys/stress + imagePullPolicy: IfNotPresent -- GitLab