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.3.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.3.0-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: charmarr_lib_vpn-0.3.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.3.0.tar.gz
Algorithm Hash digest
SHA256 4c62ee950d107588ae82eab43358f9f8254c1507198b3c51b34a137049a856f1
MD5 578d0391e7bf0bb10d698a988a52bd96
BLAKE2b-256 b2b504585968b4f64f1005914de869b8fb51117b7d4a9b4c19c49500b49076a8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for charmarr_lib_vpn-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f6dc888d2dad5430f3e0372d988feb0ed58617fe5832fe9671a0496005a7d95b
MD5 81c2c263459653b2bb0c85519e38a411
BLAKE2b-256 2699a336dd71aa226610ea82029cb04246e617ce5f0b4ff282296501855890fe

See more details on using hashes here.

Provenance

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

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