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