From 4d3c69a7104bd275e057dc918590100f01785811 Mon Sep 17 00:00:00 2001 From: distrobyte Date: Wed, 4 Oct 2023 19:34:42 +0100 Subject: [PATCH 1/3] Add job for a nova-timetable user project This file directory structure can be used for 4th year projects (user-projects/(third/fourth)-year-project) I can't validate this, but checkout this branch on one of the hosts and run `nomad job validate ` to ensure the config is okay, followed by `nomad job plan ` to plan it. Run the job at that point using the check-id. Once you're happy that it runs, return to the master branch and merge this PR. nova@redbrick.dcu.ie requested this to be deployed. A DNS entry will need to be made before planning to ensure that the cert can be generated by traefik. --- jobs/user-projects/general/nova-timetable.hcl | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 jobs/user-projects/general/nova-timetable.hcl diff --git a/jobs/user-projects/general/nova-timetable.hcl b/jobs/user-projects/general/nova-timetable.hcl new file mode 100644 index 0000000..76611c3 --- /dev/null +++ b/jobs/user-projects/general/nova-timetable.hcl @@ -0,0 +1,40 @@ +job "nova-timetable" { + datacenters = ["aperture"] + + type = "service" + + group "nova-timetable" { + count = 1 + + network { + port "http" { + to = 80 + } + } + + service { + port = "http" + name = "nova-timetable" + check { + type = "http" + path = "/" + interval = "10s" + timeout = "2s" + } + + tags = [ + "traefik.enable=true", + "traefik.http.routers.nova-timetable.rule=Host(`timetable.redbrick.dcu.ie`)", + "traefik.http.routers.nova-timetable.tls=true", + ] + } + + task "python-application" { + driver = "docker" + config { + image = "novanai/timetable-sync" + ports = ["http"] + } + } + } +} From 2a7d91e33302dec00ca0b4282021d5f1a730622f Mon Sep 17 00:00:00 2001 From: James Hackett Date: Sun, 8 Oct 2023 02:17:55 +0100 Subject: [PATCH 2/3] Update after some testing and validation No "200" status for our healthchecks to validate job readiness. Workaround is to remove the check. --- jobs/traefik.hcl | 2 +- jobs/user-projects/general/nova-timetable.hcl | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/jobs/traefik.hcl b/jobs/traefik.hcl index 3813cb7..0ded606 100644 --- a/jobs/traefik.hcl +++ b/jobs/traefik.hcl @@ -24,7 +24,7 @@ job "traefik" { task "traefik" { driver = "docker" config { - image = "traefik:2.8" + image = "traefik" network_mode = "host" volumes = [ diff --git a/jobs/user-projects/general/nova-timetable.hcl b/jobs/user-projects/general/nova-timetable.hcl index 76611c3..5c94ff3 100644 --- a/jobs/user-projects/general/nova-timetable.hcl +++ b/jobs/user-projects/general/nova-timetable.hcl @@ -15,17 +15,12 @@ job "nova-timetable" { service { port = "http" name = "nova-timetable" - check { - type = "http" - path = "/" - interval = "10s" - timeout = "2s" - } tags = [ "traefik.enable=true", "traefik.http.routers.nova-timetable.rule=Host(`timetable.redbrick.dcu.ie`)", - "traefik.http.routers.nova-timetable.tls=true", + "traefik.http.routers.nova-timetable.entrypoints=web,websecure", + "traefik.http.routers.nova-timetable.tls.certresolver=lets-encrypt", ] } From e5ffb4033c349440c7f78872091db993f2e6b5ae Mon Sep 17 00:00:00 2001 From: wizzdom Date: Wed, 11 Oct 2023 01:14:58 +0100 Subject: [PATCH 3/3] add health check on /healthcheck --- jobs/user-projects/general/nova-timetable.hcl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jobs/user-projects/general/nova-timetable.hcl b/jobs/user-projects/general/nova-timetable.hcl index 5c94ff3..790340f 100644 --- a/jobs/user-projects/general/nova-timetable.hcl +++ b/jobs/user-projects/general/nova-timetable.hcl @@ -15,6 +15,12 @@ job "nova-timetable" { service { port = "http" name = "nova-timetable" + check { + type = "http" + path = "/healthcheck" + interval = "10s" + timeout = "2s" + } tags = [ "traefik.enable=true",