dpewsey
November 25, 2022, 11:28am
1
Hi,
We’re trying to switch the logging driver on nomad from default into using the loki docker driver plugin.
{
"dns": ["172.17.0.1"],
"debug" : true,
"log-driver": "loki",
"log-opts": {
"loki-url": "https://loki.domain.com/loki/api/v1/push",
"loki-batch-size": "400",
"loki-retries": "0",
"env": "NOMAD_JOB_NAME",
"labels": "service"
}
}
However, the jobs don’t seem to get updated in terms of nomad specs, how do you force nomad to deploy with the updated driver without needing to define the driver in each jobspec?
jrasell
November 25, 2022, 11:43am
2
Hi @dpewsey ,
What Nomad config object does this represent?
Thanks,
jrasell and the Nomad team
dpewsey
November 25, 2022, 11:52am
3
Hi @jrasell
This is the docker daemon.json /etc/docker/daemon.json
With an average jobspec looking like such
task "grafana" {
driver = "docker"
env {
GF_PATHS_PROVISIONING="/local/provisioning"
}
config {
image = ""
args = ["--config=/local/grafana.yaml"]
ports = ["grafana"]
logging {
}
}
however when redeploying the app the logging driver remains json-file
docker inspect bd9d90285104 | jq '.[].HostConfig.LogConfig'
{
"Type": "json-file",
"Config": {
"max-file": "2",
"max-size": "2m"
}
}
dpewsey
November 25, 2022, 12:55pm
4
Digging a bit more the only way it seems to get updated is by adding a blank logging and config stanza, otherwise it doesn’t seem to pick it up.
config {
image = ""
args = ["--config=/local/grafana.yaml"]
ports = ["grafana"]
logging {
config {}
}
}
It there a way to apply this to all jobs without the need to update all the specs?
jrasell
November 25, 2022, 1:13pm
5
Hi @dpewsey ,
It there a way to apply this to all jobs without the need to update all the specs?
There is not unfortunately as Nomad does not have a notion of external admissions controllers that can mutate all jobs on registration.
Thanks,
jrasell and the Nomad team
dpewsey
November 25, 2022, 1:59pm
6
Hi @jrasell
Thanks for the reply, how annoying.
Is there another way to get nomad job to use the logging config specified via docker without needing to include it in the jobspec? eg like a default open when using the docker driver or to use the docker driver’s details?
jrasell
November 25, 2022, 2:34pm
7
Hi @dpewsey ,
I believe you can configure the logging block within the Nomad client configuration file. This should set the default logging configuration which all Docker containers receive.
Thanks,
jrasell and the Nomad team
dpewsey
November 25, 2022, 2:51pm
8
Ah that’s that did it, once the containers have been restarted thanks!
1 Like