Skip to content

Latest commit

 

History

History
195 lines (176 loc) · 7.33 KB

File metadata and controls

195 lines (176 loc) · 7.33 KB

QuickStart

This document helps you get started to use Alameda. If you do not have Alameda deployed in your environment yet, please reference deployment guide first.

Using Alameda

To have Alameda makes resource usage recommendations for you, first thing is to tell Alameda what are the target containers by creating AlamedaScaler CRs. Then you can see the recommendations by checking the alamedarecommendation CRs or Grafana dashboards visualize them.

Specify a target object

Users can create a custom resource of AlamedaScaler custom resource definition (CRD) to instruct Alameda that:

  1. which container needs resource usage recommendations, and
  2. what policy that Alameda should use to give recommendations.
  3. whether or not to execute the recommendations.

Currently Alameda watches containers that are deployed by Deployment or DeploymentConfig kinds and provides stable and compact policies. For more detail AlamedaScaler schema, please refer to the AlamedaScaler design. The following is an example AlamedaScaler CR.

apiVersion: autoscaling.containers.ai/v1alpha1
kind: AlamedaScaler
metadata:
  name: alameda
  namespace: webapp
spec:
  policy: stable
  enableexecution: true
  selector:
    matchLabels:
      app: nginx

This CR instructs Alameda to look up Deployment/DeploymentConfig objects in webapp namespaces with nginx label. For any pods derived from them, Alameda will predict their resource usage and make recommendations with stable considerations. Once new recommendations are available, Alameda will execute it according the enableexecution switch.

You can list all the AlamedaScaler CRs in your namespace by:

$ kubectl get alamedascalers -n <your namespace>

and see the details by adding -o yaml flag.

Note: an AlamedaScaler CR only looks for Deployment/DeploymentConfig objects in the same namespace.

Retrieve Alameda recommendations

Alameda outputs recommendations and presents them as alamedarecommendation CRD. You can check Alameda recommendations by:

$ kubectl get alamedarecommendation -n <your namespace>

and see the details by adding -o yaml flag.

This AlamedaRecommendation CR serves as a good intermediate for programs (including Alameda itself) to reference the recommendations and react to them. For more details, please refer to the alamedarecommendation CRD design.

Visualize Alameda recommendations

If alameda-grafana is deployed, users can also visualize Alameda workload predictions and recommendations through the pre-installed dashboards. The Grafana URL can be figured out by checking the alameda-grafana service name. To access it from outside the cluster, please either modify the service to NodePort type or consider to enable ingress or route. The default account is admin with password admin.

An Example Use Case

The following is an example of the Alameda workflow.

  • First we need a target application such as nginx by:
    $ cd <alameda>/example/samples/nginx
    $ kubectl create -f nginx_deployment.yaml
    
  • Then we request Alameda to recommend resource usage for nginx by:
    $ cd <alameda>/example/samples/nginx
    $ kubectl create -f alamedascaler.yaml
    

You can check that Alameda is watching containers running in the nginx application by:

$ kubectl get alamedascaler --all-namespaces
NAMESPACE   NAME      AGE
webapp      alameda   5h
$ kubectl get alamedascaler alameda -n webapp -o yaml
apiVersion: v1
items:
- apiVersion: autoscaling.containers.ai/v1alpha1
  kind: AlamedaScaler
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"autoscaling.containers.ai/v1alpha1","kind":"AlamedaScaler","metadata":{"annotations":{},"name":"alameda","namespace":"webapp"},"spec":{"enableexecution":true,"policy":"stable","selector":{"matchLabels":{"app":"nginx"}}}}
    creationTimestamp: "2019-02-15T10:51:29Z"
    generation: 3
    name: alameda
    namespace: webapp
    resourceVersion: "2158849"
    selfLink: /apis/autoscaling.containers.ai/v1alpha1/namespaces/webapp/alamedascalers/alameda
    uid: a60c4c47-310f-11e9-accd-000c29b48f2a
  spec:
    enableexecution: true
    policy: stable
    selector:
      matchLabels:
        app: nginx
  status:
    alamedaController:
      deployments:
        webapp/nginx-deployment:
          name: nginx-deployment
          namespace: webapp
          pods:
            webapp/nginx-deployment-7bdddc58f9-6l677:
              containers:
              - name: nginx
                resources: {}
              name: nginx-deployment-7bdddc58f9-6l677
              uid: 960374db-310f-11e9-accd-000c29b48f2a
            webapp/nginx-deployment-7bdddc58f9-wfrbh:
              containers:
              - name: nginx
                resources: {}
              name: nginx-deployment-7bdddc58f9-wfrbh
              uid: 9602a059-310f-11e9-accd-000c29b48f2a
          uid: 95fd011b-310f-11e9-accd-000c29b48f2a
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

And the resource usage recommendations are:

$ kubectl get alamedarecommendation alameda -n webapp -o yaml
apiVersion: v1
items:
- apiVersion: autoscaling.containers.ai/v1alpha1
  kind: AlamedaRecommendation
  metadata:
    creationTimestamp: "2019-02-15T10:51:29Z"
    generation: 13
    labels:
      alamedascaler: alameda.webapp
    name: nginx-deployment-7bdddc58f9-6l677
    namespace: webapp
    ownerReferences:
    - apiVersion: autoscaling.containers.ai/v1alpha1
      blockOwnerDeletion: true
      controller: true
      kind: AlamedaScaler
      name: alameda
      uid: a60c4c47-310f-11e9-accd-000c29b48f2a
    resourceVersion: "2482218"
    selfLink: /apis/autoscaling.containers.ai/v1alpha1/namespaces/webapp/alamedarecommendations/nginx-deployment-7bdddc58f9-6l677
    uid: a60f32f8-310f-11e9-accd-000c29b48f2a
  spec:
    containers:
    - name: nginx
      resources:
        limits:
          cpu: "0"
          memory: 9636Ki
        requests:
          cpu: "0"
          memory: 9636Ki
  status: {}
- apiVersion: autoscaling.containers.ai/v1alpha1
  kind: AlamedaRecommendation
  metadata:
    creationTimestamp: "2019-02-15T10:51:29Z"
    generation: 14
    labels:
      alamedascaler: alameda.webapp
    name: nginx-deployment-7bdddc58f9-wfrbh
    namespace: webapp
    ownerReferences:
    - apiVersion: autoscaling.containers.ai/v1alpha1
      blockOwnerDeletion: true
      controller: true
      kind: AlamedaScaler
      name: alameda
      uid: a60c4c47-310f-11e9-accd-000c29b48f2a
    resourceVersion: "2482651"
    selfLink: /apis/autoscaling.containers.ai/v1alpha1/namespaces/webapp/alamedarecommendations/nginx-deployment-7bdddc58f9-wfrbh
    uid: a61017e6-310f-11e9-accd-000c29b48f2a
  spec:
    containers:
    - name: nginx
      resources:
        limits:
          cpu: "0"
          memory: 9384Ki
        requests:
          cpu: "0"
          memory: 9384Ki
  status: {}
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

By checking the Grafana dashboards, users can also visualize the resource prediction and recommendations.