
Hola chicos,
Para es blog, lo organizaría como una guía de implementación por capas, siguiendo exactamente el diagrama, pero con una corrección importante de arquitectura:
A fecha de agosto de 2026, Application Gateway for Containers todavía usa frontends públicos administrados y no ofrece frontend privado/internal. Por tanto, si quieres que el backend desde APIM hacia AKS sea 100 % privado, debes usar otro patrón para esa parte, por ejemplo Application Gateway v2 privado o un ingress privado detrás de un ILB. Si mantienes Application Gateway for Containers, el salto APIM → AGC no será completamente privado. Microsoft Learn
Dicho esto, el resto del diagrama es perfectamente válido como patrón empresarial.
1. Crear la red base
Propón una VNet con subredes separadas:
vnet-enterprise-prod│├── snet-aks├── snet-agc├── snet-apim├── AzureFirewallSubnet├── snet-private-endpoints└── snet-management
Para Application Gateway for Containers, la subnet asociada debe estar delegada al servicio correspondiente y Microsoft recomienda disponer de al menos un /24, porque la asociación necesita un bloque amplio de direcciones. Microsoft Learn
Ejemplo conceptual Terraform:
resource "azurerm_virtual_network" "main" { name = "vnet-enterprise-prod" address_space = ["10.10.0.0/16"] location = azurerm_resource_group.main.location resource_group_name = azurerm_resource_group.main.name}
Subnets:
snet-aks = 10.10.0.0/20snet-agc = 10.10.16.0/24snet-apim = 10.10.17.0/24AzureFirewallSubnet = 10.10.18.0/26snet-private-endpoints = 10.10.19.0/24
2. Crear Azure Firewall para egress
El Firewall no forma parte del ingress principal del diagrama.
Su función será:
AKS ↓UDR 0.0.0.0/0 ↓Azure Firewall ↓Internet / APIs externas
AKS soporta userDefinedRouting, de forma que la UDR se convierte en la ruta de salida y el clúster no configura su propio camino SNAT de salida. Microsoft Learn
La route table sería conceptualmente:
resource "azurerm_route" "aks_default" { name = "default-to-firewall" address_prefix = "0.0.0.0/0" next_hop_type = "VirtualAppliance" next_hop_in_ip_address = azurerm_firewall.main.ip_configuration[0].private_ip_address}
Y debes asociarla a:
snet-aks
Microsoft documenta este patrón precisamente para obligar a que el egress de AKS atraviese Azure Firewall. Microsoft Learn
3. Crear AKS privado
Para tu diseño:
Private AKSAzure CNI OverlayCiliumWorkload IdentityOIDC IssuerUDR
Ejemplo CLI:
az aks create \ --resource-group rg-platform-prod \ --name aks-prod \ --network-plugin azure \ --network-plugin-mode overlay \ --network-dataplane cilium \ --enable-private-cluster \ --enable-oidc-issuer \ --enable-workload-identity \ --outbound-type userDefinedRouting \ --vnet-subnet-id $AKS_SUBNET_ID
Azure CNI Powered by Cilium usa eBPF y proporciona Network Policies, mejor procesamiento de servicios y mayor observabilidad de red. Microsoft Learn
La combinación sería:
Azure CNI Overlay +Cilium eBPF
4. Configurar Cilium Network Policies
Tu diagrama muestra:
Cilium├─ Microsegmentation├─ Network Policies├─ L7 Visibility└─ DNS Security
Empieza con un enfoque:
Default deny+Explicit allow
Ejemplo:
apiVersion: cilium.io/v2kind: CiliumNetworkPolicymetadata: name: api-policy namespace: appsspec: endpointSelector: matchLabels: app: api ingress: - fromEndpoints: - matchLabels: app: frontend toPorts: - ports: - port: "8080" protocol: TCP egress: - toFQDNs: - matchName: api.partner.com toPorts: - ports: - port: "443" protocol: TCP
Este modelo encaja con la recomendación actual de Microsoft de evolucionar hacia Cilium como dataplane de red para AKS. Microsoft Learn
5. Habilitar Workload Identity
El clúster necesita:
OIDC Issuer+Microsoft Entra Workload ID
Estos dos elementos se habilitan conjuntamente para que los Pods puedan utilizar federación OIDC. Microsoft Learn
Obtén el issuer:
OIDC_ISSUER=$(az aks show \ -g rg-platform-prod \ -n aks-prod \ --query oidcIssuerProfile.issuerUrl \ -o tsv)
6. Crear User Assigned Managed Identity
az identity create \ --resource-group rg-platform-prod \ --name id-api-prod
Obtener Client ID:
CLIENT_ID=$(az identity show \ -g rg-platform-prod \ -n id-api-prod \ --query clientId \ -o tsv)
7. Crear ServiceAccount
Tu YAML:
apiVersion: v1kind: ServiceAccountmetadata: name: api-sa namespace: apps annotations: azure.workload.identity/client-id: "<CLIENT-ID>"
Aplicar:
kubectl apply -f serviceaccount.yaml
8. Crear Federated Identity Credential
Aquí se establece la confianza:
AKS OIDC Issuer +ServiceAccount ↓Federated Credential ↓Managed Identity
az identity federated-credential create \ --name fic-api-prod \ --identity-name id-api-prod \ --resource-group rg-platform-prod \ --issuer "$OIDC_ISSUER" \ --subject system:serviceaccount:apps:api-sa \ --audience api://AzureADTokenExchange
9. Crear Azure Key Vault
Ejemplo:
az keyvault create \ --name kv-api-prod \ --resource-group rg-platform-prod \ --location westeurope \ --enable-rbac-authorization true
Después asigna permisos:
az role assignment create \ --assignee $CLIENT_ID \ --role "Key Vault Secrets User" \ --scope $KEYVAULT_ID
10. Private Endpoint para Key Vault
En tu diagrama, Key Vault está accesible de forma privada.
El camino debe ser:
Pod ↓Private DNS ↓Private Endpoint ↓Key Vault
Crea:
Private Endpoint→ snet-private-endpoints
y la Private DNS Zone correspondiente:
privatelink.vaultcore.azure.net
La identidad y la red resuelven dos problemas distintos:
Workload Identity= quién eresPrivate Endpoint= por dónde viajas
11. Crear namespace
apiVersion: v1kind: Namespacemetadata: name: apps
12. Crear Deployment
apiVersion: apps/v1kind: Deploymentmetadata: name: api namespace: appsspec: replicas: 3 selector: matchLabels: app: api template: metadata: labels: app: api azure.workload.identity/use: "true" spec: serviceAccountName: api-sa containers: - name: api image: myregistry.azurecr.io/api:1.0 ports: - containerPort: 8080 env: - name: KEYVAULT_URL value: "https://kv-api-prod.vault.azure.net/"
La etiqueta:
azure.workload.identity/use: "true"
permite que el workload sea preparado para usar la identidad federada. Microsoft Learn
13. Crear ClusterIP Service
apiVersion: v1kind: Servicemetadata: name: api-service namespace: appsspec: type: ClusterIP selector: app: api ports: - name: http port: 80 targetPort: 8080
Flujo:
HTTPRoute ↓api-service:80 ↓Pods:8080
14. Instalar Application Gateway for Containers ALB Controller
Microsoft permite actualmente instalar ALB Controller mediante el add-on administrado de AKS. Microsoft Learn
Conceptualmente:
AKS │ ├─ ALB Controller │ ├─ Gateway ├─ HTTPRoute │ └─ Services / Pods │ ▼Application Gateway for Containers
El ALB Controller observa Gateway, HTTPRoute, Ingress y recursos relacionados, y traduce esa configuración hacia AGC. Microsoft Learn
15. Crear subnet de AGC
La subnet debe estar delegada:
snet-agc10.10.16.0/24
con delegación al servicio requerido por Application Gateway for Containers.
Microsoft recomienda una subnet /24 con aproximadamente 250 direcciones disponibles para cada association. Microsoft Learn
16. Crear GatewayClass / Gateway
Ejemplo:
apiVersion: gateway.networking.k8s.io/v1kind: Gatewaymetadata: name: api-gateway namespace: infraspec: gatewayClassName: azure-alb-external listeners: - name: https protocol: HTTPS port: 443 hostname: api.company.com tls: mode: Terminate certificateRefs: - name: api-tls-cert allowedRoutes: namespaces: from: All
17. Crear HTTPRoute
apiVersion: gateway.networking.k8s.io/v1kind: HTTPRoutemetadata: name: api-route namespace: appsspec: parentRefs: - name: api-gateway namespace: infra hostnames: - api.company.com rules: - matches: - path: type: PathPrefix value: /api backendRefs: - name: api-service port: 80
Gateway API permite separar:
Infrastructure Team ↓GatewayApplication Team ↓HTTPRoute
y Application Gateway for Containers traduce ambos hacia configuración L7. Microsoft Learn
18. Configurar TLS
En tu diseño yo mantendría:
Client ↓ HTTPSFront Door ↓ HTTPSAPIM ↓ HTTPSAGC ↓ HTTPS opcionalService ↓Pod
AGC soporta end-to-end TLS mediante Gateway API. Microsoft Learn
Por ejemplo, para backend HTTPS:
apiVersion: gateway.networking.k8s.io/v1alpha3kind: BackendTLSPolicymetadata: name: api-backend-tls namespace: appsspec: targetRefs: - group: "" kind: Service name: api-service validation: wellKnownCACertificates: System hostname: api.apps.internal
19. Crear API Management Premium
APIM será la capa de gobierno:
APIM├─ API Catalog├─ OAuth2 / JWT├─ Rate limiting├─ Quotas├─ Transformations├─ Versioning├─ Analytics└─ Developer Portal
Como Front Door llegará privadamente a APIM, configura Inbound Private Endpoint en API Management. Microsoft soporta este patrón directamente con Front Door Premium. Microsoft Learn
20. Crear Private Endpoint de APIM
El Private Endpoint usa una IP privada de la VNet y proporciona conectividad privada a la instancia APIM. Microsoft Learn
Ejemplo conceptual:
snet-private-endpoints │ └── pe-apim ↓ APIM
Private DNS:
privatelink.azure-api.net
21. Importar la API en APIM
Ejemplo:
az apim api import \ --resource-group rg-platform-prod \ --service-name apim-prod \ --path api \ --api-id api-company \ --specification-format OpenApi \ --specification-path openapi.json
22. Configurar políticas APIM
Ejemplo:
<policies> <inbound> <base /> <validate-jwt header-name="Authorization" failed-validation-httpcode="401"> <openid-config url="https://login.microsoftonline.com/<TENANT-ID>/v2.0/.well-known/openid-configuration" /> </validate-jwt> <rate-limit-by-key calls="100" renewal-period="60" counter-key="@(context.Subscription.Id)" /> </inbound> <backend> <base /> </backend> <outbound> <base /> </outbound></policies>
23. Configurar backend APIM → AGC
Aquí está la principal consideración actual.
Si mantienes Application Gateway for Containers:
APIM ↓AGC public frontend ↓Gateway API
porque AGC actualmente no ofrece frontend privado/internal. Microsoft Learn
Esto significa que tu diagrama debería diferenciar:
Front Door → APIM PRIVATEAPIM → AGC PUBLIC HTTPS
aunque puedas aplicar controles TLS, WAF, autenticación y restricciones adicionales.
24. Alternativa si quieres backend completamente privado
Si tu requisito empresarial es:
"ninguna IP pública entre Front Door y AKS"
entonces recomiendo sustituir AGC en ese punto por:
Application Gateway v2Private frontend
porque Application Gateway v2 sí soporta frontend privado. Microsoft Learn
Entonces:
Front Door Premium ↓Private Link ↓APIM ↓Private VNet connectivity ↓Application Gateway v2Private Frontend ↓AKS
25. Crear Azure Front Door Premium
Configuración conceptual:
Front Door Premium│├─ Endpoint│ └─ api.company.com│├─ Origin Group│ └─ APIM│├─ Route│ └─ /*│└─ WAF Policy
Front Door Premium puede conectarse privadamente a APIM mediante Private Link. Microsoft Learn
26. Configurar dominio
DNS:
api.company.com ↓CNAME ↓Front Door endpoint
27. Aplicar WAF
En Front Door:
WAF Managed Rules├─ OWASP├─ Bot Protection├─ Rate Limit├─ Geo Rules└─ Custom Rules
El tráfico público termina aquí.
28. Configurar Front Door → APIM con Private Link
Flujo:
Client ↓Front Door Premium ↓Microsoft managed Private Endpoint ↓Private Link ↓APIM
Cuando Front Door habilita Private Link hacia un origen, crea su propio private endpoint administrado y la conexión debe aprobarse en el recurso de origen. Microsoft Learn
29. Configurar egress AKS
La secuencia de tu diagrama:
Pod ↓Node ↓UDR ↓Azure Firewall ↓External API
El Firewall debe permitir explícitamente los endpoints requeridos por AKS y por las aplicaciones. Microsoft mantiene una lista oficial de dependencias outbound y FQDNs requeridos. Microsoft Learn
Ejemplos de reglas:
Allow:*.azurecr.io*.blob.core.windows.netrequired AKS endpointsapi.partner.comMicrosoft update endpoints
30. Accesos privados a PaaS
Desde AKS:
Pods├── Private Endpoint → Key Vault├── Private Endpoint → Azure SQL├── Private Endpoint → Storage└── Private Endpoint → otros servicios
No conviene enviar estos flujos a Internet si puedes utilizar Private Link.
31. Managed Prometheus
Habilita Azure Monitor managed service for Prometheus.
Microsoft recomienda actualmente Managed Prometheus para métricas AKS. Microsoft Learn
Arquitectura:
AKS ↓AMA Metrics Collector ↓Azure Monitor Workspace ↓Managed Prometheus
32. Managed Grafana
Managed Prometheus ↓Azure Managed Grafana ↓Dashboards
Azure Managed Grafana puede vincularse directamente al Azure Monitor Workspace. Microsoft Learn
33. Logs
Complementa métricas con:
AKS ↓Container Insights ↓Log Analytics
y habilita también:
Control Plane LogsAudit logsApplication logsFirewall logsFront Door logsAPIM logs
La plataforma de monitoring de AKS soporta métricas Prometheus, Grafana, Container Logs y logs de control plane como componentes complementarios. Microsoft Learn
34. Secuencia final de ingress
Tu blog puede presentar el flujo operativo así:
1 User ↓2 api.company.com ↓3 Azure Front Door Premium ↓4 WAF ↓5 Private Link ↓6 APIM Private Endpoint ↓7 APIM Policies ↓8 Application Gateway for Containers ↓9 Gateway ↓10 HTTPRoute ↓11 ClusterIP Service ↓12 Pod
35. Secuencia de identidad
Pod ↓ServiceAccount ↓Projected OIDC Token ↓Microsoft Entra ID ↓Federated Identity Credential ↓Access Token ↓Azure Key Vault ↓Secret / Certificate
Workload Identity permite exactamente este modelo sin almacenar secretos de cliente en los Pods. Microsoft Learn
36. Secuencia de egress
Pod ↓AKS Node ↓UDR 0.0.0.0/0 ↓Azure Firewall ↓Application / Network Rules ↓SNAT ↓Internet / External APIs
Ese es el patrón correcto del diagrama para Azure Firewall. Microsoft Learn
Estructura recomendada del repositorio
Para que tu artículo quede profesional, mostraría también esta organización:
platform/│├── terraform/│ ├── network/│ ├── firewall/│ ├── aks/│ ├── apim/│ ├── frontdoor/│ ├── keyvault/│ ├── private-endpoints/│ └── monitoring/│└── kubernetes/ │ ├── 00-namespace.yaml ├── 01-serviceaccount.yaml ├── 02-deployment.yaml ├── 03-service.yaml │ ├── gateway/ │ ├── 10-gateway.yaml │ ├── 11-httproute.yaml │ └── 12-backendtlspolicy.yaml │ ├── security/ │ ├── 20-cilium-networkpolicy.yaml │ └── 21-secretproviderclass.yaml │ └── monitoring/ └── 30-podmonitor.yaml
Y el pipeline:
Azure DevOps / GitHub Actions ↓Terraform ↓Azure Infrastructure ↓Helm / kubectl ↓AKS resources ↓Application deployment
Conclusión para tu blog
El patrón completo separa claramente seis responsabilidades:
Edge SecurityFront Door + WAFAPI GovernanceAPIMApplication RoutingAGC + Gateway APINetwork SecurityCilium + Azure FirewallIdentity / SecretsWorkload Identity + Key VaultObservabilityManaged Prometheus + Grafana
La única parte que ajustaría visualmente en tu diagrama actual es el tramo APIM → Application Gateway for Containers: si quieres representarlo como conectividad estrictamente privada, hoy no deberías hacerlo porque AGC sigue utilizando frontend público. Para un diseño 100 % privado, usaría Application Gateway v2 con frontend privado en ese punto; para conservar Gateway API + AGC, mantendría AGC y reforzaría el endpoint público mediante TLS, políticas y controles de acceso. Microsoft Learn