Exposing Your Application via HTTP Endpoint
To make your application accessible externally, you must expose it through an HTTP endpoint. This is typically achieved using the Kubernetes Gateway API, which provides a standardized way to manage ingress traffic.
Prerequisite: Gateway Controller
A Gateway Controller is required to implement the Gateway API resources. If you already have a GatewayAPI Controller installed, ensure the className matches the controller's configured class name:
Quick Setup: Gateway Controller
You can use either the NGINX Gateway Fabric or a cloud-native Gateway Controller (AWS, GCP, Azure):
NGINX Gateway Fabric
- Install GatewayAPI CRDs:
- Deploy the NGINX GatewayAPI Controller:
- Ensure all pods are running:
Cloud-Native Gateway Controllers
- AWS: Use AWS Load Balancer Controller or Gateway API support in EKS.
- GCP: Use GKE Gateway Controller.
- Azure: Use Azure Application Gateway Ingress Controller.
Refer to your cloud provider's documentation for installation steps.
(Optional) TLS Configuration Using cert-manager
-
Add the Helm cert-manager repository:
-
Install cert-manager:
-
Ensure all cert-manager pods are running:
Create a cert issuer
Update the desired namespace ({{ Namespace }}) and ({{ GatewayName }}).
Create a Gateway
Update the desired namespace ({{ Namespace }}). Once updated, apply the configuration:
AWS NLB
If deploying on AWS and using a Network Load Balancer (NLB), ensure your Gateway specs include the following annotations for proper cross-zone load balancing and external access:
kind: Gateway
spec:
infrastructure:
annotations:
service.beta.kubernetes.io/aws-load-balancer-attributes: |
load_balancing.cross_zone.enabled=true
service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: instance
service.beta.kubernetes.io/aws-load-balancer-scheme: internet-facing
service.beta.kubernetes.io/aws-load-balancer-type: external
cert-issuer Annotations
Update the annotation for gateway as per cert-issuer create
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: qmig-gateway
namespace: {{ Namespace }}
labels:
component: "app"
app.kubernetes.io/name: qmig
annotations:
cert-manager.io/cluster-issuer: letsencrypt # If cluster-issuer created
# cert-manager.io/issuer: letsencrypt # If issuer created
spec:
gatewayClassName: nginx
listeners:
- name: http
protocol: HTTP
port: 80
allowedRoutes:
namespaces:
from: Same
- name: https
protocol: HTTPS
port: 443
allowedRoutes:
namespaces:
from: Same
tls:
mode: Terminate
certificateRefs:
- name: qmig-tls
(Optional) Map Domain to External IP
-
Retrieve the external IP (LoadBalancer) of the Gateway in your
<namespace>:
-
Update your domain's DNS settings with your domain provider to point to the external IP of the Gateway. Create an
Arecord with the following details:- Type: A
- Name:
@(or your desired subdomain, e.g.,www) - Value:
<EXTERNAL-IP>(replace with the external IP retrieved in the previous step) - TTL: Default or as per your provider's recommendation
-
Once updated, allow some time for DNS propagation before accessing your application using your domain.
Create HTTPRoute
Update the desired namespace ({{ Namespace }}) and replace your-domain.com. Once updated, apply the configuration:
Note
Verify the service names in your backendRefs match the services available in your namespace. For example:
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: qmig-route
namespace: {{ Namespace }}
labels:
component: "app"
app.kubernetes.io/name: qmig
spec:
parentRefs:
- name: qmig-gateway
namespace: {{ Namespace }}
sectionName: http
hostnames:
- "your-domain.com"
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: qmig-app
port: 4200
- matches:
- path:
type: PathPrefix
value: /api
backendRefs:
- name: qmig-eng
port: 8080
- matches:
- path:
type: PathPrefix
value: /airflow
backendRefs:
- name: qmig-airflow-webserver
port: 8080
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: qmig-route
namespace: {{ Namespace }}
labels:
component: "app"
app.kubernetes.io/name: qmig
spec:
parentRefs:
- name: qmig-gateway
namespace: {{ Namespace }}
sectionName: http
- name: qmig-gateway
namespace: {{ Namespace }}
sectionName: https
hostnames:
- "your-domain.com"
rules:
- matches:
- path:
type: PathPrefix
value: /
backendRefs:
- name: qmig-app
port: 4200
- matches:
- path:
type: PathPrefix
value: /api
backendRefs:
- name: qmig-eng
port: 8080
- matches:
- path:
type: PathPrefix
value: /airflow
backendRefs:
- name: qmig-airflow-webserver
port: 8080
Access Endpoint
- Retrieve the external IP (LoadBalancer)/Host of the HTTPRoute in your
<namespace>: - Access the application in your browser or via
curl:
If the domain is mapped, access your application using your-domain.com.
References
For detailed installation and configuration instructions, refer to the official documentation: