# Routing

> Which paths the ingress sends to which Corfedo Service on Kubernetes, the host names, the HTTPS certificate, the trusted proxy, the NetworkPolicies and the outside services an installation calls.

Source: https://docs.corfedo.ai/operate/kubernetes/routing/

## Which paths go to which Service

`ingress.enabled` creates one Ingress with these rules. With your own load balancer or gateway, send the same paths to the same Services on port 8080. Its health checks must reach the pods directly, not through the public route: `/health/ready` and `/health/live` answer 404 to a request that a trusted proxy forwarded.

| Path | Service |
| --- | --- |
| `/oauth`, `/.well-known/oauth-authorization-server`, `/.well-known/openid-configuration` | `corfedo-issuer` |
| `/api` | `corfedo-api` |
| `/mcp`, `/.well-known/oauth-protected-resource` | `corfedo-mcp` |
| `/scim`, which your identity provider calls | `corfedo-scim` |
| `/webhooks`, which Slack and Microsoft Teams call | `corfedo-webhooks` |
| Everything else | `corfedo-web` |

The Services' names start with the release name, here `corfedo`.

| `hosting.mode` | Host names |
| --- | --- |
| `SingleTenant` | The host of `hosting.publicOrigin` |
| `MultiTenant` | The host of `hosting.finderOrigin` and every name one label below `hosting.baseDomain` |

With `keycloak.enabled`, the Ingress also sends `keycloak.host` to Keycloak.

## HTTPS certificate

The public entry holds the certificate for the host names above, not Corfedo. Add the values of your case to `values.yaml`.

**cert-manager**

cert-manager issues the certificate into the Secret `corfedo-tls` and renews it. Replace `letsencrypt` with your ACME ClusterIssuer, which needs an [approval policy](https://docs.corfedo.ai/operate/kubernetes/prepare-the-cluster/#public-entry).

```yaml
ingress:
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt
  tls:
    - secretName: corfedo-tls
```

**AWS load balancer**

The load balancer holds the certificate from ACM, so leave `ingress.tls` empty. With the target type `ip` it sends to the pods directly: `hosting.trustedProxies` and `networkPolicy.ingressFrom` name its subnets, and its health checks use `/health/ready`.

```yaml
ingress:
  className: alb
  annotations:
    alb.ingress.kubernetes.io/scheme: internet-facing
    alb.ingress.kubernetes.io/target-type: ip
    alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS": 443}]'
    alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:eu-central-1:111122223333:certificate/EXAMPLE
    alb.ingress.kubernetes.io/healthcheck-path: /health/ready
hosting:
  trustedProxies: [10.0.0.0/16]
networkPolicy:
  ingressFrom:
    - ipBlock: {cidr: 10.0.0.0/16}
```

**Your own Secret**

Name a Secret of type `kubernetes.io/tls` in the release's namespace. Without `ingress.tls`, your ingress controller's default certificate applies.

```sh
kubectl create secret tls acme-tls --namespace corfedo --cert=tls.crt --key=tls.key
```

```yaml
ingress:
  tls:
    - secretName: acme-tls
```

## Trusted proxy

TLS ends at the public entry, which forwards plain HTTP. Set `hosting.trustedProxies` to the networks the forwarded requests come from. Corfedo accepts a forwarded client address and scheme only from them, see [Public entry](https://docs.corfedo.ai/operate/kubernetes/prepare-the-cluster/#public-entry).

## NetworkPolicies

`networkPolicy.ingressFrom` names the peers allowed to send public requests to Corfedo, your ingress controller's pods or the load balancer's subnets when it sends to the pods directly, and is required while `networkPolicy.enabled` is on, the default. The policies limit inbound traffic only, and only when the cluster's network plugin enforces NetworkPolicy.

## Outside services

To restrict outbound traffic with egress policies or firewall rules, allow the cluster's DNS, the traffic between the release's own pods and these services. Corfedo reaches them over HTTPS, except PostgreSQL.

- Your PostgreSQL server, on `database.port`, and on `keycloak.database.port` when the bundled Keycloak uses a database outside the release.
- The bucket. With the AWS credential chain, also the AWS credential endpoints, such as AWS STS for IAM roles for service accounts.
- Your code hosts.
- Your identity provider.
- The AI providers you add, and the identity endpoints of Azure and Google credentials, by default `login.microsoftonline.com` and `oauth2.googleapis.com`.
- `clients.corfedo.ai` for the Corfedo CLI, and the address each coding agent gives for its description, when they sign in.
- Advisory data at `storage.googleapis.com` and `cwe.mitre.org`.
- Slack. With Socket Mode, also a secure WebSocket to an address Slack returns, which an HTTPS-only proxy or filter must allow.
- Microsoft Teams, with Microsoft's sign-in and the Bot Framework's signing keys.

[Data handling](https://docs.corfedo.ai/operate/security/data-handling/#what-leaves-the-installation) lists what each outside service receives.
