-
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.
- Use a common template for nodes kubelets and kubelet configs - Install disk-mounter and not rely on it being installed by another systemd
- Loading branch information
Foivos Filippopoulos
committed
Jul 23, 2019
1 parent
56ee749
commit 6cea97e
Showing
11 changed files
with
326 additions
and
158 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
// All nodes should belong to system:nodes group | ||
data "template_file" "node-cfssl-new-cert" { | ||
template = file("${path.module}/resources/cfssl-new-cert.sh") | ||
|
||
vars = { | ||
cert_name = "node" | ||
user = "root" | ||
group = "root" | ||
profile = "client" | ||
path = "/etc/kubernetes/ssl" | ||
cn = "system:node:$(${var.node_name_command[var.cloud_provider]})" | ||
org = "system:nodes" | ||
get_ip = var.get_ip_command[var.cloud_provider] | ||
extra_names = "" | ||
} | ||
} | ||
|
||
data "ignition_file" "node-cfssl-new-cert" { | ||
mode = 493 | ||
filesystem = "root" | ||
path = "/opt/bin/cfssl-new-cert" | ||
|
||
content { | ||
content = data.template_file.node-cfssl-new-cert.rendered | ||
} | ||
} | ||
|
||
// Kubeconfig will be the same for all kubernetes nodes as it only | ||
// contains master address and certs | ||
data "template_file" "node-kubeconfig" { | ||
template = file("${path.module}/resources/node-kubeconfig") | ||
|
||
vars = { | ||
master_address = var.master_address | ||
} | ||
} | ||
|
||
data "ignition_file" "node-kubeconfig" { | ||
mode = 420 | ||
filesystem = "root" | ||
path = "/var/lib/kubelet/kubeconfig" | ||
|
||
content { | ||
content = data.template_file.node-kubeconfig.rendered | ||
} | ||
} | ||
|
||
// Kubelet config | ||
data "template_file" "node-kubelet-conf" { | ||
template = file("${path.module}/resources/node-kubelet-conf.yaml") | ||
|
||
vars = { | ||
cluster_dns = local.cluster_dns_yaml | ||
feature_gates = local.feature_gates_yaml_fragment | ||
} | ||
} | ||
|
||
data "ignition_file" "node-kubelet-conf" { | ||
mode = 420 | ||
filesystem = "root" | ||
path = "/etc/kubernetes/config/node-kubelet-conf.yaml" | ||
|
||
content { | ||
content = data.template_file.node-kubelet-conf.rendered | ||
} | ||
} | ||
|
||
|
||
data "ignition_file" "node-sysctl-vm" { | ||
mode = 420 | ||
filesystem = "root" | ||
path = "/etc/sysctl.d/vm.conf" | ||
|
||
content { | ||
content = "vm.max_map_count=262144" | ||
} | ||
} | ||
|
||
// Common prometheus text-collector metrics for nodes | ||
data "template_file" "prometheus-tmpfs-dir" { | ||
template = file("${path.module}/resources/prometheus-tmpfs-dir.service") | ||
} | ||
|
||
data "ignition_systemd_unit" "prometheus-tmpfs-dir" { | ||
name = "prometheus-tmpfs-dir.service" | ||
content = data.template_file.prometheus-tmpfs-dir.rendered | ||
} | ||
|
||
data "template_file" "prometheus-ro-rootfs" { | ||
template = file("${path.module}/resources/prometheus-ro-rootfs.service") | ||
} | ||
|
||
data "ignition_systemd_unit" "prometheus-ro-rootfs" { | ||
name = "prometheus-ro-rootfs.service" | ||
content = data.template_file.prometheus-ro-rootfs.rendered | ||
} | ||
|
||
data "template_file" "prometheus-ro-rootfs-timer" { | ||
template = file("${path.module}/resources/prometheus-ro-rootfs.timer") | ||
} | ||
|
||
data "ignition_systemd_unit" "prometheus-ro-rootfs-timer" { | ||
name = "prometheus-ro-rootfs.timer" | ||
content = data.template_file.prometheus-ro-rootfs-timer.rendered | ||
} | ||
|
||
data "ignition_file" "prometheus-ro-rootfs" { | ||
mode = 493 | ||
filesystem = "root" | ||
path = "/opt/bin/prometheus-ro-rootfs" | ||
|
||
content { | ||
content = file("${path.module}/resources/prometheus-ro-rootfs") | ||
} | ||
} |
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
File renamed without changes.
File renamed without changes.
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,39 @@ | ||
[Unit] | ||
Description=Kubernetes Kubelet | ||
Requires=docker.service | ||
After=docker.service | ||
[Service] | ||
ExecStartPre=/usr/bin/mkdir -p /etc/kubernetes/manifests | ||
ExecStartPre=/usr/bin/mkdir -p /var/log/containers | ||
ExecStartPre=/usr/bin/mkdir -p /opt/cni/bin | ||
ExecStartPre=/usr/bin/mkdir -p /var/lib/cni | ||
ExecStartPre=/usr/bin/mkdir -p /etc/cni/net.d | ||
ExecStartPre=/usr/bin/mkdir -p /var/run/calico | ||
ExecStartPre=/usr/bin/mkdir -p /var/lib/calico | ||
# This is a partial workaround to this upstream Kubernetes issue: | ||
# https://github.com/kubernetes/kubernetes/issues/41916#issuecomment-312428731 | ||
ExecStartPre=/sbin/sysctl -w net.ipv4.tcp_retries2=8 | ||
# This is a temporal workaround this upstream Kubernetes issue: | ||
# https://github.com/kubernetes/kubernetes/issues/69015 | ||
ExecStartPre=/sbin/sysctl -w fs.inotify.max_user_watches=524288 | ||
ExecStartPre=/opt/bin/cfssl-new-cert | ||
ExecStart=${kubelet_binary_path} \ | ||
--allow-privileged \ | ||
%{ if cloud_provider != "" } --cloud-provider=${cloud_provider} \ | ||
%{ endif ~} | ||
--cni-bin-dir=/opt/cni/bin \ | ||
--cni-conf-dir=/etc/cni/net.d \ | ||
--config=/etc/kubernetes/config/node-kubelet-conf.yaml \ | ||
--container-runtime=docker \ | ||
--exit-on-lock-contention \ | ||
--kubeconfig=/var/lib/kubelet/kubeconfig \ | ||
--network-plugin=cni \ | ||
--node-labels=role=${role} \ | ||
%{ if taints != "" } --register-with-taints=${taints} \ | ||
%{ endif ~} | ||
--lock-file=/var/run/lock/kubelet.lock \ | ||
--v=0 | ||
Restart=always | ||
RestartSec=10 | ||
[Install] | ||
WantedBy=multi-user.target |
Oops, something went wrong.