> ## Documentation Index
> Fetch the complete documentation index at: https://ayakaleaf-pro.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 5. Distribuire Ayakaleaf Pro

> Distribuisci il pod di Ayakaleaf Pro, il suo volume dei dati e un Service NodePort.

```yaml title="40-overleaf.yaml" wrap theme={null}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: overleaf-data
  namespace: overleaf
spec:
  accessModes: [ReadWriteOnce]
  resources:
    requests:
      storage: 20Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: overleaf
  namespace: overleaf
spec:
  replicas: 1
  strategy:
    type: Recreate          # one pod owns the data volume; never run two at once
  selector:
    matchLabels:
      app: overleaf
  template:
    metadata:
      labels:
        app: overleaf
    spec:
      terminationGracePeriodSeconds: 60   # time to flush pending edits, like the Toolkit
      # Keep the environment to what the ConfigMap and Secret set: no REDIS_PORT=tcp://... and the like
      enableServiceLinks: false
      containers:
        - name: sharelatex
          image: ghcr.io/ayaka-notes/overleaf-pro:6.3.2
          envFrom:
            - configMapRef:
                name: overleaf-env
            - secretRef:
                name: overleaf-secrets
          ports:
            - containerPort: 80
          readinessProbe:
            httpGet:
              path: /status
              port: 80
            periodSeconds: 10
          resources:
            requests:
              cpu: 500m
              memory: 1536Mi
            limits:
              memory: 3Gi
          volumeMounts:
            - name: data
              mountPath: /var/lib/overleaf
            - name: compiles
              mountPath: /var/lib/overleaf/data/compiles
            - name: output
              mountPath: /var/lib/overleaf/data/output
            - name: cache
              mountPath: /var/lib/overleaf/data/cache
            - name: docker-sock
              mountPath: /var/run/docker.sock
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: overleaf-data
        # Compile scratch space on the node; same paths as SANDBOXED_COMPILES_HOST_DIR_*
        - name: compiles
          hostPath:
            path: /srv/overleaf/compiles
            type: DirectoryOrCreate
        - name: output
          hostPath:
            path: /srv/overleaf/output
            type: DirectoryOrCreate
        - name: cache
          hostPath:
            path: /srv/overleaf/cache
            type: DirectoryOrCreate
        - name: docker-sock
          hostPath:
            path: /var/run/docker.sock
            type: Socket
---
apiVersion: v1
kind: Service
metadata:
  name: overleaf
  namespace: overleaf
spec:
  type: NodePort
  selector:
    app: overleaf
  ports:
    - name: http
      port: 80
      targetPort: 80
      nodePort: 30080
```

```bash theme={null}
kubectl apply -f 40-overleaf.yaml
kubectl -n overleaf rollout status deployment/overleaf --timeout=10m
kubectl -n overleaf logs deployment/overleaf | grep -E 'Finished migrations|Missing required'
```

Il primo avvio esegue le migrazioni del database e richiede un paio di minuti. Il pod è pronto quando `/status` risponde; a quel punto apri `OVERLEAF_SITE_URL`.

### Perché il manifest è fatto così

* **Volume dei dati.** Tutto ciò che si trova in `/var/lib/overleaf` (file dei progetti, cronologia, upload) risiede sul PVC. Con uno storage locale al nodo come local-path i dati restano su un unico nodo; con uno storage a blocchi di rete il pod può spostarsi tra i nodi.
* **Volumi di compilazione e socket Docker.** Ayakaleaf Pro chiede al Docker del nodo di avviare un container TeX Live e gli passa la directory di compilazione del progetto **tramite il suo percorso sul nodo**. Queste directory sono quindi volumi `hostPath`, e i loro percorsi sono ripetuti in `SANDBOXED_COMPILES_HOST_DIR_*`. Il loro contenuto è costituito da dati temporanei e non richiede backup.
* **`enableServiceLinks: false`.** Kubernetes aggiunge a ogni pod variabili in stile Docker per ogni Service del namespace: il Service `redis` diventa `REDIS_PORT=tcp://10.x.x.x:6379`, il Service `git-bridge` `GIT_BRIDGE_PORT=tcp://...`. Alcuni servizi di Overleaf leggono variabili con questi nomi. In questo pod prevalgono le impostazioni di `OVERLEAF_REDIS_*` e della ConfigMap, ma git-bridge usa `GIT_BRIDGE_PORT` come propria porta e si arresta (vedi [Integrazione Git](https://ayakaleaf-pro.mintlify.site/it/on-premises/configuration/kubernetes/integrations/git-integration.md)). Disattivare i link limita l'ambiente a ciò che imposti tu.
* **`Recreate`.** Due pod non devono mai usare lo stesso volume dei dati né eseguire migrazioni contemporaneamente.
* **Esposizione.** Il Service NodePort risponde sulla porta `30080` di ogni nodo. In produzione metti davanti il tuo ingress controller o load balancer e termina lì TLS; deve consentire i WebSocket, timeout delle richieste di 10 minuti (compilazioni lunghe) e upload di 50 MB, e inoltrare `X-Forwarded-For` e `X-Forwarded-Proto`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.