Skip to content

Add Kubermatic Virtualization firewall rules how-to - #2282

Open
mihiragrawal wants to merge 1 commit into
kubermatic:mainfrom
mihiragrawal:docs/kubev-firewall-rules
Open

Add Kubermatic Virtualization firewall rules how-to#2282
mihiragrawal wants to merge 1 commit into
kubermatic:mainfrom
mihiragrawal:docs/kubev-firewall-rules

Conversation

@mihiragrawal

Copy link
Copy Markdown
Contributor

What this PR documents:

Adds a "Firewall Rules" how-to for Kubermatic Virtualization, covering the dashboard
workflow for firewall rules: creating, editing and deleting rules from the Firewalls
page, the per-VM firewall switch on the Networking tab, port ranges, and the relaxed
enforcement mode that keeps ICMP (ping) and DHCP working on a firewalled VM. Also
documents the <vm>-default-deny baseline policy and the <vm>-allow-dns companion
policy that accompanies a target's first outbound rule.

This also introduces a tutorials-howtos section for Kubermatic Virtualization,
mirroring the existing KKP layout, and files the new page under it.

Which change does this document:

Documents the dashboard feature added in
kubermatic/kubermatic-virtualization#439 ("Add firewall rule create, edit and per-VM posture"),

How does this affect users:

Firewall rules were previously visible in the dashboard but read-only. Users can now
manage them from the UI. Rules are additive and allow-only, so blocking is expressed by
turning the firewall on and then permitting what you need; and the default relaxed
enforcement mode keeps ping and DHCP alive because Kubernetes NetworkPolicy cannot
express ICMP at all.

Signed-off-by: Mihir Agrawal <mihir@kubermatic.com>
@kubermatic-bot kubermatic-bot added the dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. label Sep 1, 2026
@mihiragrawal mihiragrawal self-assigned this Sep 1, 2026
@kubermatic-bot kubermatic-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 1, 2026
@kubermatic-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign simontheleg for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Waseem826 Waseem826 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some feedback, PTAL

Comment on lines +166 to +169
The YAML editor behaves differently. It submits the exact version you opened, so if the
rule changed underneath you the save is refused with *"This rule changed since you opened
it — reload and reapply your edit"* instead of overwriting. The form carries no such
check, which is why concurrent edits are lost there but rejected here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the other way round. The form PUTs the object it fetched when Edit was clicked, resourceVersion included (routes/firewalls.tsx:176-195), and the update mutation maps a 409 to exactly the message quoted here (hooks/mutations/use-service-mutations.ts:366-368). The YAML dialog has its own conflict text with a "Load latest version" button (components/yaml/resource-yaml-dialog.tsx:81-84). Suggest rewriting so both editors are described as rejecting a stale save, with the quoted string attributed to the form.

Comment on lines +161 to +164
Editing a rule replaces the whole policy. Changes made outside the dashboard to the same
rule, such as extra ports or additional sources, are lost when you save the form. If a rule is
too complex for the form to represent, the dashboard says so and opens the YAML editor
instead of showing you a simplified version it would then destroy.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The form does not silently drop anything. parse-network-policy.ts loads every port row (the 8-row cap only hides the Add button) and refuses a rule with more than one peer, which is what sends it to the YAML editor; labels and annotations are merged from the live object in handleEdit. Suggest dropping the "extra ports or additional sources ... are lost" sentence and keeping the rest of the paragraph, which is accurate.

Comment on lines +195 to +197
* *"Applies to 1 virtual machine."* means the rule will be enforced. The number is a real
count, so a pool rule reports how many machines it selects, for example *"Applies to 4
virtual machines."*

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The match line only renders when the target type is Virtual Machine, and the count is targetableVms.includes(target) ? 1 : 0 (components/forms/firewall-form.tsx:210-215). Pool targets get no match feedback at all, so "Applies to 4 virtual machines" cannot appear. Suggest removing the pool example and saying the line appears for VM targets only.


Turning the firewall on creates a policy named `<vm-name>-vm-default-deny`. The `vm` part
is in the name because a VM and a VM pool can share a name in one namespace, and each type
needs its own system policy. For a pool the name is `<pool-name>-pool-default-deny`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildBaselinePolicy has a single caller, hard-coded to 'VirtualMachine' (components/vm-detail/vm-firewall-section.tsx:54), and there is no firewall section under pool-detail. The -pool-default-deny name exists in the naming scheme but nothing in the dashboard creates it. Suggest saying the switch is VM-only today and pools are closed only by their inbound rules.

Comment on lines +205 to +207
A firewall rule selects VMs by a label that this dashboard applies when it creates a VM.
Nothing back-fills that label, so a VM created another way, whether by `kubectl`, a YAML
manifest, or an import, cannot be targeted by a rule. The API server accepts such a rule and it then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming the label would give the reader a remedy. The selector is fw.kubevirt-manager.io/vm-name=<vm-name> on spec.template.metadata.labels (lib/constants.ts:20, hooks/use-vm-names.ts:41-42), so an imported VM can be made targetable by adding it. Suggest naming the label and where it goes.

Comment on lines +115 to +117
By default, rules are created in a relaxed enforcement mode that keeps **ICMP (ping)
and DHCP working** on a firewalled VM, no matter what the rules say. This is almost
always what you want:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The relaxed mode is the Kube-OVN annotation ovn.kubernetes.io/network_policy_enforcement: lax on the policy, and strict is simply its absence (components/forms/build-network-policy.ts:17-18,115). Since the troubleshooting section sends people to the policy YAML, they have no way to recognise the mode without this. Suggest naming the annotation once and noting the ping/DHCP allowance is a Kube-OVN behaviour.


| Field | What it does |
| --- | --- |
| **Name** | Identifies the rule. Lowercase letters, numbers and hyphens. Cannot be changed later. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Names ending in -default-deny or -allow-dns are rejected on create (components/forms/firewall-form-schema.ts:109-117). Since this page introduces both suffixes it is worth saying they are reserved.

+++
title = "Tutorials & How-tos"
date = 2026-08-26T10:00:00+00:00
weight = 6

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three sibling sections already use weight = 6 (access-control-guide, configuration-guide, references), so where this lands in the sidebar is tie-broken rather than chosen. Suggest picking a free weight.

Step-by-step guides for day-to-day work with Kubermatic Virtualization. Each page walks
through a complete task from the dashboard, rather than describing a single setting in
isolation. For the full list of settings, see the
[Configuration Reference]({{< ref "../configuration-reference" >}}).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The KKP tutorials-howtos/_index.en.md this mirrors ends with a ## Pages heading and {{% children depth=5 %}}, so the section landing page lists its how-tos. Without it this page shows only the intro prose. Suggest adding the same listing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants