Skip to main content

Charmarr Lib

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,
)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

charmarr_lib_vpn-0.5.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

charmarr_lib_vpn-0.5.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file charmarr_lib_vpn-0.5.0.tar.gz.

File metadata

  • Download URL: charmarr_lib_vpn-0.5.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for charmarr_lib_vpn-0.5.0.tar.gz
Algorithm Hash digest
SHA256 237e8da865716cf94ea5802e6bd4de434784da3965b8239ceb6ee8ce7cfbab74
MD5 743f5cfb0668cfbd33c82246fbfad64a
BLAKE2b-256 a65c0e9b2e182ae91ddfb40dd0bbb1cc59d04227486e7a199e8fdbac6f88ec3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for charmarr_lib_vpn-0.5.0.tar.gz:

Publisher: release.yml on charmarr/charmarr-lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file charmarr_lib_vpn-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for charmarr_lib_vpn-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5725582a86fa4a3b269d482756dd821f1ef4d5bb908e972f4b3758798181f5b2
MD5 627b939df08efb947708e8602def3231
BLAKE2b-256 493289756e5c9666a91ae195f0e53028b45744d3fe0fd102224afb148d3c820c

See more details on using hashes here.

Provenance

The following attestation bundles were made for charmarr_lib_vpn-0.5.0-py3-none-any.whl:

Publisher: release.yml on charmarr/charmarr-lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 files

0.4.0

2 files

0.3.0

2 files

0.2.2

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page