From 3322c76de7cc4b03bc705e0ba90703baf9917b52 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Mon, 13 Jan 2025 12:05:28 +0100 Subject: [PATCH 1/3] Add AI4EOSC API and Dash to the template --- artifacts/lrms/nomad_ai4eosc_fe_install.yml | 105 ++++++++++++++++++++ templates/nomad_ai4eosc.yaml | 16 ++- 2 files changed, 119 insertions(+), 2 deletions(-) diff --git a/artifacts/lrms/nomad_ai4eosc_fe_install.yml b/artifacts/lrms/nomad_ai4eosc_fe_install.yml index 6d9353c..64dd762 100644 --- a/artifacts/lrms/nomad_ai4eosc_fe_install.yml +++ b/artifacts/lrms/nomad_ai4eosc_fe_install.yml @@ -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: @@ -202,3 +204,106 @@ - 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 + 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 diff --git a/templates/nomad_ai4eosc.yaml b/templates/nomad_ai4eosc.yaml index bf13fe2..8e010d9 100644 --- a/templates/nomad_ai4eosc.yaml +++ b/templates/nomad_ai4eosc.yaml @@ -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: @@ -22,7 +22,8 @@ metadata: - nomad_dc - nomad_domain - nomad_namespaces - + - ai4eosc_api_host + - ai4eosc_dashboard_host topology_template: inputs: @@ -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: @@ -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 From dd37195f9ca0835bda176199072c06301de6f035 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Mon, 13 Jan 2025 12:44:30 +0100 Subject: [PATCH 2/3] Fix lint --- artifacts/lrms/nomad_ai4eosc_fe_install.yml | 196 ++++++++++---------- 1 file changed, 98 insertions(+), 98 deletions(-) diff --git a/artifacts/lrms/nomad_ai4eosc_fe_install.yml b/artifacts/lrms/nomad_ai4eosc_fe_install.yml index 64dd762..5d4ba9b 100644 --- a/artifacts/lrms/nomad_ai4eosc_fe_install.yml +++ b/artifacts/lrms/nomad_ai4eosc_fe_install.yml @@ -168,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 != '' @@ -208,102 +208,102 @@ - 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 - content: | - job "api-dashboard" { - namespace = "ai4eosc" - type = "service" - id = "api-dashboard" - priority = "50" - group "usergroup" { - network { - port "api" { - to = 80 + - 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 + 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 + } + } } - 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 + + - name: "Run api-dashboard job" + command: nomad job run api-dashboard.hcl + args: + chdir: "{{ path }}" + async: 60 + poll: 5 From ccdaa7afd83b27025716895ede1ae38e7f5bed79 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Mon, 13 Jan 2025 12:48:32 +0100 Subject: [PATCH 3/3] Fix error --- artifacts/lrms/nomad_ai4eosc_fe_install.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/artifacts/lrms/nomad_ai4eosc_fe_install.yml b/artifacts/lrms/nomad_ai4eosc_fe_install.yml index 5d4ba9b..13a8e05 100644 --- a/artifacts/lrms/nomad_ai4eosc_fe_install.yml +++ b/artifacts/lrms/nomad_ai4eosc_fe_install.yml @@ -225,6 +225,7 @@ copy: dest: "{{ path }}/api-dashboard.hcl" owner: cloudadm + mode: '0755' content: | job "api-dashboard" { namespace = "ai4eosc"