Ingress construct creates Kubernetes Ingress resources to route external HTTP/HTTPS traffic to your services. It automatically configures TLS certificates and routing rules based on domains and paths.
Constructor
Properties
The internal port that the service exposes. Traffic from the ingress will be routed to this port on the service.
A list of host rules that configure the Ingress routing. Each rule defines a domain and the paths to route.
A key/value map of annotations to customize the Ingress behavior. Common uses include:
- Path rewriting
- SSL redirects
- Request size limits
- Custom NGINX configurations
HostRules Interface
The domain name for the ingress rule (e.g.,
"api.example.com").Array of URL paths that should route to the service (e.g.,
["/api", "/admin"]).Whether this host is a subdomain of a domain that already has a wildcard certificate. When
true, the certificate name is generated from the parent domain.For example:api.example.comwithisSubdomain: true→ uses certificate forexample.comapi.example.comwithisSubdomain: false→ creates new certificate forapi.example.com
Behavior
TheIngress construct:
- Generates TLS configuration: Creates TLS entries for each host using the certificate naming convention
- Creates routing rules: Configures path-based routing for each host
- Applies annotations: Adds custom annotations to the ingress resource
- Sets metadata: Labels the ingress with
app.kubernetes.io/name
Helper Functions
removeSubdomain
isSubdomain is true.
Examples:
removeSubdomain("api.example.com", true)→"example.com"removeSubdomain("example.com", false)→"example.com"removeSubdomain("app.sub.example.com", true)→"sub.example.com"
domainToCertName
domainToCertName("example.com", false)→"example-com"domainToCertName("api.example.com", true)→"example-com"domainToCertName("api.example.com", false)→"api-example-com"
Usage Examples
Basic Ingress
Multiple Domains
Subdomain with Parent Certificate
Ingress with Custom Annotations
Path-Based Routing
WebSocket Support
TLS Configuration
The ingress automatically configures TLS based on the host rules:{certName}-tls where certName is generated using domainToCertName().
Common Annotations
Here are some commonly used NGINX Ingress annotations:Generated Kubernetes Resource
The construct generates an Ingress resource like:Related
- Certificates - TLS certificate management
- DjangoApplication - Uses Ingress internally
- ReactApplication - Uses Ingress internally