MicroWARP: Proxy Cloudflare WARP Ultra-Leggero da 800KB

2026-03-25 · 10 min read · gen:2m 50s · tok:20109
#cloudflare-warp #docker #kubernetes #devops #beginner-tutorial #italiano

Scopri come MicroWARP riduce il footprint di un proxy SOCKS5 a soli 800KB in Docker. Guida completa per deployment in Kubernetes con ottimizzazioni kernel.

Building an Ultra-Lightweight Cloudflare WARP Proxy: Come MicroWARP Raggiunge 800KB di Memory Footprint in Docker

Ogni container che aggiungi al tuo cluster Kubernetes consuma memoria. Un proxy SOCKS5 tradizionale basato su Dante o Squid parte da 50-100MB. Moltiplica per centinaia di pod e stai bruciando gigabyte di RAM solo per il routing del traffico.

MicroWARP cambia completamente questa equazione. Con un footprint di soli 800KB, puoi deployare un proxy Cloudflare WARP completo come sidecar senza impatto significativo sulle risorse. Questo articolo ti mostra esattamente come funziona a livello kernel e come implementarlo nei tuoi ambienti.

Prerequisiti

Prima di procedere, assicurati di avere:

  • Docker 20.10+ installato e funzionante
  • Conoscenze base di networking: comprensione di TCP/IP, proxy SOCKS5, VPN
  • FamiliaritΓ  con Linux: comandi base, gestione permessi, file system
  • Un account Cloudflare (il tier gratuito Γ¨ sufficiente)
  • kubectl configurato se intendi deployare su Kubernetes
  • (Opzionale) Accesso a un kernel Linux 5.6+ per le ottimizzazioni WireGuard native

πŸ’‘ Se non hai mai usato WireGuard, non preoccuparti: MicroWARP astrae completamente la complessitΓ . Tuttavia, capire i concetti di base ti aiuterΓ  a debuggare eventuali problemi.

Architettura e Concetti Chiave

PerchΓ© i Proxy Tradizionali Consumano Tanta Memoria

Un proxy SOCKS5 classico opera interamente in user-space. Questo significa che ogni pacchetto di rete attraversa molteplici context switch tra kernel e applicazione:

  1. Il pacchetto arriva alla NIC
  2. Il kernel lo copia in un buffer
  3. L’applicazione proxy lo legge dal buffer (context switch)
  4. L’applicazione elabora e decide il routing
  5. L’applicazione scrive sul socket di destinazione (context switch)
  6. Il kernel invia il pacchetto

Ogni context switch costa circa 1-2 microsecondi e richiede allocazioni di memoria per i buffer. Con migliaia di connessioni simultanee, questi costi si accumulano rapidamente.

L’Approccio Kernel-Space di MicroWARP

MicroWARP sfrutta WireGuard, che dal kernel Linux 5.6 Γ¨ implementato direttamente nel kernel. Questo elimina la maggior parte dei context switch:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    APPROCCIO TRADIZIONALE (User-Space)                      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                             β”‚
β”‚  Pacchetto ──► Kernel ──► Context ──► Proxy ──► Elaborazione ──► Context   β”‚
β”‚  in arrivo     Buffer     Switch     User-     + Buffer         Switch     β”‚
β”‚                                      Space                                  β”‚
β”‚                                                        β”‚                    β”‚
β”‚                                                        β–Ό                    β”‚
β”‚                                              Kernel Socket ──► Pacchetto   β”‚
β”‚                                                                 in uscita  β”‚
β”‚                                                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                       MICROWARP (Kernel-Space)                              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                             β”‚
β”‚  Pacchetto ──► WireGuard ──► Routing Decision ──► Pacchetto in uscita      β”‚
β”‚  in arrivo     Kernel        in-kernel                                      β”‚
β”‚                Module                                                       β”‚
β”‚                   β–²                                                         β”‚
β”‚                   β”‚                                                         β”‚
β”‚         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                              β”‚
β”‚         β”‚ Componente User-   β”‚                                              β”‚
β”‚         β”‚ Space Minimale     β”‚                                              β”‚
β”‚         β”‚ (solo handshake)   β”‚                                              β”‚
β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                              β”‚
β”‚                                                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Il componente user-space di MicroWARP gestisce esclusivamente:

  • Handshake SOCKS5 iniziale (pochi byte)
  • Configurazione del tunnel WireGuard
  • Health check

Tutto il traffico dati effettivo passa direttamente attraverso il kernel, senza mai toccare l’applicazione.

