> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lerian.studio/llms.txt
> Use this file to discover all available pages before exploring further.

# Configurar ingress

> Expón los servicios de Midaz a través de ingress de Kubernetes: define hostnames, secrets de TLS y anotaciones del controller para NGINX, ALB o Traefik.

<Warning>
  La orientación sobre CRM y Fees marcada como legacy en esta página aplica solo a un release legacy existente. Midaz v4 despliega el Ledger unificado y sirve CRM y Fees en `/v2`.
</Warning>

El repositorio de Helm conserva un workload `crm.enabled` y el chart `plugin-fees-helm` para releases de aplicación anteriores. Son superficies de compatibilidad legacy, no el modelo de despliegue de Midaz v4.

Usa `ledger.ingress` para Midaz v4. Los ejemplos de ingress de CRM que se conservan aplican solo al workload de compatibilidad legacy `crm.enabled`.

Para usar ingress, necesitas un [ingress controller](https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/) en ejecución en tu cluster (por ejemplo, **NGINX**, **AWS ALB** o **Traefik**) y entradas de DNS que apunten hacia él.

<Tip>
  Puedes habilitar ingress por servicio en tu archivo values.yaml y configurar hostnames, secrets de TLS y cualquier anotación específica del controller.
</Tip>

<Note>
  **Integración con cert-manager:** Si usas cert-manager para TLS automático, agrega la anotación `cert-manager.io/cluster-issuer: <issuer-name>` y define `tls.secretName`. cert-manager provisiona el certificado automáticamente.
</Note>

## Ingress controller de NGINX

***

Para usar el **NGINX Ingress Controller**, configura el `values.yaml` de la siguiente manera:

```yaml expandable theme={null}
ingress:
  enabled: true
  className: "nginx"
  # The `annotations` field is used to add custom metadata to the Nginx resource.
  # Annotations are key-value pairs that can be used to attach arbitrary non-identifying metadata to objects.
  # These annotations can be used by various tools and libraries to augment the behavior of the Nginx resource.
  # See more https://github.com/kubernetes/ingress-nginx/blob/main/docs/user-guide/nginx-configuration/annotations.md
  annotations: {}
  hosts:
    - host: midaz.example.com
      paths:
        - path: /
          pathType: Prefix
  tls:
    - secretName: midaz-tls  # Ensure this secret exists or is managed by cert-manager
      hosts:
        - midaz.example.com
```

<Tip>
  Consulta la documentación oficial de ingress-nginx para una referencia completa de las anotaciones de Nginx.
</Tip>

## AWS ALB (Application load balancer)

***

Para el **AWS ALB Ingress Controller**, configura el `values.yaml` de la siguiente manera:

```yaml expandable theme={null}
ingress:
  enabled: true
  className: "alb"
  annotations:
    alb.ingress.kubernetes.io/scheme: internal  # Use "internet-facing" for public ALB
    alb.ingress.kubernetes.io/target-type: ip   # Use "instance" if targeting EC2 instances
    alb.ingress.kubernetes.io/group.name: "midaz"  # Group ALB resources under this name
    alb.ingress.kubernetes.io/healthcheck-path: "/health"  # Health check path
    alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS": 443}]'  # Listen on HTTP and HTTPS
  hosts:
    - host: midaz.example.com
      paths:
        - path: /
          pathType: Prefix
  tls: []  # TLS is managed by the ALB using ACM certificates
```

## Ingress controller de Traefik

***

Para **Traefik**, configura el `values.yaml` de la siguiente manera:

```yaml expandable theme={null}
ingress:
  enabled: true
  className: "traefik"
  annotations:
    traefik.ingress.kubernetes.io/router.entrypoints: "web, websecure"  # Entrypoints defined in Traefik
    traefik.ingress.kubernetes.io/router.tls: "true"  # Enable TLS for this route
  hosts:
    - host: midaz.example.com
      paths:
        - path: /
          pathType: Prefix
  tls:
    - secretName: midaz-tls  # Ensure this secret exists and contains the TLS certificate
      hosts:
        - midaz.example.com
```

## Ejemplo con varios servicios

***

Para exponer tanto la API de Ledger como CRM con hostnames distintos:

```yaml theme={null}
ledger:
  ingress:
    enabled: true
    className: "nginx"
    hosts:
      - host: api.midaz.example.com
        paths:
          - path: /
            pathType: Prefix
    tls:
      - secretName: midaz-api-tls
        hosts:
          - api.midaz.example.com

crm:
  ingress:
    enabled: true
    className: "nginx"
    hosts:
      - host: crm.midaz.example.com
        paths:
          - path: /
            pathType: Prefix
    tls:
      - secretName: midaz-crm-tls
        hosts:
          - crm.midaz.example.com
```
