Skip to main content
After installing the nginx Ingress Controller, create an Ingress object that defines how incoming requests are routed to a Service. 1. Create a file named ingress.yaml with the following content:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
  namespace: default
spec:
  ingressClassName: nginx
  rules:
    - http:
        paths:
          - pathType: Prefix
            path: /
            backend:
              service:
                name: example-service
                port:
                  number: 80
The manifest defines a single routing rule for one Service. Replace the example values with values for the target service:
FieldDescription
nameName of the Ingress object
namespaceNamespace where the target Service runs
ingressClassNameName of the IngressClass — nginx for the nginx controller
pathURL path prefix to match incoming requests
service.nameName of the Service to route traffic to
service.port.numberPort exposed by the target Service that receives incoming requests
2. Apply the manifest:
kubectl apply -f ingress.yaml
Expected output:
ingress.networking.k8s.io/example-ingress created
The Ingress object is now active and the nginx Ingress Controller begins routing requests according to the configured rules.