Skip to content

Commit

Permalink
Stop fighting calico and fix firewall resources
Browse files Browse the repository at this point in the history
The newer firewall can get into a weird state when port ranges are
defined with hyphens, because in iptables they are defined with colons,
so puppet agent will view this as a corrective change.

This is not necessarily a problem, but when the host's networking is
sufficiently chaotic, this attempt at a corrective change can cause the
puppet server to lose the resource in favor of `nil` and crash.

Calico is sufficiently chaotic, and this commit also aims to stop
purging half of calico's firewall on every puppet agent run.
  • Loading branch information
daaang committed Nov 8, 2024
1 parent 10d722f commit 69de977
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion manifests/profile/kubernetes/kubelet.pp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
;

'200 Cluster NodePorts':
dport => '30000-32767',
dport => '30000:32767',
;

'200 Cluster Prometheus':
Expand Down
2 changes: 1 addition & 1 deletion manifests/profile/networking/firewall.pp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
firewallchain {
default:
ensure => 'present',
purge => true,
purge => $internal_routing != 'kubernetes_calico',
policy => 'accept',
;

Expand Down
2 changes: 1 addition & 1 deletion spec/classes/profile/kubernetes/kubelet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
[%w[2379 2380 2381], 'etcd', 'tcp'],
[10250, 'kubelet', 'tcp'],
[6443, 'kubernetes API', 'tcp'],
%w[30000-32767 NodePorts tcp],
%w[30000:32767 NodePorts tcp],
[9100, 'Prometheus', 'tcp'],
].each do |ports, purpose, proto|
it do
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/profile/networking/firewall_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@
it do
expect(subject).to contain_firewallchain("#{chain}:filter:IPv4")
.with_ensure('present')
.with_purge(true)
.with_purge(false)
end

it do
expect(subject).to contain_firewallchain("#{chain}:filter:IPv6")
.with_ensure('present')
.with_purge(true)
.with_purge(false)
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/classes/role/kubernetes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@

it { is_expected.to contain_class('Nebula::Profile::Ntp') }

it { is_expected.not_to contain_resources('firewall').with_purge(true) }
it { is_expected.not_to contain_resources('firewall').with_purge(false) }

it do
expect(subject).to contain_firewallchain('INPUT:filter:IPv4').with(
ensure: 'present',
purge: true,
purge: false,
ignore: ['-j cali-INPUT',
'-j KUBE-FIREWALL',
'-j KUBE-SERVICES',
Expand All @@ -69,7 +69,7 @@
it do
expect(subject).to contain_firewallchain('OUTPUT:filter:IPv4').with(
ensure: 'present',
purge: true,
purge: false,
ignore: ['-j cali-OUTPUT',
'-j KUBE-FIREWALL',
'-j KUBE-SERVICES'],
Expand All @@ -79,7 +79,7 @@
it do
expect(subject).to contain_firewallchain('FORWARD:filter:IPv4').with(
ensure: 'present',
purge: true,
purge: false,
ignore: ['-j cali-FORWARD',
'-j KUBE-FORWARD',
'-j KUBE-SERVICES'],
Expand Down
6 changes: 3 additions & 3 deletions spec/defines/exposed_port_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@
let(:title) { '400 Who knows' }
let(:params) { { block: 'developers' } }

context 'with port "30000-32967"' do
context 'with port "30000:32967"' do
let(:params) do
super().merge(port: '30000-32967')
super().merge(port: '30000:32967')
end

it do
expect(subject).to contain_firewall('400 Who knows: Developers')
.with_dport('30000-32967')
.with_dport('30000:32967')
end
end

Expand Down

0 comments on commit 69de977

Please sign in to comment.