== Agnostic Scheduler
image:https://github.com/redhat-gpe/agnostics/workflows/Go/badge.svg[Go] image:https://quay.io/repository/redhat-gpte/scheduler/status["Docker Repository on Quay", link="https://quay.io/repository/redhat-gpte/scheduler"]
image::https://gpte-public.s3.amazonaws.com/agnostics/scheduler.png[width=100%]
=== link:https://redhat-gpe.github.io/agnostics/api-reference[API Reference]
=== Usage (server)
[source,subs="+quotes,verbatim,macros"]
----
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 "\git@github.com: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`
[source,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`
[source,yaml]
----
---
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
[source,yaml]
----
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
[source,yaml]
----
- 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 %}
----
. Playbook to delete placement using UUID
[source,yaml]
----
- 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
link:LICENSE[MIT License]
== Contributions
Contributions are welcome! See link:docs/contributors.md[Contributor’s
Guide]
=== Code of Conduct
Be nice :wave:
link:http://docs.ansible.com/ansible/community.html#community-code-of-conduct[Ansible Code of Conduct] applies here.
=== See Also
- https://github.com/redhat-cop/agnosticd
- https://github.com/redhat-cop/agnosticv
- https://github.com/redhat-cop/babylon