Skip to content

Commit c57724e

Browse files
davejrtscotty-c
authored andcommitted
fixes issue with cgroup mismatch on rhel and ignore flags for containerd runtime (#109)
* testing file resource * Revert "testing file resource" This reverts commit 7d5ab84. * fixing up issues with RHEL and containerd * linting and fixing spec test
1 parent c84346d commit c57724e

File tree

3 files changed

+40
-15
lines changed

3 files changed

+40
-15
lines changed

manifests/cluster_roles.pp

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,41 @@
1818
String $cni_pod_cidr = $kubernetes::cni_pod_cidr,
1919
String $token = $kubernetes::token,
2020
String $discovery_token_hash = $kubernetes::discovery_token_hash,
21+
String $container_runtime = $kubernetes::container_runtime,
2122

2223
){
2324
$path = ['/usr/bin','/bin','/sbin','/usr/local/bin']
2425
$env = ['HOME=/root', 'KUBECONFIG=/etc/kubernetes/admin.conf']
2526

27+
if $container_runtime == 'cri_containerd' {
28+
$preflight_errors = ['Service-Docker']
29+
$cri_socket = '/run/containerd/containerd.sock'
30+
} else {
31+
$preflight_errors = undef
32+
$cri_socket = undef
33+
}
34+
35+
2636
if $controller {
2737
kubernetes::kubeadm_init { $node_label:
28-
config => '/etc/kubernetes/config.yaml',
29-
path => $path,
30-
env => $env,
31-
node_label => $node_label,
38+
config => '/etc/kubernetes/config.yaml',
39+
path => $path,
40+
env => $env,
41+
node_label => $node_label,
42+
ignore_preflight_errors => $preflight_errors,
3243
}
3344
}
3445

3546
if $worker {
3647
kubernetes::kubeadm_join { $node_label:
37-
path => $path,
38-
env => $env,
39-
controller_address => $controller_address,
40-
token => $token,
41-
ca_cert_hash => $discovery_token_hash,
42-
cri_socket => '/run/containerd/containerd.sock',
43-
node_label => $node_label,
48+
path => $path,
49+
env => $env,
50+
controller_address => $controller_address,
51+
token => $token,
52+
ca_cert_hash => $discovery_token_hash,
53+
cri_socket => $cri_socket,
54+
node_label => $node_label,
55+
ignore_preflight_errors => $preflight_errors,
4456
}
4557
}
4658
}

manifests/packages.pp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,22 @@
3737

3838
if $container_runtime == 'docker' {
3939
case $::osfamily {
40-
'Debian','RedHat' : {
40+
'Debian': {
4141
package { 'docker-engine':
4242
ensure => $docker_version,
4343
}
4444
}
45-
45+
'RedHat': {
46+
package { 'docker-engine':
47+
ensure => $docker_version,
48+
}
49+
file_line { 'set systemd cgroup docker':
50+
path => '/usr/lib/systemd/system/docker.service',
51+
line => 'ExecStart=/usr/bin/dockerd --exec-opt native.cgroupdriver=systemd',
52+
match => 'ExecStart',
53+
require => Package['docker-engine'],
54+
}
55+
}
4656
default: { notify {"The OS family ${::osfamily} is not supported by this module":} }
4757
}
4858
}

spec/classes/cluster_roles_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
'token' => 'foo',
3434
'etcd_initial_cluster' => 'foo',
3535
'controller_address' => '172.17.10.101',
36-
'node_label' => 'foo',
36+
'node_label' => 'foo',
37+
'container_runtime' => 'docker',
3738
}
3839
end
3940

@@ -58,7 +59,9 @@
5859
'token' => 'foo',
5960
'etcd_initial_cluster' => 'foo',
6061
'controller_address' => '172.17.10.101',
61-
'node_label' => 'foo',
62+
'node_label' => 'foo',
63+
'container_runtime' => 'docker',
64+
6265
}
6366
end
6467

0 commit comments

Comments
 (0)