> ## 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.

# Configurando o ingress

> Exponha os serviços do Midaz via ingress do Kubernetes — defina hostnames, secrets TLS e anotações para NGINX, ALB ou Traefik.

Cada serviço do Midaz pode ser exposto de forma independente via ingress. O bloco de ingress é idêntico entre os serviços (Ledger, Onboarding, Transaction, CRM, Grafana) — configure-o na seção `.ingress` de cada serviço no `values.yaml`.

Para usar o ingress, você precisa de um [ingress controller](https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/) em execução no seu cluster (ex.: **NGINX**, **AWS ALB** ou **Traefik**) e entradas DNS apontando para ele.

<Tip>
  Você pode habilitar o ingress por serviço no seu arquivo values.yaml e configurar hostnames, secrets TLS e quaisquer annotations específicas do controller.
</Tip>

<Note>
  **Integração com cert-manager:** Se você usa cert-manager para TLS automático, adicione a annotation `cert-manager.io/cluster-issuer: <issuer-name>` e defina `tls.secretName` — o cert-manager provisionará o certificado automaticamente.
</Note>

As seções a seguir fornecem exemplos de configuração para os ingress controllers mais comuns.

## NGINX ingress controller

Para usar o **NGINX Ingress Controller**, configure o `values.yaml` da seguinte forma:

```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>
  Confira a documentação oficial do ingress-nginx para uma referência completa sobre annotations do Nginx.
</Tip>

## AWS ALB (Application load balancer)

Para o **AWS ALB Ingress Controller**, configure o `values.yaml` da seguinte forma:

```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: "/healthz"  # 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
```

## Traefik Ingress controller

Para o **Traefik**, configure o `values.yaml` da seguinte forma:

```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
```

## Exemplo com múltiplos serviços

***

Para expor tanto a API do Ledger quanto o Grafana com hostnames diferentes:

```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

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