Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting metricsBindAddress #377

Merged
merged 2 commits into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions manifests/config/kubeadm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
String $image_repository = $kubernetes::image_repository,
String $cgroup_driver = $kubernetes::cgroup_driver,
String $proxy_mode = $kubernetes::proxy_mode,
Stdlib::IP::Address $metrics_bind_address = $kubernetes::metrics_bind_address,
) {

if !($proxy_mode in ['', 'userspace', 'iptables', 'ipvs', 'kernelspace']) {
Expand Down
5 changes: 5 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@
# Availability of the token
# Default to 24h
#
# [*metrics_bind_address*]
# Set the metricsBindAddress (to allow prometheus)
# Default to 127.0.0.1
#
# Authors
# -------
#
Expand Down Expand Up @@ -496,6 +500,7 @@
default => ['HOME=/root', 'KUBECONFIG=/etc/kubernetes/kubelet.conf'],
},
Optional[Array] $ignore_preflight_errors = undef,
Stdlib::IP::Address $metrics_bind_address = '127.0.0.1',
){
if ! $facts['os']['family'] in ['Debian','RedHat'] {
notify {"The OS family ${facts['os']['family']} is not supported by this module":}
Expand Down
43 changes: 43 additions & 0 deletions spec/classes/config/kubeadm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,47 @@
expect(config_yaml[2]['mode']).to include('ipvs')
end
end

context 'with metrics_bind_address = 0.0.0.0 with version 1.14.2' do
let(:params) do
{
'kubernetes_version' => '1.14.2',
'metrics_bind_address' => '0.0.0.0',
}
end

let(:config_yaml) { YAML.load_stream(catalogue.resource('file', '/etc/kubernetes/config.yaml').send(:parameters)[:content]) }

it { is_expected.to contain_file('/etc/kubernetes/config.yaml') }
it 'has 0.0.0.0 in metrics_bind_address:' do
expect(config_yaml[2]['metricsBindAddress']).to include('0.0.0.0')
end
end

context 'with metrics_bind_address = 0.0.0.0 with version 1.16.3' do
let(:params) do
{
'kubernetes_version' => '1.16.3',
'metrics_bind_address' => '0.0.0.0',
}
end

let(:config_yaml) { YAML.load_stream(catalogue.resource('file', '/etc/kubernetes/config.yaml').send(:parameters)[:content]) }

it { is_expected.to contain_file('/etc/kubernetes/config.yaml') }
it 'has 0.0.0.0 in metrics_bind_address:' do
expect(config_yaml[2]['metricsBindAddress']).to include('0.0.0.0')
end
end

context 'with metrics_bind_address = invalid' do
let(:params) do
{
'kubernetes_version' => '1.14.2',
'metrics_bind_address' => 'invalid',
}
end

it { is_expected.to compile.and_raise_error(%r{metrics_bind_address}) }
end
end
2 changes: 1 addition & 1 deletion templates/v1beta1/config_kubeadm.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ ipvs:
scheduler: ""
syncPeriod: 30s
kind: KubeProxyConfiguration
metricsBindAddress: 127.0.0.1:10249
metricsBindAddress: <%= @metrics_bind_address %>:10249
mode: "<%= @proxy_mode %>"
nodePortAddresses: null
oomScoreAdj: -999
Expand Down
2 changes: 1 addition & 1 deletion templates/v1beta2/config_kubeadm.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ ipvs:
scheduler: ""
syncPeriod: 30s
kind: KubeProxyConfiguration
metricsBindAddress: 127.0.0.1:10249
metricsBindAddress: <%= @metrics_bind_address %>:10249
mode: "<%= @proxy_mode %>"
nodePortAddresses: null
oomScoreAdj: -999
Expand Down