Ingress در Kubernetes باید ترافیک خارجی را به Serviceها برساند — با TLS، path routing، و مشاهدهپذیری. خیلی تیمها بین این گزینهها میمانند:
NGINX Ingress → آشنا، annotation-heavy
Envoy خام → قدرتمند، بدون K8s control plane
Gateway API → استاندارد آینده، نیاز به implementationContour پاسخ Heptio/VMware (و حالا جامعه CNCF) است:
An open source Kubernetes ingress controller providing the control plane for the Envoy edge and service proxy
یعنی Contour خود Envoy نیست — مدیریتکنندهٔ Envoy است: Kubernetes API را میبیند و از طریق xDS به Envoy config میدهد.
طبق CNCF: پذیرش ۷ ژوئیه ۲۰۲۰ در سطح Incubating.
مشکل: Ingress بدون data plane مدرن
Ingress resource alone:
فقط قرارداد — نیاز به controller
NGINX Ingress:
بالغ — مدل annotation، کمتر «Envoy-native»
Contour:
Contour (control) + Envoy (data)
Ingress + HTTPProxy + Gateway API
همان قابلیتهای L7 که در [Envoy](/blog/envoy-proxy-cloud-native-data-plane-guide/) دارید| معیار | NGINX Ingress | Traefik | Envoy Gateway | Contour |
|---|---|---|---|---|
| Data plane | NGINX | Traefik | Envoy | Envoy |
| Ingress v1 | ✅ | ✅ | محدود/متفاوت | ✅ |
| CRD غنی | annotations | IngressRoute/… | HTTPRoute | HTTPProxy |
| Gateway API | وابسته | ✅ | تمرکز اصلی | ✅ |
| xDS native | ❌ | — | ✅ | ✅ |
| CNCF | — | — | مرتبط Envoy | ✅ Incubating |
Contour برای تیمهایی است که Envoy را بهعنوان edge میخواهند، اما با تجربهٔ Kubernetes-native (CRD، status، Helm).
Contour چیست؟
Contour یک Kubernetes Ingress Controller است که:
- Envoy را بهعنوان reverse proxy با عملکرد بالا اجرا میکند
- خودش management server (xDS) برای آن Envoyها است
- منابع
Ingress،HTTPProxy، و اختیاری Gateway API را تماشا میکند - Service، Endpoints، Secret را به CDS/RDS/EDS/SDS ترجمه میکند
Site: projectcontour.io
CNCF page: cncf.io/projects/contour
Repo: github.com/projectcontour/contour
Origin: Heptio → VMware Tanzu ecosystem → CNCF
License: Apache 2.0
تاریخچه
| تاریخ | رویداد |
|---|---|
| ۴ ژوئیه ۲۰۱۶ | First commit (طبق metrics CNCF) |
| Heptio / VMware | رشد بهعنوان ingress مبتنی بر Envoy |
| ۷ ژوئیه ۲۰۲۰ | ورود به CNCF در سطح Incubating |
| ongoing | HTTPProxy، Gateway API، TLS delegation، rate limit، ext_authz |
| همزیستی | معرفی Envoy Gateway (۲۰۲۲+) — گزینهٔ دیگر روی همان data plane |
هر دو Contour و Envoy Gateway از Envoy استفاده میکنند؛ Contour مسیر بالغ Ingress/HTTPProxy + Gateway را نگه میدارد، Envoy Gateway بیشتر روی Gateway API خالص تمرکز دارد.
معماری: Contour + Envoy
طبق Architecture docs:
Kubernetes API
Ingress / HTTPProxy / Gateway API / Service / Endpoints / Secret
│ watch (controller-runtime)
▼
┌─────────────────┐ gRPC xDS ┌─────────────┐
│ Contour │◄──────────────────►│ Envoy │
│ Deployment │ CDS RDS EDS … │ DaemonSet │
│ (leader elect) │ │ or Deploy │
└─────────────────┘ └──────┬──────┘
│
LoadBalancer / NLB
│
Clients → Services → Podsنقشها
| جزء | نقش |
|---|---|
| Contour | client API سرور؛ cache؛ ترجمه به xDS؛ نوشتن status (فقط leader) |
| Envoy | data plane — terminate TLS، route، upstream |
| Init bootstrap | در Pod Envoy، Contour بهصورت initcontainer فایل bootstrap مینویسد تا Envoy Contour را بهعنوان management server بشناسد |
Envoy اگر Contour موقتاً نباشد gracefully retry میکند — ترتیب start حیاتی نیست.
HA Contour
- چند replica با leader election
- همه instanceها میتوانند xDS به Envoy بدهند
- فقط leader status را به API مینویسد
- در ترافیک بالای Envoy→Contour، HA مقیاس عملیاتی میدهد
استقرار Envoy
| مدل | مزیت | نکته |
|---|---|---|
| DaemonSet | یک Envoy per node؛ hostPort؛ توزیع ساده | روی حذف node، preStop محدود DaemonSet |
| Deployment + anti-affinity | drain تمیزتر هنگام scale-down | نزدیک به الگوی DaemonSet |
Probes: Envoy /ready روی admin؛ Contour liveness /healthz و readiness دسترسی به API.
سه سطح API برای routing
۱. Ingress (استاندارد)
سازگار با اکوسیستم موجود؛ با Helm اغلب ingressClassName: contour.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: httpbin
spec:
ingressClassName: contour
rules:
- host: httpbin.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: httpbin
port:
number: 80۲. HTTPProxy (CRD Contour)
قابلیتهای غنیتر از Ingress کلاسیک:
- virtual host با FQDN
- path routing، header/method matching
- weight / mirroring / retry / timeout
- includes — ترکیب routeها بین namespaceها
- TCPProxy برای TCP/TLS passthrough
- TLS با Secret و TLSCertificateDelegation
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
name: www
namespace: default
spec:
virtualhost:
fqdn: www.example.com
tls:
secretName: www-tls # یا admin-ns/wildcard-secret با delegation
routes:
- conditions:
- prefix: /
services:
- name: web
port: 80
weight: 90
- name: web-canary
port: 80
weight: 10۳. Gateway API
Contour هدف پشتیبانی core و extended Gateway API را دارد.
- یک Gateway ≈ یک جفت Contour+Envoy (۱:۱ در مدل Contour)
HTTPRoute/TLSRouteو منابع مرتبط- دو روش نصب: static provisioning و dynamic (Gateway Provisioner)
حتی با Gateway فعال، میتوانید هنوز Ingress/HTTPProxy را (با محدودیتها و listenerهای خاص) استفاده کنید — مفید برای مهاجرت تدریجی.
TLS، cert-manager، Delegation
TLS termination
- Secret استاندارد Kubernetes (
tls.crt/tls.key) - SNI اجباری برای virtual host صحیح
- یکپارچگی رایج با cert-manager — راهنمای رسمی Contour موجود است
TLSCertificateDelegation
برای wildcard cert در namespace admin که تیمهای دیگر باید ارجاع دهند — بدون کپی Secret:
apiVersion: projectcontour.io/v1
kind: TLSCertificateDelegation
metadata:
name: wildcard-delegate
namespace: www-admin
spec:
delegations:
- secretName: example-com-wildcard
targetNamespaces:
- example-com
# یا "*" برای همهدر HTTPProxy:
tls:
secretName: www-admin/example-com-wildcardبرای Ingress v1 از annotation projectcontour.io/tls-cert-namespace استفاده میشود.
قابلیتهای عملیاتی مهم
| قابلیت | کاربرد |
|---|---|
| External Authorization | ext_authz از طریق Envoy |
| Global Rate Limiting | محدودیت نرخ متمرکز |
| gRPC ingress | راهنمای رسمی برای سرویسهای gRPC |
| Health checking | upstream health |
| PROXY protocol | حفظ client IP پشت NLB/LB |
| AWS NLB guides | استقرار production روی AWS |
| FIPS 140-2 | محیطهای regulated |
| Gatekeeper | policy روی Contour resources |
| Prometheus metrics | Contour + Envoy |
همه روی قدرت Envoy سوارند — Contour آنها را از Kubernetes قابلاعلام میکند.
نصب
پیشنیاز
- Kubernetes cluster
kubectl(+ اختیاری Helm)- برای production: LoadBalancer / NLB و DNS
Helm (سریع)
helm repo add projectcontour https://charts.projectcontour.io
# یا طبق docs جاری projectcontour — repository ممکن است بهروز شود
helm repo update
helm install my-release contour/contour \
--namespace projectcontour \
--create-namespaceمستندات رسمی Getting Started چند گزینه دارد: YAML خام، Helm، Gateway provisioner — همیشه getting-started نسخهٔ روز را چک کنید.
Gateway Provisioner (dynamic)
# مفهومی — از manifests رسمی
# 1) نصب provisioner
# 2) GatewayClass با controllerName: projectcontour.io/gateway-controller
# 3) Gateway در namespace projectcontourبا ساخت Gateway، Contour+Envoy مربوطه provision میشوند. میتوانید routing را همچنان با Ingress تعریف کنید.
تست سریع
# static Envoy service
kubectl -n projectcontour port-forward svc/envoy 8888:80
# یا با provisioner
kubectl -n projectcontour port-forward svc/envoy-contour 8888:80
curl -H "Host: httpbin.example.com" http://127.0.0.1:8888/مقایسه Contour vs Envoy Gateway vs NGINX
| سناریو | انتخاب محتمل |
|---|---|
| تیم روی HTTPProxy و Contour mature | Contour |
| فقط Gateway API سبزمیدان | Envoy Gateway (یا Contour با Gateway) |
| annotationهای NGINX موجود زیاد | NGINX Ingress (مهاجرت تدریجی) |
| نیاز service mesh کامل | Istio / Cilium + Envoy sidecar — Contour فقط north-south |
| AI / LLM multi-provider | Envoy AI Gateway |
Contour جایگزین mesh نیست — ingress/edge است.
Observability و troubleshooting
kubectl -n projectcontour get pods
kubectl -n projectcontour logs deploy/contour --tail=100
kubectl -n projectcontour logs ds/envoy --tail=50 # یا deploy/envoy
# status روی HTTPProxy
kubectl describe httpproxy www| علامت | بررسی |
|---|---|
| HTTPProxy Invalid | FQDN تکراری، Secret TLS، include cycle |
| 503 | Endpoints خالی، health check، Service port |
| TLS fail | Secret، delegation، SNI/Host mismatch |
| Envoy بالا Contour پایین | bootstrap/xDS retry؛ بعداً config میآید |
| Ingress نادیده | ingressClassName، Contour IngressClass filter |
Admin Envoy و metrics Prometheus را محدود و مانیتور کنید — مثل هر Envoy deployment.
امنیت
- Contour به Secrets دسترسی دارد — RBAC حداقل و namespaceبندی
- TLS delegation را فقط به namespaceهای لازم بدهید (
*با احتیاط) - External auth و rate limit برای edge
- Threat model رسمی Contour را در docs امنیت بخوانید
- بهروزرسانی همگام Contour و تصویر Envoy همراه chart
تصاویر از Harbor؛ توزیع در مقیاس با Dragonfly.
ارتباط با stack شما
Internet
│
▼
LoadBalancer / NLB
│
▼
Envoy (Contour-managed) ← data plane
│ xDS
Contour Deployment ← control plane
│ watch
Ingress / HTTPProxy / Gateway API
│
▼
Services → Pods
([containerd](/blog/containerd-container-runtime-guide/), [Cilium](/blog/cilium-ebpf-kubernetes-networking/), [CoreDNS](/blog/coredns-kubernetes-dns-guide/))
TLS secrets ← [cert-manager](/blog/cert-manager-kubernetes-tls-certificates/)
GitOps ← [Argo CD](/blog/argo-project-kubernetes-gitops-cicd/)Dapr پشت Contour میماند (app runtime)؛ Contour فقط ورودی north-south را مدیریت میکند.
Best practices
- در production از Deployment Envoy با anti-affinity اگر drain تمیز مهم است
- Contour را HA (≥۲ replica) کنید
- برای wildcard از TLSCertificateDelegation استفاده کنید نه کپی Secret
ingressClassNameرا صریح بگذارید اگر چند controller دارید- مهاجرت تدریجی: Ingress → HTTPProxy → Gateway API
- PROXY protocol را با NLB درست کنید تا IP واقعی client بماند
- Resource limits Contour/Envoy را از راهنمای رسمی تنظیم کنید
- Metrics + alert روی xDS و upstream 5xx
- GitOps برای HTTPProxy/Gateway
- نسخه chart Contour را با Envoy bundled همتراز نگه دارید
چه زمانی Contour؟
✅ استفاده کنید
- میخواهید Envoy در edge با تجربه Kubernetes
- نیاز به HTTPProxy (includes، delegation، weights)
- Gateway API + حفظ Ingress موجود
- یکپارچگی با cert-manager و AWS NLB
⚠️ شاید نه
- فقط چند Ingress ساده و تیم NGINX — مهاجرت اجباری نیست
- نیاز به AI Gateway تخصصی — Envoy AI Gateway را جدا ببینید
- بدون آمادگی ops برای دو جزء Contour+Envoy
طبق CNCF project page، پروژه Incubating است؛ قبل از انتخاب، وضعیت community و roadmap نسخهٔ جاری را چک کنید (health score در LFX متغیر است).
جمعبندی
| مفهوم | توضیح |
|---|---|
| Contour | Kubernetes ingress controller — control plane برای Envoy |
| Envoy | data plane reverse proxy |
| xDS | کانال config Contour → Envoy |
| HTTPProxy | CRD غنی Contour |
| Gateway API | پشتیبانی با static یا provisioner |
| TLS delegation | اشتراک امن wildcard cert بین namespaceها |
| CNCF | Incubating از ژوئیه ۲۰۲۰ |
Contour پلی است بین قراردادهای Kubernetes (Ingress/Gateway) و قدرت Envoy — بدون اینکه هر تیم Envoy خام را با دست پیکربندی کند.
قدم بعدی
- Getting Started — YAML یا Helm روی kind/dev
- یک Ingress با
ingressClassName: contour - همان سرویس را به HTTPProxy با weight canary تبدیل کنید
- cert-manager + TLS روی HTTPProxy
- (اختیاری) Gateway provisioner و یک
HTTPRoute
منابع
- CNCF Contour
- projectcontour.io
- Architecture
- Getting Started
- Gateway API with Contour
- TLS Certificate Delegation
- GitHub — projectcontour/contour
- Envoy Proxy (مقاله P30Light)
منتشر شده در P30Light — بخش زیرساخت و سرور.