Struttura Interna di MicroWARP

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Client           β”‚
β”‚ Application      β”‚
β”‚                  β”‚
β”‚ [SOCKS5 Request] β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           MicroWARP Container (~800KB)              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ SOCKS5      β”‚  β”‚ WireGuard   β”‚  β”‚ Cloudflare  β”‚  β”‚
β”‚  β”‚ Listener    β”‚  β”‚ Config      β”‚  β”‚ Auth        β”‚  β”‚
β”‚  β”‚ ~200KB      β”‚  β”‚ ~100KB      β”‚  β”‚ ~300KB      β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚         β”‚                β”‚                β”‚         β”‚
β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β”‚
β”‚                          β”‚                          β”‚
β”‚              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€οΏ½οΏ½οΏ½β”              β”‚
β”‚              β”‚ Shared Buffers ~200KB β”‚              β”‚
β”‚              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Linux Kernel                      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”‚
β”‚  β”‚ WireGuard       │───►│ Network Stack   β”‚         β”‚
β”‚  β”‚ Module          β”‚    β”‚                 β”‚         β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β”‚
                                   β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚    Cloudflare Edge      β”‚
                    β”‚    [WARP Endpoint]      β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Implementazione Passo-Passo

Sezione 1: Setup Base con Docker

Iniziamo con il deployment piΓΉ semplice possibile. Crea una directory di progetto e il file di configurazione:

1
2
3
# Crea la struttura del progetto
mkdir -p microwarp-proxy/{config,data}
cd microwarp-proxy

Crea il file docker-compose.yml:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# docker-compose.yml
# Configurazione minimale per MicroWARP

services:
  microwarp:
    image: ghcr.io/microwarp/microwarp:latest
    container_name: microwarp-proxy
    
    # Capability necessaria per creare l'interfaccia WireGuard
    cap_add:
      - NET_ADMIN
    
    # Sysctls per il forwarding del traffico
    sysctls:
      - net.ipv4.ip_forward=1
      - net.ipv4.conf.all.src_valid_mark=1
    
    # Volume per persistere la registrazione WARP
    volumes:
      - ./data:/var/lib/microwarp
    
    # Esponi la porta SOCKS5 solo su localhost
    ports:
      - "127.0.0.1:1080:1080"
    
    # Limiti di risorse ultra-bassi
    deploy:
      resources:
        limits:
          memory: 2M  # Margine di sicurezza sopra gli 800KB
          cpus: '0.1'
        reservations:
          memory: 1M
    
    # Health check integrato
    healthcheck:
      test: ["CMD", "microwarp", "health"]
      interval: 30s
      timeout: 5s
      retries: 3
    
    # Restart policy per produzione
    restart: unless-stopped
    
    environment:
      # Livello di log (debug|info|warn|error)
      - MICROWARP_LOG_LEVEL=info
      # Indirizzo di ascolto SOCKS5
      - MICROWARP_LISTEN=0.0.0.0:1080
      # Abilita metriche Prometheus (opzionale)
      - MICROWARP_METRICS=false

Avvia il container:

1
2
3
4
5
# Avvia MicroWARP in background
docker compose up -d

# Verifica che sia partito correttamente
docker compose logs -f microwarp

⚠️ Nota importante: La prima esecuzione richiede la registrazione con Cloudflare WARP. Il container mostrerΓ  un URL da visitare per completare l’autenticazione. Questo passaggio Γ¨ necessario solo una volta.

Testa la connessione:

1
2
3
4
# Verifica che il proxy risponda
curl --socks5 127.0.0.1:1080 https://cloudflare.com/cdn-cgi/trace

# Dovresti vedere warp=on nell'output

Sezione 2: Configurazione Multi-Container e Network Isolation

In scenari reali, vorrai che altri container usino MicroWARP come proxy. Ecco una configurazione piΓΉ avanzata:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# docker-compose.multi.yml
# Setup multi-container con network isolation

networks:
  # Network privata per il traffico proxy
  proxy-net:
    driver: bridge
    ipam:
      config:
        - subnet: 172.28.0.0/16
  
  # Network per servizi che NON devono usare il proxy
  internal-net:
    driver: bridge
    internal: true  # Nessun accesso esterno

