Difference between revisions of "Kind: Ingress"

From wikieduonline
Jump to navigation Jump to search
Line 57: Line 57:
  
 
== Examples ==
 
== Examples ==
 
apiVersion: [[networking.k8s.io/v1]]
 
kind: Ingress
 
metadata:
 
  annotations:
 
    [[kubernetes.io/ingress.class]]: nginx
 
  name: example
 
  namespace: foo
 
spec:
 
  rules:
 
    - host: www.example.com
 
      http:
 
        paths:
 
          - backend:
 
              serviceName: exampleService
 
              servicePort: 80
 
            path: /
 
 
 
 
 
  apiVersion: [[networking.k8s.io/v1beta1]]
 
  apiVersion: [[networking.k8s.io/v1beta1]]
 
  kind: Ingress
 
  kind: Ingress
Line 121: Line 101:
 
           servicePort: 8080
 
           servicePort: 8080
 
         path: /
 
         path: /
 +
 +
 +
== Errors ==
 +
apiVersion: [[networking.k8s.io/v1]]
 +
kind: Ingress
 +
metadata:
 +
  annotations:
 +
    [[kubernetes.io/ingress.class]]: nginx
 +
  name: example
 +
  namespace: foo
 +
spec:
 +
  rules:
 +
    - host: www.example.com
 +
      http:
 +
        paths:
 +
          - backend:
 +
              serviceName: exampleService
 +
              servicePort: 80
 +
            path: /
  
 
== Errors ==
 
== Errors ==

Revision as of 12:12, 6 February 2024

v1.19 (Aug 2020)

Official examples

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: minimal-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: nginx-example
  rules:
  - http:
      paths:
      - path: /testpath
        pathType: Prefix
        backend:
          service:
            name: test
            port:
              number: 80
https://kind.sigs.k8s.io/docs/user/ingress/
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  rules:
  - http:
      paths:
      - pathType: Prefix
        path: /foo(/|$)(.*)
        backend:
          service:
            name: foo-service
            port:
              number: 8080
      - pathType: Prefix
        path: /bar(/|$)(.*)
        backend:
          service:
            name: bar-service
            port:
              number: 8080

Examples

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
  name: example
  namespace: foo
spec:
  rules:
    - host: www.example.com
      http:
        paths:
          - backend:
              serviceName: exampleService
              servicePort: 80
            path: /
  # This section is only required if TLS is to be enabled for the Ingress
  tls:
      - hosts:
          - www.example.com
        secretName: example-tls


 .../...
 status:
   loadBalancer:
     ingress:
     - hostname: a324242432.elb.ap-southeast-1.amazonaws.com
 .../...


apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: foobar
spec:
  rules:
  - host: foobar.example.com
    http:
      paths:
      - backend:
          serviceName: foo
          servicePort: 8080
        path: /


Errors

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
  name: example
  namespace: foo
spec:
  rules:
    - host: www.example.com
      http:
        paths:
          - backend:
              serviceName: exampleService
              servicePort: 80
            path: /

Errors

 error: error validating "ingress.yaml": error validating data: [ValidationError(Ingress.spec.rules[0].http.paths[0].backend): unknown field "serviceName" in io.k8s.api.networking.v1.IngressBackend, ValidationError(Ingress.spec.rules[0].http.paths[0].backend): unknown field "servicePort" in io.k8s.api.networking.v1.IngressBackend]; if you choose to ignore these errors, turn validation off with --validate=false
error: error parsing ingress.yaml: error converting YAML to JSON: yaml: line 16: mapping values are not allowed in this context
The Ingress "youingress" is invalid: spec.rules[0].http.paths[0].backend: Required value: port name or number is required
Warning  Rejected  31s   nginx-ingress-controller  spec.rules(0).host: Required value

Related terms

See also

Advertising: