Skip to content

Commit

Permalink
Merge pull request #230 from grycap/devel
Browse files Browse the repository at this point in the history
Add AI4EOSC API and Dash to the template
  • Loading branch information
micafer authored Jan 13, 2025
2 parents 6b8e743 + ccdaa7a commit ce6b5ff
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 3 deletions.
108 changes: 107 additions & 1 deletion artifacts/lrms/nomad_ai4eosc_fe_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
nvidia_support: false
certs_url: "{{ consul_cert_url | default('') }}"
consul_join: "{{ consul_server_join | default('') }}"
API_HOST: "{{ ai4eosc_api_host | default('') }}"
DASHBOARD_HOST: "{{ ai4eosc_dashboard_host | default('') }}"
pre_tasks:
- name: Convert server_list to list
set_fact:
Expand Down Expand Up @@ -166,7 +168,7 @@

- name: Set facts
set_fact:
consul_servers_ip: "{{ consul_servers_ip + [ consul_join ] }}"
consul_servers_ip: "{{ consul_servers_ip + [consul_join] }}"
from_scratch_cluster_installation: false
when: consul_join != ''

Expand Down Expand Up @@ -202,3 +204,107 @@
- name: Invoke nomad role
include_role:
name: nomad

- when: API_HOST != '' and DASHBOARD_HOST != ''
block:

- name: Get list of running jobs
command: nomad job status -namespace ai4eosc
register: nomad_jobs
changed_when: false

- name: Check if a api-dashboard job is running
set_fact:
api_dashboard_running: "{{ 'api-dashboard' in nomad_jobs.stdout }}"
changed_when: false

- when: not api_dashboard_running
block:

- name: Creat API-Dashboard job file
copy:
dest: "{{ path }}/api-dashboard.hcl"
owner: cloudadm
mode: '0755'
content: |
job "api-dashboard" {
namespace = "ai4eosc"
type = "service"
id = "api-dashboard"
priority = "50"
group "usergroup" {
network {
port "api" {
to = 80
}
port "dashboard" {
to = 80
}
}
service {
name = "ai4eosc-service"
port = "dashboard"
tags = [
"traefik.enable=true",
"traefik.http.routers.ai4eosc.tls=true",
"traefik.http.routers.ai4eosc.rule=Host(`{{ DASHBOARD_HOST }}`)",
]
}
service {
name = "api-ai4eosc-service"
port = "api"
tags = [
"traefik.enable=true",
"traefik.http.routers.api-ai4eosc.tls=true",
"traefik.http.routers.api-ai4eosc.rule=Host(`{{ API_HOST }}`)",
]
}
ephemeral_disk {
size = 500
}
task "api" {
driver = "docker"
config {
force_pull = true
image = "registry.services.ai4os.eu/ai4os/ai4-papi:nomad"
ports = ["api"]
volumes = [
"/etc/nomad.d/certs:/home/nomad-certs",
]
}
env {
DASHBOARD_URL = "https://{{ DASHBOARD_HOST }}"
NOMAD_ADDR = "https://{{ server_private_ip }}:4646"
NOMAD_CACERT = "/home/nomad-certs/nomad-ca.pem"
NOMAD_CLIENT_CERT = "/home/nomad-certs/nomad-cli.pem"
NOMAD_CLIENT_KEY = "/home/nomad-certs/nomad-cli-key.pem"
}
resources {
cores = 1
memory = 500
}
}
task "dashboard" {
driver = "docker"
config {
force_pull = true
image = "registry.services.ai4os.eu/ai4os/ai4eosc-dashboard:ai4-dashboard-nomad"
ports = ["dashboard"]
}
env {
API_SERVER = "https://{{ API_HOST }}/v1"
}
resources {
cores = 1
memory = 500
}
}
}
}
- name: "Run api-dashboard job"
command: nomad job run api-dashboard.hcl
args:
chdir: "{{ path }}"
async: 60
poll: 5
16 changes: 14 additions & 2 deletions templates/nomad_ai4eosc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: Deploy an Consul + Nomad Virtual Cluster (AI4EOSC).

metadata:
template_name: Nomad
template_version: "1.1.1"
template_version: "1.2.0"
display_name: Deploy a Consul + Nomad Virtual Cluster
icon: images/nomad.png
tabs:
Expand All @@ -22,7 +22,8 @@ metadata:
- nomad_dc
- nomad_domain
- nomad_namespaces

- ai4eosc_api_host
- ai4eosc_dashboard_host
topology_template:
inputs:

Expand Down Expand Up @@ -161,6 +162,15 @@ topology_template:
default: [ ai4eosc, imagine, tutorials ]
required: yes

ai4eosc_api_host:
type: string
description: AI4EOSC API DNS name (if empty, the AI4EOSC API will not be installed)
default: ''
ai4eosc_dashboard_host:
type: string
description: AI4EOSC Dashboard DNS name (if empty, the AI4EOSC Dashboard will not be installed)
default: ''

node_templates:

lrms_front_end:
Expand Down Expand Up @@ -210,6 +220,8 @@ topology_template:
nomad_input_dc: { get_input: nomad_dc }
nomad_input_domain: { get_input: nomad_domain }
nomad_input_namespaces: { get_input: nomad_namespaces }
ai4eosc_api_host: { get_input: ai4eosc_api_host }
ai4eosc_dashboard_host: { get_input: ai4eosc_dashboard_host }

front:
type: tosca.nodes.indigo.Compute
Expand Down

0 comments on commit ce6b5ff

Please sign in to comment.