6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Version 3.2.2

Fixes bug where nodes in v1.10/11 could not join the cluster

A full list of PR's and issues closed can be found here [here](https://github.com/puppetlabs/puppetlabs-kubernetes/milestone/6)

# Version 3.2.1

Fixes world readable PKI keys in /etc/kubernetes/config.yaml
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,17 @@ The download URL for the etcd archive.

Defaults to `https://github.com/coreos/etcd/releases/download/v${etcd_version}/${etcd_archive}`.

#### `etcd_install_method`
The method on how to install etcd. Can be either `wget` (using etcd_source) or `package` (using $etcd_package_name)

Defaults to `wget`.

#### `etcd_package_name`

The system package name for installing etcd

Defaults to `etcd-server`.

#### `etcd_ip`

Specifies the IP address etcd uses for communications.
Expand Down
14 changes: 11 additions & 3 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
class kubernetes::config (
String $config_file = $kubernetes::config_file,
Boolean $manage_etcd = $kubernetes::manage_etcd,
String $etcd_install_method = $kubernetes::etcd_install_method,
String $kubernetes_version = $kubernetes::kubernetes_version,
String $etcd_ca_key = $kubernetes::etcd_ca_key,
String $etcd_ca_crt = $kubernetes::etcd_ca_crt,
Expand Down Expand Up @@ -57,9 +58,16 @@
mode => '0600',
}
}
file { '/etc/systemd/system/etcd.service':
ensure => present,
content => template('kubernetes/etcd/etcd.service.erb'),
if $etcd_install_method == 'wget' {
file { '/etc/systemd/system/etcd.service':
ensure => present,
content => template('kubernetes/etcd/etcd.service.erb'),
}
} else {
file { '/etc/default/etcd':
ensure => present,
content => template('kubernetes/etcd/etcd.erb'),
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@
# The URL to download the etcd archive
# Defaults to https://github.com/coreos/etcd/releases/download/v${etcd_version}/${etcd_archive}
#
# [*etcd_install_method*]
# The method on how to install etcd. Can be either wget (using etcd_source) or package (using $etcd_package_name)
# Defaults to wget
#
# [*etcd_package_name*]
# The system package name for installing etcd
# Defaults to etcd-server
#
# [*runc_version*]
# The version of runc to install
# Defaults to 1.0.0-rc5
Expand Down Expand Up @@ -373,7 +381,9 @@
Optional[String] $containerd_source =
"https://github.com/containerd/containerd/releases/download/v${containerd_version}/${containerd_archive}",
String $etcd_archive = "etcd-v${etcd_version}-linux-amd64.tar.gz",
String $etcd_package_name = 'etcd-server',
String $etcd_source = "https://github.com/coreos/etcd/releases/download/v${etcd_version}/${etcd_archive}",
String $etcd_install_method = 'wget',
Optional[String] $kubernetes_apt_location = undef,
Optional[String] $kubernetes_apt_release = undef,
Optional[String] $kubernetes_apt_repos = undef,
Expand Down
1 change: 0 additions & 1 deletion manifests/kubeadm_join.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
/^1.1(0|1)/: {
$kubeadm_join_flags = kubeadm_join_flags({
controller_address => $controller_address,
config => $config,
cri_socket => $cri_socket,
discovery_file => $discovery_file,
discovery_token => $discovery_token,
Expand Down
25 changes: 17 additions & 8 deletions manifests/packages.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
Optional[String] $containerd_archive = $kubernetes::containerd_archive,
Optional[String] $containerd_source = $kubernetes::containerd_source,
String $etcd_archive = $kubernetes::etcd_archive,
String $etcd_version = $kubernetes::etcd_version,
String $etcd_source = $kubernetes::etcd_source,
String $etcd_package_name = $kubernetes::etcd_package_name,
String $etcd_install_method = $kubernetes::etcd_install_method,
Optional[String] $runc_source = $kubernetes::runc_source,
Boolean $disable_swap = $kubernetes::disable_swap,
Boolean $manage_kernel_modules = $kubernetes::manage_kernel_modules,
Expand Down Expand Up @@ -105,14 +108,20 @@
}

if $controller and $manage_etcd {
archive { $etcd_archive:
path => "/${etcd_archive}",
source => $etcd_source,
extract => true,
extract_command => 'tar xfz %s --strip-components=1 -C /usr/local/bin/',
extract_path => '/usr/local/bin',
cleanup => true,
creates => ['/usr/local/bin/etcd','/usr/local/bin/etcdctl']
if $etcd_install_method == 'wget' {
archive { $etcd_archive:
path => "/${etcd_archive}",
source => $etcd_source,
extract => true,
extract_command => 'tar xfz %s --strip-components=1 -C /usr/local/bin/',
extract_path => '/usr/local/bin',
cleanup => true,
creates => ['/usr/local/bin/etcd','/usr/local/bin/etcdctl']
}
} else {
package { $etcd_package_name:
ensure => $etcd_version,
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@

if $controller and $manage_etcd {
service { 'etcd':
ensure => running,
enable => true,
require => File['/etc/systemd/system/etcd.service']
ensure => running,
enable => true,
}
File <| path == '/etc/systemd/system/kubelet.service.d' or path == '/etc/default/etcd' |> ~> Service['etcd']
}

# RedHat needs to have CPU and Memory accounting enabled to avoid systemd proc errors
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-kubernetes",
"version": "3.2.1",
"version": "3.2.2",
"author": "Puppet",
"summary": "The module installs and configures a Kubernetes cluster",
"license": "Apache-2.0",
Expand Down
16 changes: 16 additions & 0 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@


it { should contain_file('/etc/systemd/system/etcd.service') }
it { should_not contain_file('/etc/default/etcd') }
it { should contain_file('/etc/kubernetes/config.yaml') }
it { should contain_file('/etc/kubernetes/config.yaml').with_content(/foo:\n- bar\n- baz/) }
it { should contain_file('/etc/kubernetes/config.yaml').with_content(/kubeletConfiguration:\n baseConfig:\n baz:\n - bar\n - foo/) }
Expand Down Expand Up @@ -86,11 +87,26 @@


it { should_not contain_file('/etc/systemd/system/etcd.service') }
it { should_not contain_file('/etc/default/etcd') }
it { should contain_file('/etc/kubernetes/config.yaml') }
it { should contain_file('/etc/kubernetes/config.yaml').with_content(/foo:\n- bar\n- baz/) }
it { should contain_file('/etc/kubernetes/config.yaml').with_content(/kubeletConfiguration:\n baseConfig:\n baz:\n - bar\n - foo/) }
end

context 'manage_etcd => true and etcd_install_method => package' do
let(:params) do
{
'etcd_install_method' => 'package',
'kubeadm_extra_config' => {'foo' => ['bar', 'baz']},
'kubelet_extra_config' => {'baz' => ['bar', 'foo']},
'kubelet_extra_arguments' => ['foo'],
'manage_etcd' => true,
}
end
it { should_not contain_file('/etc/systemd/system/etcd.service') }
it { should contain_file('/etc/default/etcd') }
end

context 'with version = 1.12 and cloud_provider => aws and cloud_config => undef' do
let(:params) do
{
Expand Down
1 change: 1 addition & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
end

context 'with controller => true' do

let(:params) do {
:controller => true,
} end
Expand Down
59 changes: 59 additions & 0 deletions spec/classes/packages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
'manage_etcd' => true,
'manage_kernel_modules' => true,
'manage_sysctl_settings' => true,
'etcd_install_method' => 'wget',
'etcd_package_name' => 'etcd-server',
'etcd_version' => '3.1.12',
}
end
it { should contain_kmod__load('br_netfilter')}
Expand All @@ -43,6 +46,53 @@
it { should contain_package('kubeadm').with_ensure('1.10.2')}
end

context 'with osfamily => RedHat and container_runtime => Docker and manage_docker => true and manage_etcd => true and etcd_install_method => package' do
let(:facts) do
{
:osfamily => 'RedHat', #needed to run dependent tests from fixtures camptocamp-kmod
:kernel => 'Linux',
:os => {
:family => "RedHat",
:name => 'RedHat',
:release => {
:full => '7.4',
},
},
}
end
let(:params) do
{
'container_runtime' => 'docker',
'kubernetes_package_version' => '1.10.2',
'docker_version' => '17.03.1.ce-1.el7.centos',
'containerd_archive' =>'containerd-1.1.0.linux-amd64.tar.gz',
'containerd_source' => 'https://github.com/containerd-1.1.0.linux-amd64.tar.gz',
'etcd_archive' => 'etcd-v3.1.12-linux-amd64.tar.gz',
'etcd_source' => 'https://github.com/etcd-v3.1.12.tar.gz',
'runc_source' => 'https://github.com/runcsource',
'controller' => true,
'docker_package_name' => 'docker-engine',
'disable_swap' => true,
'manage_docker' => true,
'manage_etcd' => true,
'manage_kernel_modules' => true,
'manage_sysctl_settings' => true,
'etcd_install_method' => 'package',
'etcd_package_name' => 'etcd-server',
'etcd_version' => '3.1.12',
}
end
it { should contain_kmod__load('br_netfilter')}
it { should contain_sysctl('net.bridge.bridge-nf-call-iptables').with_ensure('present').with_value('1')}
it { should contain_sysctl('net.ipv4.ip_forward').with_ensure('present').with_value('1')}
it { should contain_package('docker-engine').with_ensure('17.03.1.ce-1.el7.centos')}
it { should_not contain_archive('etcd-v3.1.12-linux-amd64.tar.gz')}
it { should contain_package('etcd-server').with_ensure('3.1.12')}
it { should contain_package('kubelet').with_ensure('1.10.2')}
it { should contain_package('kubectl').with_ensure('1.10.2')}
it { should contain_package('kubeadm').with_ensure('1.10.2')}
end

context 'with osfamily => Debian and container_runtime => cri_containerd and manage_etcd => false' do
let(:facts) do
{
Expand Down Expand Up @@ -77,6 +127,9 @@
'manage_etcd' => false,
'manage_kernel_modules' => true,
'manage_sysctl_settings' => true,
'etcd_install_method' => 'wget',
'etcd_package_name' => 'etcd-server',
'etcd_version' => '3.1.12',
}
end
it { should contain_kmod__load('br_netfilter')}
Expand Down Expand Up @@ -126,6 +179,9 @@
'manage_etcd' => true,
'manage_kernel_modules' => true,
'manage_sysctl_settings' => true,
'etcd_install_method' => 'wget',
'etcd_package_name' => 'etcd-server',
'etcd_version' => '3.1.12',
}
end
it { should contain_kmod__load('br_netfilter')}
Expand Down Expand Up @@ -172,6 +228,9 @@
'manage_etcd' => true,
'manage_kernel_modules' => true,
'manage_sysctl_settings' => true,
'etcd_install_method' => 'wget',
'etcd_package_name' => 'etcd-server',
'etcd_version' => '3.1.12',
}
end
it { should contain_kmod__load('br_netfilter')}
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/kubeadm_join_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_exec('kubeadm join').with_command("kubeadm join '10.0.0.1:6443' --config '/etc/kubernetes/config.yaml' --discovery-token 'token' --discovery-token-ca-cert-hash 'sha256:hash' --node-name 'kube-node' --token 'token'")}
it { is_expected.to contain_exec('kubeadm join').with_command("kubeadm join '10.0.0.1:6443' --discovery-token 'token' --discovery-token-ca-cert-hash 'sha256:hash' --node-name 'kube-node' --token 'token'")}
end

context 'with kubernetes_version => 1.12.3 and controller_address => 10.0.0.1:6443' do
Expand Down
17 changes: 17 additions & 0 deletions templates/etcd/etcd.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ETCD_NAME="<%= @hostname %>"
ETCD_DATA_DIR="/var/lib/etcd"
ETCD_LISTEN_PEER_URLS="https://<%= @etcd_ip %>:2380"
ETCD_LISTEN_CLIENT_URLS="https://<%= @etcd_ip %>:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="https://<%= @etcd_ip %>:2380"
ETCD_INITIAL_CLUSTER="<%= @etcd_initial_cluster %>"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="my-etcd-token"
ETCD_ADVERTISE_CLIENT_URLS="https://<%= @etcd_ip %>:2379"
ETCD_CERT_FILE="/etc/kubernetes/pki/etcd/server.crt"
ETCD_KEY_FILE="/etc/kubernetes/pki/etcd/server.key"
ETCD_CLIENT_CERT_AUTH=1
ETCD_TRUSTED_CA_FILE="/etc/kubernetes/pki/etcd/ca.crt"
ETCD_PEER_CERT_FILE="/etc/kubernetes/pki/etcd/peer.crt"
ETCD_PEER_KEY_FILE="/etc/kubernetes/pki/etcd/peer.key"
ETCD_PEER_CLIENT_CERT_AUTH=1
ETCD_PEER_TRUSTED_CA_FILE="/etc/kubernetes/pki/etcd/ca.crt"