|
|
@@ -66,19 +66,25 @@ resource "null_resource" "k3s_install_worker1" {
|
|
|
"TOKEN=$(cat /root/node-token)",
|
|
|
"echo -e '\\033[32m--Install k3s-agent systemd service--\\033[0m'",
|
|
|
# 注册 systemd 服务
|
|
|
- "cat > /etc/systemd/system/k3s-agent.service <<EOF",
|
|
|
- "[Unit]",
|
|
|
- "Description=K3s Agent",
|
|
|
- "After=network.target",
|
|
|
- "[Service]",
|
|
|
- "ExecStart=/usr/local/bin/k3s agent --server https://${var.master_ip}:6443 --token $TOKEN --node-name worker-node-${replace(var.worker_ips[0], \".\", \"-\")} --node-external-ip=${var.worker_ips[0]} --data-dir /var/lib/rancher/k3s",
|
|
|
- "Restart=always",
|
|
|
- "KillMode=process",
|
|
|
- "Delegate=yes",
|
|
|
- "LimitNOFILE=65536",
|
|
|
- "[Install]",
|
|
|
- "WantedBy=multi-user.target",
|
|
|
- "EOF",
|
|
|
+ "echo '[Unit]
|
|
|
+Description=Lightweight Kubernetes
|
|
|
+Documentation=https://k3s.io
|
|
|
+After=network-online.target
|
|
|
+Wants=network-online.target
|
|
|
+[Service]
|
|
|
+Type=notify
|
|
|
+ExecStart=/usr/local/bin/k3s agent --server https://${var.master_ip}:6443 --token $TOKEN --node-name worker-node-${replace(var.worker_ips[1], ".", "-")} --node-external-ip=${var.worker_ips[0]} --data-dir /var/lib/rancher/k3s
|
|
|
+KillMode=process
|
|
|
+Delegate=yes
|
|
|
+LimitNOFILE=1048576
|
|
|
+LimitNPROC=infinity
|
|
|
+LimitCORE=infinity
|
|
|
+TasksMax=infinity
|
|
|
+TimeoutStartSec=0
|
|
|
+Restart=always
|
|
|
+RestartSec=5s
|
|
|
+[Install]
|
|
|
+WantedBy=multi-user.target' > /etc/systemd/system/k3s-agent.service",
|
|
|
"systemctl daemon-reload",
|
|
|
"systemctl enable --now k3s-agent",
|
|
|
"echo -e '\\033[32m--k3s agent started successfully--\\033[0m'",
|
|
|
@@ -109,19 +115,25 @@ resource "null_resource" "k3s_install_worker2" {
|
|
|
"TOKEN=$(cat /root/node-token)",
|
|
|
"echo -e '\\033[32m--Install k3s-agent systemd service--\\033[0m'",
|
|
|
# 注册 systemd 服务
|
|
|
- "cat > /etc/systemd/system/k3s-agent.service <<EOF",
|
|
|
- "[Unit]",
|
|
|
- "Description=K3s Agent",
|
|
|
- "After=network.target",
|
|
|
- "[Service]",
|
|
|
- "ExecStart=/usr/local/bin/k3s agent --server https://${var.master_ip}:6443 --token $TOKEN --node-name worker-node-${replace(var.worker_ips[0], \".\", \"-\")} --node-external-ip=${var.worker_ips[1]} --data-dir /var/lib/rancher/k3s",
|
|
|
- "Restart=always",
|
|
|
- "KillMode=process",
|
|
|
- "Delegate=yes",
|
|
|
- "LimitNOFILE=65536",
|
|
|
- "[Install]",
|
|
|
- "WantedBy=multi-user.target",
|
|
|
- "EOF",
|
|
|
+ "echo '[Unit]
|
|
|
+Description=Lightweight Kubernetes
|
|
|
+Documentation=https://k3s.io
|
|
|
+After=network-online.target
|
|
|
+Wants=network-online.target
|
|
|
+[Service]
|
|
|
+Type=notify
|
|
|
+ExecStart=/usr/local/bin/k3s agent --server https://${var.master_ip}:6443 --token $TOKEN --node-name worker-node-${replace(var.worker_ips[1], ".", "-")} --node-external-ip=${var.worker_ips[1]} --data-dir /var/lib/rancher/k3s
|
|
|
+KillMode=process
|
|
|
+Delegate=yes
|
|
|
+LimitNOFILE=1048576
|
|
|
+LimitNPROC=infinity
|
|
|
+LimitCORE=infinity
|
|
|
+TasksMax=infinity
|
|
|
+TimeoutStartSec=0
|
|
|
+Restart=always
|
|
|
+RestartSec=5s
|
|
|
+[Install]
|
|
|
+WantedBy=multi-user.target' > /etc/systemd/system/k3s-agent.service",
|
|
|
"systemctl daemon-reload",
|
|
|
"systemctl enable --now k3s-agent",
|
|
|
"echo -e '\\033[32m--k3s agent started successfully--\\033[0m'",
|