-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the cert fetch and restart calls into separate unit (#105)
* Move the cert fetch and restart calls into separate unit Decouples kubelet service from certificate refreshing. Failing to fetch new certificates doesn't restart kubelet or other components. Restarting kubelet no longer refreshes certificates or restarts other components.
- Loading branch information
1 parent
41eaa9e
commit b4a1e30
Showing
13 changed files
with
162 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
variable "on_calendar" { | ||
type = string | ||
} | ||
|
||
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 | ||
Requires=docker.service | ||
After=network-online.target | ||
[Service] | ||
Type=oneshot | ||
ExecStart=/opt/bin/cfssl-keys-and-certs-get | ||
ExecStart=/opt/bin/cfssl-new-node-cert | ||
ExecStart=/opt/bin/cfssl-new-kubelet-cert | ||
ExecStart=/opt/bin/cfssl-new-apiserver-cert | ||
ExecStart=/opt/bin/cfssl-new-apiserver-kubelet-client-cert | ||
ExecStart=/opt/bin/cfssl-new-scheduler-cert | ||
ExecStart=/opt/bin/cfssl-new-controller-manager-cert | ||
# Hack to reload certs on control plane tier | ||
# https://github.com/kubernetes/kubernetes/issues/46287 | ||
ExecStart=/usr/bin/systemctl try-restart kubelet.service | ||
ExecStart=-/bin/sh -c "docker restart $(docker ps -q -f name=k8s_kube-controller-manager)" | ||
ExecStart=-/bin/sh -c "docker restart $(docker ps -q -f name=k8s_kube-apiserver)" | ||
ExecStart=-/bin/sh -c "docker restart $(docker ps -q -f name=k8s_kube-scheduler)" | ||
[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.id, | ||
data.ignition_systemd_unit.cert-refresh-timer.id, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
variable "on_calendar" { | ||
type = string | ||
} | ||
|
||
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 | ||
Requires=docker.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 | ||
[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.id, | ||
data.ignition_systemd_unit.cert-refresh-timer.id, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters