CoreOS 单元文件实际上是 systemd 单元文件。当您向 fleet 提交单元文件时,它会存储在某个注册表中。当您启动单元文件时,fleet 会将此单元文件传输到/run/fleet/units
机器上的目录中,该单元计划在该目录中运行。当单元停止时,单元文件将从机器中删除。
问题是:fleet 将这些提交的单元文件存储在哪里?我以为那里只是etcd
分布式数据存储。但etcd ls
检查后发现存储中没有单元文件之类的东西。
答案1
哦.. 看来它们存储在 etcd 中的隐藏密钥中,如下所示:
core-02 ~ # etcdctl get /_coreos.com/fleet/states/hello-fleet.service/7fd494f60e2844978072683ea374a7dd
{"loadState":"loaded","activeState":"active","subState":"running","machineState":{"ID":"7fd494f60e2844978072683ea374a7dd","PublicIP":"","Metadata":null,"Version":""},"unitHash":"e738189b45f4421e25cc0990da1c1e37ba0d40c6"}
core-02 ~ # etcdctl get /_coreos.com/fleet/job/hello-fleet.service/object
{"Name":"hello-fleet.service","UnitHash":[231,56,24,155,69,244,66,30,37,204,9,144,218,28,30,55,186,13,64,198]}
core-02 ~ # etcdctl get /_coreos.com/fleet/state/hello-fleet.service
{"loadState":"loaded","activeState":"active","subState":"running","machineState":{"ID":"7fd494f60e2844978072683ea374a7dd","PublicIP":"","Metadata":null,"Version":""},"unitHash":"e738189b45f4421e25cc0990da1c1e37ba0d40c6"}
core-02 ~ # etcdctl get /_coreos.com/fleet/unit/e738189b45f4421e25cc0990da1c1e37ba0d40c6
{"Raw":"[Service]\nExecStart=/usr/bin/bash -c \"while true; do echo 'Hello Fleet'; sleep 1; done\"\n"}
core-02 ~ #