From b4a1e300f39b26773250b4af9abcf40ee3b33290 Mon Sep 17 00:00:00 2001 From: George Angel Date: Thu, 13 Feb 2020 08:22:14 +0000 Subject: [PATCH] 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. --- cfssl.tf | 90 +++++++++---------- common.tf | 7 -- etcd.tf | 2 +- master.tf | 9 +- .../cert-fetcher-etcd}/main.tf | 4 +- modules/cert-refresh-master/main.tf | 53 +++++++++++ modules/cert-refresh-node/main.tf | 45 ++++++++++ .../systemd_service_restarter}/main.tf | 4 +- node-common.tf | 5 ++ resources/master-kubelet.service | 12 --- resources/node-kubelet.service | 2 - storage-node.tf | 2 +- worker.tf | 2 +- 13 files changed, 162 insertions(+), 75 deletions(-) rename {cert-fetcher => modules/cert-fetcher-etcd}/main.tf (86%) create mode 100644 modules/cert-refresh-master/main.tf create mode 100644 modules/cert-refresh-node/main.tf rename {systemd_service_restarter => modules/systemd_service_restarter}/main.tf (85%) diff --git a/cfssl.tf b/cfssl.tf index 039cb7d..79bc784 100644 --- a/cfssl.tf +++ b/cfssl.tf @@ -67,9 +67,9 @@ EOS } data "ignition_file" "cfssl-init-ca" { - mode = 493 + mode = 493 filesystem = "root" - path = "/opt/bin/cfssl-init-ca" + path = "/opt/bin/cfssl-init-ca" content { content = file("${path.module}/resources/cfssl-init-ca.sh") @@ -77,9 +77,9 @@ data "ignition_file" "cfssl-init-ca" { } data "ignition_file" "cfssl-init-proxy-pki" { - mode = 493 + mode = 493 filesystem = "root" - path = "/opt/bin/cfssl-init-proxy-pki" + path = "/opt/bin/cfssl-init-proxy-pki" content { content = file("${path.module}/resources/cfssl-init-proxy-pki") @@ -87,9 +87,9 @@ data "ignition_file" "cfssl-init-proxy-pki" { } data "ignition_file" "cfssl-proxy-ca-csr-json" { - mode = 420 + mode = 420 filesystem = "root" - path = "/etc/cfssl/proxy-ca-csr.json" + path = "/etc/cfssl/proxy-ca-csr.json" content { content = file("${path.module}/resources/cfssl-proxy-ca-csr.json") @@ -97,9 +97,9 @@ data "ignition_file" "cfssl-proxy-ca-csr-json" { } data "ignition_file" "cfssl-proxy-csr-json" { - mode = 420 + mode = 420 filesystem = "root" - path = "/etc/cfssl/proxy-csr.json" + path = "/etc/cfssl/proxy-csr.json" content { content = file("${path.module}/resources/cfssl-proxy-csr.json") @@ -110,16 +110,16 @@ data "template_file" "cfssl-server-config" { template = file("${path.module}/resources/cfssl-server-config.json") vars = { - expiry_hours = var.cfssl_node_expiry_hours + expiry_hours = var.cfssl_node_expiry_hours cfssl_unused_key = random_id.cfssl-auth-key-unused.hex - cfssl_auth_key = random_id.cfssl-auth-key-client.hex + cfssl_auth_key = random_id.cfssl-auth-key-client.hex } } data "ignition_file" "cfssl-server-config" { - mode = 384 + mode = 384 filesystem = "root" - path = "/etc/cfssl/config.json" + path = "/etc/cfssl/config.json" content { content = data.template_file.cfssl-server-config.rendered @@ -127,14 +127,14 @@ data "ignition_file" "cfssl-server-config" { } data "ignition_systemd_unit" "cfssl" { - name = "cfssl.service" + name = "cfssl.service" content = file("${path.module}/resources/cfssl.service") } data "ignition_file" "cfssl-sk-csr" { - mode = 420 + mode = 420 filesystem = "root" - path = "/etc/cfssl/sk-csr.json" + path = "/etc/cfssl/sk-csr.json" content { content = <