-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.tf
53 lines (47 loc) · 1.29 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
variable "on_calendar" {
type = string
}
variable "use_deprecated_docker_runtime" {
description = "Use legacy docker container runtime"
default = false
type = bool
}
data "ignition_systemd_unit" "cert-refresh" {
name = "cert-refresh.service"
content = <<EOS
[Unit]
Description=Fetch new certificates from cfssl server and restart components to reload certs
${var.use_deprecated_docker_runtime ? "Requires=docker.service" : "Requires=containerd.service" }
After=network-online.target
[Service]
Type=oneshot
ExecStart=/opt/bin/cfssl-new-cert
ExecStart=/opt/bin/cfssl-new-kubelet-cert
# Hack to reload certs on control plane tier
# https://github.com/kubernetes/kubernetes/issues/46287
ExecStart=/usr/bin/systemctl try-restart kubelet.service
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
EOS
}
data "ignition_systemd_unit" "cert-refresh-timer" {
name = "cert-refresh.timer"
content = <<EOS
[Unit]
Description=Fetch new certificates from cfssl server and restart components to reload certs
[Timer]
OnCalendar=${var.on_calendar}
AccuracySec=1s
RandomizedDelaySec=60min
[Install]
WantedBy=timers.target
EOS
}
output "systemd_units" {
value = [
data.ignition_systemd_unit.cert-refresh.rendered,
data.ignition_systemd_unit.cert-refresh-timer.rendered,
]
}