Skip to main content

charmarr-lib-vpn

VPN gateway charm library for Kubernetes.

Features

  • VPN gateway Juju relation interface
  • StatefulSet patching utilities for pod-gateway integration
  • NetworkPolicy kill switch implementation
  • Reusable beyond Charmarr ecosystem

Installation

pip install charmarr-lib-vpn

Usage

Interfaces

from charmarr_lib.vpn.interfaces import (
    VPNGatewayProvider,
    VPNGatewayRequirer,
    VPNGatewayProviderData,
    VPNGatewayRequirerData,
    VPNGatewayChangedEvent,
)

Gateway Patching (VPN gateway side - gluetun)

from charmarr_lib.vpn import (
    reconcile_gateway,
    build_gateway_patch,
    is_gateway_patched,
)
from charmarr_lib.krm import K8sResourceManager

manager = K8sResourceManager()
provider_data = VPNGatewayProviderData(
    vxlan_id=42,
    vxlan_ip_network="172.16.0.0/24",
    cluster_cidrs="10.1.0.0/16,10.152.183.0/24",
)

# Idempotent reconciliation
result = reconcile_gateway(
    manager=manager,
    statefulset_name="gluetun",
    namespace="vpn-gateway",
    data=provider_data,
    pod_cidr="10.1.0.0/16",
)

Client Patching (Download client side - qBittorrent)

from charmarr_lib.vpn import (
    reconcile_gateway_client,
    build_gateway_client_patch,
    build_gateway_client_configmap_data,
    is_gateway_client_patched,
)

# Create client-side VPN routing
result = reconcile_gateway_client(
    manager=manager,
    statefulset_name="qbittorrent",
    namespace="download-clients",
    data=requirer_data,
    configmap_name="qbittorrent-vpn-config",
)

Kill Switch (NetworkPolicy)

from charmarr_lib.vpn import (
    KillSwitchConfig,
    reconcile_kill_switch,
)

# Create NetworkPolicy that blocks non-VPN egress
config = KillSwitchConfig(
    app_name="qbittorrent",
    namespace="download-clients",
    cluster_cidrs=["10.1.0.0/16", "10.152.183.0/24"],
    dns_namespace="kube-system",
)
reconcile_kill_switch(manager, "qbittorrent", "download-clients", config)

# Remove kill switch on relation-broken
reconcile_kill_switch(manager, "qbittorrent", "download-clients", None)

Constants

from charmarr_lib.vpn import (
    POD_GATEWAY_IMAGE,
    DEFAULT_VXLAN_ID,
    DEFAULT_VXLAN_IP_NETWORK,
    GATEWAY_INIT_CONTAINER_NAME,
    GATEWAY_SIDECAR_CONTAINER_NAME,
    CLIENT_INIT_CONTAINER_NAME,
    CLIENT_SIDECAR_CONTAINER_NAME,
)

Metadata

Release files for charmarr-lib-vpn 0.6.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for charmarr-lib-vpn 0.6.4
File Size Uploaded
charmarr_lib_vpn-0.6.4.tar.gz 19.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for charmarr-lib-vpn 0.6.4
File Interpreter ABI Platform
charmarr_lib_vpn-0.6.4-py3-none-any.whl Python 3 none any Details

Total release size: 35.5 kB

Release files / charmarr_lib_vpn-0.6.4.tar.gz

Download URL charmarr_lib_vpn-0.6.4.tar.gz
Size 19.5 kB
Tags Source
SHA-256 checksum
How to use checksums
792ceaaf72a0b6dc9a5130352a052f6289c2c8646104a3cd97bbc0609147e0e6
BLAKE2b-256 checksum
How to use checksums
4bc4774eb413d682f321d5669d96ffb3f5702c08bee1877216577a70c8333d4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.

Transparency log

Release files / charmarr_lib_vpn-0.6.4-py3-none-any.whl

Download URL charmarr_lib_vpn-0.6.4-py3-none-any.whl
Size 16.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fcc1527f7af8411f8801978188ce451ab4db24a9b44584ac34b9613af5d5bd58
BLAKE2b-256 checksum
How to use checksums
09ef94c570d89b76a231ac70d306a56b409e60496cbcb48c60c8224ddd09c8ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 23, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.6.4 This release

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page