Link Search Menu Expand Document

Ingress

fanout.yaml

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-fanout
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
    - host: foo.bar.com
      http:
        paths:
          - path: /path1
            backend:
              service:
                name: testsvc1
                port:
                  number: 4201
            pathType: exact
          - path: /path2
            backend:
              service:
                name: testsvc2
                port:
                  number: 4202
            pathType: exact

ingress-class.yaml

---
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  name: external-lb
spec:
  controller: example.com/ingress-controller
  parameters:
    apiGroup: k8s.example.com/v1alpha
    kind: IngressParameters
    name: external-lb

ingress.yaml

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
spec:
  defaultBackend:
    service:
      name: testsvc
      port:
        number: 80

nohost.yaml

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: name-virtual-host-ingress
spec:
  rules:
    - host: first.bar.com
      http:
        paths:
          - backend:
              service:
                name: testsvc1
                port:
                  number: 80
            pathType: exact
    - host: second.foo.com
      http:
        paths:
          - backend:
              service:
                name: testsvc2
                port:
                  number: 80
            pathType: exact
    # No host supplied here
    - http:
        paths:
          - backend:
              service:
                name: testsvc3
                port:
                  number: 80
            pathType: exact

rewrite.yaml

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-rewrite
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
    - http:
        paths:
          - path: /rewritepath
            pathType: Prefix
            backend:
              service:
                name: testsvc
                port:
                  number: 80

tls.yaml

---
apiVersion: v1
kind: Secret
metadata:
  name: ingress-tls-secret
data:
  # Data here as a placeholder - it's just a base64-encoded 'a'
  tls.crt: YQo=
  tls.key: YQo=
type: kubernetes.io/tls
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-tls
spec:
  tls:
    - hosts:
        - sslexample.foo.com
      secretName: ingress-tls-secret
  rules:
    - host: sslexample.foo.com
      http:
        paths:
          - path: /
            backend:
              service:
                name: testsvc1
                port:
                  number: 80
            pathType: exact

virtualhosting.yaml

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: name-virtual-host-ingress
spec:
  rules:
    - host: foo.bar.com
      http:
        paths:
          - backend:
              service:
                name: testsvc1
                port:
                  number: 80
            pathType: exact
    - host: bar.foo.com
      http:
        paths:
          - backend:
              service:
                name: testsvc2
                port:
                  number: 80
            pathType: exact

See: https://kubernetes.io/docs/concepts/services-networking/ingress/