Kubernetes YAML Networking/Basic Ingress YAML

Route traffic by host and path.

Section: Ingress

Basic Ingress YAML

yaml
yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: app
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: nginx
  rules:
    - host: app.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: api
                port:
                  number: 80
Explanation

Ingress manages external HTTP/HTTPS access based on hostnames and paths. It requires an Ingress controller.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Ingress
Enable TLS on Ingress
Terminate HTTPS with a Secret-backed certificate.
OpenIn sheetyamlsame section
ClusterIP Service YAML
Expose Pods internally in the cluster.
Default deny ingress policy
Block incoming traffic until explicitly allowed.
NodePort Service YAML
Expose the service on each node's IP.
Allow ingress from labeled pods
Permit traffic only from a specific app tier.
LoadBalancer Service YAML
Request external load balancing from the platform.