services:
  microwarp:
    image: ghcr.io/microwarp/microwarp:latest
    container_name: microwarp
    cap_add:
      - NET_ADMIN
    sysctls:
      - net.ipv4.ip_forward=1
      - net.ipv4.conf.all.src_valid_mark=1
    volumes:
      - microwarp-data:/var/lib/microwarp
    networks:
      proxy-net:
        # IP fisso per riferimento facile da altri container
        ipv4_address: 172.28.0.10
    deploy:
      resources:
        limits:
          memory: 2M
          cpus: '0.1'
    healthcheck:
      test: ["CMD", "microwarp", "health"]
      interval: 30s
      timeout: 5s
      retries: 3
    restart: unless-stopped
    environment:
      - MICROWARP_LOG_LEVEL=info
      - MICROWARP_LISTEN=0.0.0.0:1080

  # Esempio: applicazione che usa il proxy
  web-scraper:
    image: python:3.11-slim
    depends_on:
      microwarp:
        condition: service_healthy
    networks:
      - proxy-net
    environment:
      # Configura il proxy per tutte le richieste HTTP/HTTPS
      - HTTP_PROXY=socks5://172.28.0.10:1080
      - HTTPS_PROXY=socks5://172.28.0.10:1080
      # Escludi traffico interno dal proxy
      - NO_PROXY=localhost,127.0.0.1,172.28.0.0/16
    command: >
      python -c "
      import requests
      r = requests.get('https://cloudflare.com/cdn-cgi/trace')
      print(r.text)
      "

  # Esempio: database che NON deve usare il proxy
  postgres:
    image: postgres:15-alpine
    networks:
      - internal-net
    environment:
      - POSTGRES_PASSWORD=secret
    volumes:
      - postgres-data:/var/lib/postgresql/data

  # Servizio che accede sia al proxy che al database
  api-server:
    image: node:20-alpine
    networks:
      - proxy-net      # Per traffico esterno via WARP
      - internal-net   # Per accesso al database
    environment:
      - SOCKS_PROXY=socks5://172.28.0.10:1080
      - DATABASE_URL=postgres://postgres:secret@postgres:5432/app

volumes:
  microwarp-data:
  postgres-data:

πŸ’‘ L’uso di network separate ti permette di controllare esattamente quale traffico passa attraverso il proxy. Il database rimane isolato e inaccessibile dall’esterno, mentre il traffico dell’API verso servizi esterni usa WARP.

Sezione 3: Deployment come Kubernetes Sidecar

Il pattern sidecar Γ¨ ideale per MicroWARP: ogni pod ha il suo proxy dedicato con footprint minimo.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
# microwarp-sidecar-deployment.yaml
# Deployment Kubernetes con MicroWARP come sidecar
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app-with-warp-proxy
  labels:
    app: my-application
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-application
  template:
    metadata:
      labels:
        app: my-application
      annotations:
        # Annotazione per escludere il sidecar da service mesh (se presente)
        sidecar.istio.io/inject: "false"
    spec:
      # Init container per verificare che WARP sia registrato
      initContainers:
        - name: warp-init
          image: ghcr.io/microwarp/microwarp:latest
          command: ["microwarp", "init", "--check-registration"]
          volumeMounts:
            - name: warp-data
              mountPath: /var/lib/microwarp
          securityContext:
            capabilities:
              add: ["NET_ADMIN"]
      
      containers:
        # Container principale dell'applicazione
        - name: app
          image: my-app:latest
          ports:
            - containerPort: 8080
          env:
            # Il proxy Γ¨ raggiungibile su localhost grazie al pod network
            - name: HTTP_PROXY
              value: "socks5://127.0.0.1:1080"
            - name: HTTPS_PROXY
              value: "socks5://127.0.0.1:1080"
            - name: NO_PROXY
              value: "localhost,127.0.0.1,.cluster.local,.svc"
          resources:
            requests:
              memory: "128Mi"
              cpu: "100m"
            limits:
              memory: "256Mi"
              cpu: "500m"
        
        # Sidecar MicroWARP
        - name: microwarp
          image: ghcr.io/microwarp/microwarp:latest
          securityContext:
            capabilities:
              add: ["NET_ADMIN"]
          env:
            - name: MICROWARP_LISTEN
              value: "127.0.0.1:1080"
            - name: MICROWARP_LOG_LEVEL
              value: "warn"
            # Disabilita metriche per ridurre ulteriormente il footprint
            - name: MICROWARP_METRICS
              value: "false"
          volumeMounts:
            - name: warp-data
              mountPath: /var/lib/microwarp
          # Risorse ultra-limitate
          resources:
            requests:
              memory: "1Mi"
              cpu: "10m"
            limits:
              memory: "2Mi"
              cpu: "50m"
          # Probe per health check
          livenessProbe:
            exec:
              command: ["microwarp", "health"]
            initialDelaySeconds: 10
            periodSeconds: 30
          readinessProbe:
            exec:
              command: ["microwarp", "health"]
            initialDelaySeconds: 5
            periodSeconds: 10
      
      volumes:
        - name: warp-data
          persistentVolumeClaim:
            claimName: warp-registration-pvc
---
# PVC per persistere la registrazione WARP tra i restart
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: warp-registration-pvc
spec:
  accessModes:
    - ReadWriteMany  # Necessario se replicas > 1
  resources:
    requests:
      storage: 1Mi  # La registrazione occupa pochi KB
  storageClassName: fast-ssd

