可以在任务中以非 root 用户身份运行Nomad raw_exec 驱动程序的进程吗?理想情况下,希望以 root 身份运行 nomad,然后删除权限以以目标用户身份运行命令:
job "show_id_job" {
datacenters = ["dc1"]
priority = 100
type = "batch"
constraint {
attribute = "${attr.unique.hostname}"
value = "myhost.company.com"
}
group "show_id_group" {
network {
mode = "host"
}
task "show_id" {
driver = "raw_exec"
config {
command = "/usr/bin/su"
args = ["--login", "regularuser", "/usr/bin/id"]
}
}
}
}
但是当我运行这项工作时它失败了:
Oct 23 19:51:03 myhost.company.com nomad[300160]: client: allocation updates applied: added=0 removed=0 updated=4 ignored=4 errors=0
Oct 23 19:51:03 myhost.company.com su[385531]: pam_unix(su-l:session): session closed for user regularuser
Oct 23 19:51:03 myhost.company.com nomad[300160]: 2020-10-23T19:51:03.822-0400 [ERROR] client.driver_mgr.raw_exec: error receiving stream from Stats executor RPC, closing stream: alloc_id=fbe2e6d9-930e-acff-83c7-9d0f83b2e085 driver=raw_exec task_name=show_id error="rpc error: code = Unavailable desc = transport is closing"
Oct 23 19:51:03 myhost.company.com nomad[300160]: 2020-10-23T19:51:03.822-0400 [ERROR] client.alloc_runner.task_runner.task_hook.stats_hook: failed to start stats collection for task: alloc_id=fbe2e6d9-930e-acff-83c7-9d0f83b2e085 task=show_id error="rpc error: code = Canceled desc = grpc: the client connection is closing"
我在文档中找不到任何可以让我做同样事情的参数
有没有人遇到过这个问题?
谢谢!