Code Monkey home page Code Monkey logo

agnostics's Introduction

Agnostic Scheduler

Go Docker Repository on Quay

scheduler

Usage (server)

Usage of ./scheduler:
  -api-addr string
        The address API listens to.
        Environment variable: API_ADDR
         (default ":8080")
  -api-auth
        Enable authentication for the API.
        Environment variable: API_AUTH  ('true' or 'false')
         (default true)
  -api-htpasswd string
        The path of the htpasswd file to use for authentication for the API.
        Environment variable: API_HTPASSWD
         (default "api-htpasswd")
  -console-addr string
        The address the Console listens to.
        Environment variable: CONSOLE_ADDR
         (default ":8081")
  -debug
        Debug mode.
        Environment variable: DEBUG

  -git-ssh-private-key string
        The path of the SSH private key used to authenticate to the git repository. Used only when 'git-url' is an SSH URL.
        Environment variable: GIT_SSH_PRIVATE_KEY

  -git-url string
        The URL of the git repository where the scheduler will find its configuration. SSH is assumed, unless the URL starts with 'http'.
        Environment variable: GIT_URL
         (default "[email protected]:redhat-gpe/scheduler-config.git")
  -redis-url string
        The URL to access redis. The format is described by the IANA specification for the scheme, see https://www.iana.org/assignments/uri-schemes/prov/redis
        Environment variable: REDIS_URL
         (default "redis://localhost:6379")
  -template-dir string
        The directory containing the golang templates for the Console.
        Environment variable: TEMPLATE_DIR
         (default "templates")

Config Git repository

The Git repository must contain the following:

  • /policy.yaml - describing the policy.

  • /clouds - directory containting the definition of the resources (clouds) to be scheduled.

example policy.yaml
---
predicates:
  - name: LabelPredicates
  - name: TaintPredicates

priorities:
  - name: LabelPriorities
    weight: 1 # (1)
  - name: TaintPriorities
    weight: 1 # (2)
  1. The weight that will be used to increase the priority of Clouds that match the preferences provided in the Schedule request

  2. The weight that will be used to decrease the priority of Clouds if they have Taints of type "PreferNoSchedule"

example clouds/openstack-blue.yml
---
name: openstack-blue
labels:
  type: osp
  region: na
  datacenter: wdc
  purpose: ilt

Example using the scheduler (client)

Here is an example how the scheduler can be used from ansible.

Input variables
agnosticv_meta:
  scheduler:
    enable: true
    data:
      cloud_preference:
        purpose: development
        region: '{{ region }}'
      uuid: '{{ uuid }}'
    endpoint: /api/v1/schedule
    url: https://scheduler.example.com
Playbook to schedule or retrieve a placement using UUID
- name: Schedule or retrieve a placement using UUID
  hosts: localhost
  gather_facts: false
  vars:
    output: /tmp/placement.json
  tasks:
    - name: Schedule a placement
      uri:
        url: "{{ agnosticv_meta.scheduler.url + agnosticv_meta.scheduler.endpoint }}"
        validate_certs: "{{ agnosticv_meta.scheduler.validate_certs | default(false) }}"
        return_content: true
        method: POST
        body_format: json
        body: "{{ agnosticv_meta.scheduler.data }}"
        status_code: [200, 400]
        dest: "{{ output }}"
      register: r_placement
      retries: 10
      delay: 30
      until: r_placement is succeeded

    - when: >-
        r_placement.status == 400
        and 'service uuid already has a placement' in r_placement.json.message
      name: Get placement using uuid
      uri:
        url: "{{ agnosticv_meta.scheduler.url }}/api/v1/placements/{{ uuid }}"
        validate_certs: "{{ agnosticv_meta.scheduler.validate_certs | default(false) }}"
        return_content: true
        method: GET
        dest: "{{ output }}"
      register: g_placement
      retries: 10
      delay: 30
      until: g_placement is succeeded

    - debug:
        msg: >-
          {% if r_placement.json.cloud is defined %}
          {{ r_placement.json.cloud.name }}
          {% else %}
          {{ r_placement.json.message }}: {{ g_placement.json.cloud.name }}
          {% endif %}
  1. Playbook to delete placement using UUID

- name: Delete placement using UUID
  hosts: localhost
  gather_facts: false
  tasks:
    - name: Delete placement using uuid
      uri:
        url: "{{ agnosticv_meta.scheduler.url }}/api/v1/placements/{{ uuid }}"
        validate_certs: "{{ agnosticv_meta.scheduler.validate_certs | default(false) }}"
        return_content: true
        method: DELETE
      register: r_placement
      retries: 10
      delay: 30
      until: r_placement is succeeded

License

The scripts and documentation in this project are released under the MIT License

agnostics's People

Contributors

9strands avatar fridim avatar jkupferer avatar josephassiga avatar yvarbanov avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

jkupferer fridim

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.