Skip to main content

VPN gateway charm library for Kubernetes

Project description

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

Project details


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.2.2.tar.gz (14.2 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.2.2-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: charmarr_lib_vpn-0.2.2.tar.gz
  • Upload date:
  • Size: 14.2 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.2.2.tar.gz
Algorithm Hash digest
SHA256 a149022ecb7e9b9a139ce6f4e1830e520859a05fe296bab9059065ab1d6a95f9
MD5 0aeae79bdd9708a3ec6ff2d410f76d75
BLAKE2b-256 17fc7aadaa8f497bf465df7953a5025f3d426c6bf95d30e2bb3bb6e3223ae9ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for charmarr_lib_vpn-0.2.2.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.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for charmarr_lib_vpn-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 cbdeb12256393f2d4995889edbefa714ff3592b6b23fc04ba10fafc9a14e3138
MD5 333e45b3f3d116b2ef31d4f25f7fdc99
BLAKE2b-256 c29f2e08bf518a7a707f22d7197772993e25c5fa8c9eed615b1774dcdcfe9970

See more details on using hashes here.

Provenance

The following attestation bundles were made for charmarr_lib_vpn-0.2.2-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.

Supported by

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