Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AI4EOSC API and Dash to the template #230

Merged
merged 3 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading