The infrastructure should be running now: the last steps are to deploy our services.
traefik discovers the different services and nodes by requesting Consul. The refresh interval is set at 15 seconds by default.
This means that traefik will possibly be aware of a change only after 15 seconds and will keep sending traffic during this interval. This can of course results in errors (as the service could have been migrated to another node or simply shutdown on this node, etc.).
We have to instruct Nomad to delay the shutdown of an allocation after it has been seen by traefik. We will use this option:
shutdown_delay = "20s"
See here
The sources of this webiste are available here:
See here for the Github Actions that creates the Docker image
The different steps to deploy this website are:
on Github Actions, pushing a new tag that will trigger:
manually running the Nomad job that will:
You can also notice that
To start a job, you only need to call its file.
nomad run <job name>.nomad
Check the status of the different jobs:
nomad job status
nomad job status <job name>
On important part is the stats about deployed instances:
Latest Deployment
ID = e243a9eb
Status = failed
Description = Failed due to progress deadline
Summary
Task Group Queued Starting Running Failed Complete Lost
http 0 0 2 7 69 0
It is also possible to access the logs of the different allocations.
Identify the allocation’s id:
nomad job status <job name>
You should have as a result:
Allocations
ID Node ID Task Group Version Desired Status Created Modified
168711f9 867e4021 http 72 run running 17h35m ago 17h30m ago
8b45c8c1 65dec082 http 72 run running 17h35m ago 17h30m ago
For logs on stdout:
nomad alloc logs -f <alloc id>
For logs on stderr:
nomad alloc logs -f -stderr <alloc id>
You should end now with everything working together: