Skip to content
This repository was archived by the owner on Dec 3, 2025. It is now read-only.
Closed
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
4 changes: 4 additions & 0 deletions config/crd/bases/vpn.wireguard-operator.io_wireguards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ spec:
be useful to enable if the peers are having problems with sending
traffic to the internet.
type: boolean
hostNetwork:
description: A boolean field that specifies whether the Wireguard
VPN pod should run in the host network namespace.
type: boolean
metric:
description: WireguardPodSpec defines spec for respective containers
created for Wireguard
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/v1alpha1/wireguard_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ type WireguardSpec struct {
EnableIpForwardOnPodInit bool `json:"enableIpForwardOnPodInit,omitempty"`
// A boolean field that specifies whether to use the userspace implementation of Wireguard instead of the kernel one.
UseWgUserspaceImplementation bool `json:"useWgUserspaceImplementation,omitempty"`
// A boolean field that specifies whether the Wireguard VPN pod should run in the host network namespace.
HostNetwork bool `json:"hostNetwork,omitempty"`

NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Agent WireguardPodSpec `json:"agent,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions pkg/controllers/wireguard_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,11 @@ func (r *WireguardReconciler) deploymentForWireguard(m *v1alpha1.Wireguard) *app
}
}

if m.Spec.HostNetwork {
dep.Spec.Template.Spec.HostNetwork = true
dep.Spec.Template.Spec.DNSPolicy = corev1.DNSClusterFirstWithHostNet
}

ctrl.SetControllerReference(m, dep, r.Scheme)
return dep
}
Loading