Skip to content

Commit 32ec37f

Browse files
committed
Configure etcd with a config file instead of ExecStart arguments
1 parent 936b38c commit 32ec37f

File tree

7 files changed

+46
-15
lines changed

7 files changed

+46
-15
lines changed

manifests/profile/kubelet.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@
5454
notify => Exec["kubelet reload daemon"],
5555
}
5656

57+
file { "/etc/kubernetes/kubelet.yaml":
58+
content => template("nebula/profile/kubelet/config.yaml.erb"),
59+
require => Package["kubelet"],
60+
notify => Service["kubelet"],
61+
}
62+
5763
exec { 'kubelet reload daemon':
5864
command => "/bin/systemctl daemon-reload",
5965
refreshonly => true,

manifests/profile/kubernetes/bootstrap/etcd_config.pp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
notify => Exec['kubelet reload daemon'],
1818
}
1919

20+
$pod_manifest_path = "/etc/kubernetes/manifests"
21+
file { "/etc/kubernetes/kubelet.yaml":
22+
content => template("nebula/profile/kubelet/config.yaml.erb"),
23+
require => Package["kubelet"],
24+
notify => Service["kubelet"],
25+
}
26+
2027
file { '/etc/systemd/system/kubelet.service.d':
2128
ensure => 'directory',
2229
}

spec/classes/profile/kubelet_spec.rb

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,15 @@
105105

106106
it do
107107
is_expected.to contain_file("/etc/systemd/system/kubelet.service.d/20-containerd-and-manifest-dir.conf")
108-
.with_content(/^ExecStart=\/usr\/bin\/kubelet/)
108+
.with_content(/^ExecStart=\/usr\/bin\/kubelet --config=\/etc\/kubernetes\/kubelet\.yaml$/)
109109
end
110110

111-
["--address=127.0.0.1",
112-
"--pod-manifest-path=/etc/kubernetes/manifests",
113-
"--container-runtime=remote",
114-
"--container-runtime-endpoint=unix:///run/containerd/containerd.sock",
115-
"--cgroup-driver=systemd"].each do |param|
116-
it do
117-
is_expected.to contain_file("/etc/systemd/system/kubelet.service.d/20-containerd-and-manifest-dir.conf")
118-
.with_content(/^ExecStart=.+ #{param}/)
119-
end
111+
it do
112+
is_expected.to contain_file("/etc/kubernetes/kubelet.yaml")
113+
.with_content(/address:.*127.0.0.1/)
114+
.with_content(/staticPodPath:.*\/etc\/kubernetes\/manifests/)
115+
.with_content(/cgroupDriver:.*systemd/)
116+
.with_content(/containerRuntimeEndpoint:.*unix:\/\/\/run\/containerd\/containerd.sock/)
120117
end
121118

122119
context "with pod_manifest_path set to /tmp/kubelet" do
@@ -126,8 +123,8 @@
126123
it { is_expected.to contain_file("/tmp/kubelet") }
127124

128125
it do
129-
is_expected.to contain_file("/etc/systemd/system/kubelet.service.d/20-containerd-and-manifest-dir.conf")
130-
.with_content(/^ExecStart=.+ --pod-manifest-path=\/tmp\/kubelet/)
126+
is_expected.to contain_file("/etc/kubernetes/kubelet.yaml")
127+
.with_content(/staticPodPath:.*\/tmp\/kubelet/)
131128
end
132129
end
133130

spec/classes/profile/kubernetes/bootstrap/etcd_config_spec.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@
1515

1616
it do
1717
is_expected.to contain_file('/etc/systemd/system/kubelet.service.d/20-etcd-service-manager.conf')
18-
.with_content(%r{^ExecStart=/usr/bin/kubelet --address=127.0.0.1 --pod-manifest-path=/etc/kubernetes/manifests --cgroup-driver=systemd --container-runtime=remote --container-runtime-endpoint=unix:///run/containerd/containerd.sock$})
18+
.with_content(%r{^ExecStart=/usr/bin/kubelet --config=/etc/kubernetes/kubelet\.yaml$})
1919
.that_notifies('Exec[kubelet reload daemon]')
2020
.that_requires('Package[kubelet]')
2121
.that_requires('File[/etc/systemd/system/kubelet.service.d]')
2222
end
2323

24+
it do
25+
is_expected.to contain_file("/etc/kubernetes/kubelet.yaml")
26+
.with_content(/address:.*127.0.0.1/)
27+
.with_content(/staticPodPath:.*\/etc\/kubernetes\/manifests/)
28+
.with_content(/cgroupDriver:.*systemd/)
29+
.with_content(/containerRuntimeEndpoint:.*unix:\/\/\/run\/containerd\/containerd.sock/)
30+
end
31+
2432
it { is_expected.to contain_file('/etc/systemd/system/kubelet.service.d').with_ensure('directory') }
2533

2634
it do
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: "kubelet.config.k8s.io/v1beta1"
2+
kind: "KubeletConfiguration"
3+
address: "127.0.0.1"
4+
staticPodPath: "<%= @pod_manifest_path %>"
5+
cgroupDriver: "systemd"
6+
containerRuntimeEndpoint: "unix:///run/containerd/containerd.sock"
7+
authentication:
8+
anonymous:
9+
enabled: true
10+
webhook:
11+
enabled: false
12+
authorization:
13+
mode: "AlwaysAllow"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Managed by puppet (nebula/profile/kubelet/systemd.conf.erb)
22
[Service]
33
ExecStart=
4-
ExecStart=/usr/bin/kubelet --address=127.0.0.1 --pod-manifest-path=<%= @pod_manifest_path %> --cgroup-driver=systemd --container-runtime=remote --container-runtime-endpoint=unix:///run/containerd/containerd.sock
4+
ExecStart=/usr/bin/kubelet --config=/etc/kubernetes/kubelet.yaml
55
Restart=always
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Managed by puppet (nebula/profile/kubernetes/bootstrap/etcd/systemd.conf.erb)
22
[Service]
33
ExecStart=
4-
ExecStart=/usr/bin/kubelet --address=127.0.0.1 --pod-manifest-path=/etc/kubernetes/manifests --cgroup-driver=systemd --container-runtime=remote --container-runtime-endpoint=unix:///run/containerd/containerd.sock
4+
ExecStart=/usr/bin/kubelet --config=/etc/kubernetes/kubelet.yaml
55
Restart=always

0 commit comments

Comments
 (0)