systemd
本教程介绍如何创建systemd适用于 Linux 系统的 KES 服务。
安装
下载适用于您架构和操作系统的最新 KES 二进制文件。
例如linux/amd64运行:
curl -X GET 'https://github.com/minio/kes/releases/latest/download/kes-linux-amd64' --output kes-linux-amd64
sudo install kes-linux-amd64 /usr/local/bin/kes
创建用户/组
为 KES 创建新的 Unix 用户和组:
useradd kes -s /sbin/nologin
如果您选择了不同的用户和组名
The
kes, 更新kes.servicefile.The
kes用户需要具有读取权限/etc/kes/目录。配置
更新 KES 服务器配置/etc/kes/config.yml.
要创建新的 KES 服务器配置文件,请参阅:
以下示例是我们的配置文件FileSystem 指南:
address: 0.0.0.0:7373
admin:
identity: disabled # We disable the admin identity since we don't need it in this guide
tls:
key: private.key
cert: public.crt
policy:
my-app:
allow:
- /v1/key/create/app-key*
- /v1/key/generate/app-key*
- /v1/key/decrypt/app-key*
identities:
- ${APP_IDENTITY}
keystore:
fs:
path: ./keys # Choose a directory for the secret keys
systemd 服务
创建systemd通过创建服务kes.service归档/etc/systemd/system
[Unit]
Description=KES
Documentation=https://github.com/minio/kes/wiki
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/bin/kes
[Service]
WorkingDirectory=/etc/kes/
User=kes
Group=kes
ProtectProc=invisible
ExecStart=/usr/local/bin/kes server --config=/etc/kes/config.yaml
# Let systemd restart this service always
Restart=always
# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65536
# Specifies the maximum number of threads this process can create
TasksMax=infinity
# Disable timeout logic and wait until process is stopped
TimeoutStopSec=infinity
SendSIGKILL=no
# Enable memory locking features used to prevent paging.
AmbientCapabilities=CAP_IPC_LOCK
[Install]
WantedBy=multi-user.target
Privileged Ports
如果您打算在特权端口号(小于 1024 的端口)上运行 KES1024) 服务以常规非特权用户身份运行时root用户,通过添加绑定功能AmbientCapabilities指令在kes.servicefile:
[Service]
AmbientCapabilities=CAP_NET_BIND_SERVICE
开机自启动
要在重启后自动启动 KES,请运行:
systemctl enable kes.service
禁用 `kes.service` 开机启动
通过运行以下命令防止 KES 在重启后自动启动:
systemctl disable kes.service
启动或停止 KES
要启动 KES,请运行:
systemctl start kes.service
要停止 KES,请运行:
systemctl stop kes.service