Per deployare:

1
2
3
4
5
6
7
8
# Applica la configurazione
kubectl apply -f microwarp-sidecar-deployment.yaml

# Verifica che i pod siano running
kubectl get pods -l app=my-application

# Controlla i log del sidecar
kubectl logs -l app=my-application -c microwarp

πŸ“ Con 3 repliche, stai usando solo 6MB di memoria totale per i proxy (2MB Γ— 3). Un setup equivalente con Dante richiederebbe circa 150-300MB.

Configurazione per Produzione

Gestione Sicura delle Credenziali

In produzione, le credenziali WARP non devono essere accessibili a chiunque abbia accesso ai container. Usa Kubernetes Secrets:

1
2
3
4
5
6
7
8
9
# warp-secrets.yaml
apiVersion: v1
kind: Secret
metadata:
  name: warp-credentials
type: Opaque
data:
  # Genera con: cat /var/lib/microwarp/reg.json | base64
  registration: <BASE64_ENCODED_REGISTRATION>

Modifica il deployment per usare il secret:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Nel container microwarp, aggiungi:
volumeMounts:
  - name: warp-creds
    mountPath: /var/lib/microwarp
    readOnly: true

# E nella sezione volumes:
volumes:
  - name: warp-creds
    secret:
      secretName: warp-credentials

Configurazione Avanzata con ConfigMap

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# microwarp-config.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: microwarp-config
data:
  config.toml: |
    # Configurazione MicroWARP per produzione
    
    [server]
    # Indirizzo di ascolto
    listen = "127.0.0.1:1080"
    # Timeout connessione in secondi
    connect_timeout = 10
    # Timeout idle in secondi (0 = nessun timeout)
    idle_timeout = 300
    
    [wireguard]
    # MTU ottimizzato per container networking
    mtu = 1280
    # Keepalive per NAT traversal (secondi)
    persistent_keepalive = 25
    
    [performance]
    # Numero massimo di connessioni simultanee
    max_connections = 1000
    # Dimensione buffer condiviso (bytes)
    buffer_size = 65536
    # Usa io_uring se disponibile (kernel 5.1+)
    use_io_uring = true
    
    [logging]
    # Livello: trace, debug, info, warn, error
    level = "warn"
    # Formato: json, text
    format = "json"
    
    [metrics]
    # Abilita endpoint Prometheus
    enabled = true
    # Porta per le metriche (separata dal proxy)
    port = 9090

Network Policies per Kubernetes

Limita il traffico in ingresso e uscita del sidecar:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# network-policy.yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: microwarp-policy
spec:
  podSelector:
    matchLabels:
      app: my-application
  policyTypes:
    - Ingress
    - Egress
  
  ingress:
    # Solo traffico dal pod stesso (localhost)
    - from:
        - podSelector:
            matchLabels:
              app: my-application
      ports:
        - port: 1080
          protocol: TCP
  
  egress:
    # Permetti traffico verso Cloudflare WARP endpoints
    - to:
        - ipBlock:
            cidr: 162.159.192.0/24  # Cloudflare WARP
        - ipBlock:
            cidr: 162.159.193.0/24
      ports:
        - port: 2408
          protocol: UDP
    # Permetti DNS
    - to:
        - namespaceSelector: {}
          podSelector:
            matchLabels:
              k8s-app: kube-dns
      ports:
        - port: 53
          protocol: UDP

Errori Comuni e Troubleshooting

Errore: “TUNSETIFF: Operation not permitted”

Error: failed to create WireGuard interface: TUNSETIFF: Operation not permitted

Causa: Il container non ha la capability NET_ADMIN.

Soluzione:

1
2
3
4
5
6
7
8
# Docker Compose
cap_add:
  - NET_ADMIN

# Kubernetes
securityContext:
  capabilities:
    add: ["NET_ADMIN"]

⚠️ Se usi un runtime container con restrizioni di sicurezza (gVisor, Kata), potresti dover usare la modalità user-space di WireGuard, che aumenta il footprint a circa 5MB.

Errore: “Registration expired”

Error: WARP registration expired, please re-authenticate

Causa: La registrazione WARP ha una scadenza (tipicamente 30 giorni senza uso).

Soluzione:

1
2
3
4
5
6
7
8
# Rimuovi la vecchia registrazione
docker exec microwarp rm -f /var/lib/microwarp/reg.json

# Riavvia il container per ri-registrarsi
docker restart microwarp

# Segui il link di autenticazione nei log
docker logs microwarp

Errore: “Too many open files”

Error: accept: too many open files

Questo errore si verifica con molte connessioni simultanee.

Soluzione: Aumenta i limiti di file descriptor:

1
2
3
# docker-compose.yml
services:
  microwarp: