Skip to content

Commit

Permalink
Additional rules for podman root containers
Browse files Browse the repository at this point in the history
This class defines additional forwarding rules to let root containers
reach external networks when using Netavark (since v4.0) or CNI (deprecated).
At the time of writing, Podman supports automatic configuration
of firewall rules with iptables and firewalld only.
  • Loading branch information
traylenator committed Nov 22, 2023
1 parent 3413220 commit 08b9f1d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
13 changes: 13 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ and Manager Daemons (MGR).
* [`nftables::rules::out::tor`](#nftables--rules--out--tor): manage out tor
* [`nftables::rules::out::whois`](#nftables--rules--out--whois): allow clients to query remote whois server
* [`nftables::rules::out::wireguard`](#nftables--rules--out--wireguard): manage out wireguard
* [`nftables::rules::podman`](#nftables--rules--podman): Rules for Podman, a tool for managing OCI containers and pods.
This class defines additional forwarding rules to let root containers
reach external networks when using Netavark (since v4.0) or CNI (deprecated).
At the time of writing, Podman supports automatic configuration
of firewall rules with iptables and firewalld only.
* [`nftables::rules::puppet`](#nftables--rules--puppet): manage in puppet
* [`nftables::rules::pxp_agent`](#nftables--rules--pxp_agent): manage in pxp-agent
* [`nftables::rules::qemu`](#nftables--rules--qemu): Bridged network configuration for qemu/libvirt
Expand Down Expand Up @@ -1190,6 +1195,14 @@ specify wireguard ports

Default value: `[51820]`

### <a name="nftables--rules--podman"></a>`nftables::rules::podman`

Rules for Podman, a tool for managing OCI containers and pods.
This class defines additional forwarding rules to let root containers
reach external networks when using Netavark (since v4.0) or CNI (deprecated).
At the time of writing, Podman supports automatic configuration
of firewall rules with iptables and firewalld only.

### <a name="nftables--rules--puppet"></a>`nftables::rules::puppet`

manage in puppet
Expand Down
17 changes: 17 additions & 0 deletions manifests/rules/podman.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# @summary
# Rules for Podman, a tool for managing OCI containers and pods.
# This class defines additional forwarding rules to let root containers
# reach external networks when using Netavark (since v4.0) or CNI (deprecated).
# At the time of writing, Podman supports automatic configuration
# of firewall rules with iptables and firewalld only.
#
class nftables::rules::podman {
nftables::rule {
'default_fwd-podman_establised':
content => 'ip daddr 10.88.0.0/16 ct state related,established accept',
}
nftables::rule {
'default_fwd-podman_accept':
content => 'ip saddr 10.88.0.0/16 accept',
}
}
1 change: 1 addition & 0 deletions spec/acceptance/all_rules_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class { 'nftables':
include nftables::rules::dhcpv6_client
include nftables::rules::afs3_callback
include nftables::rules::ospf
include nftables::rules::podman
include nftables::rules::http
include nftables::rules::puppet
include nftables::rules::pxp_agent
Expand Down
17 changes: 17 additions & 0 deletions spec/classes/rules/podman_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'nftables::rules::podman' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }

context 'default options' do
it { is_expected.to compile }
it { is_expected.to contain_nftables__rule('default_fwd-podman_establised').with_content('ip daddr 10.88.0.0/16 ct state related,established accept') }
it { is_expected.to contain_nftables__rule('default_fwd-podman_accept').with_content('ip saddr 10.88.0.0/16 accept') }
end
end
end
end

0 comments on commit 08b9f1d

Please sign in to comment.