Difference between revisions of "Kind: Ingress"

From wikieduonline
Jump to navigation Jump to search
 
(76 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Draft}}
 
 
{{lowercase}}
 
{{lowercase}}
 +
[[v1.19]] (Aug 2020, as of Jul 2024 has been superseded by <code>[[kind: Gateway]]</code>)
 +
 +
* https://kubernetes.io/docs/concepts/services-networking/ingress/
 
* https://kind.sigs.k8s.io/docs/user/ingress/
 
* https://kind.sigs.k8s.io/docs/user/ingress/
 +
* https://docs.okd.io/latest/rest_api/network_apis/ingress-networking-k8s-io-v1.html
 +
* <code>[[helm install my-release ingress-nginx/ingress-nginx]]</code>
 +
* <code>[[minikube addons enable ingress]]</code>
 +
* <code>[[spec.rules.host]]</code>
 +
* <code>rules: [  [[http:]] | [[hosts:]] ]</code>
 +
 +
*  <code>[[acme.cert-manager.io/http01-edit-in-place]]: "true"</code>
 +
 +
== Official examples ==
 +
{{kind: Ingress example}}
 +
 +
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
 +
 +
[[TLS]]
 +
 +
{{kind: ingress tls official}}
 +
 +
== Examples ==
 +
=== with tls and issuer annotation for [[cert-manager]] ===
 +
 +
{{kind: Ingress tls and annotation}}
 +
 +
=== With tls ===
 +
{{kind: ingress tls}}
  
  
  apiVersion: extensions/v1beta1
+
  .../...
 +
  status:
 +
    [[loadBalancer:]]
 +
      ingress:
 +
      - hostname: a324242432.elb.ap-southeast-1.amazonaws.com
 +
  .../...
 +
 
 +
 
 +
  [[apiVersion]]: [[extensions/]]v1beta1
 
  [[kind:]] Ingress
 
  [[kind:]] Ingress
 
  [[metadata:]]
 
  [[metadata:]]
 
   name: foobar
 
   name: foobar
 
  [[spec:]]
 
  [[spec:]]
   rules:
+
   [[rules:]]
 
   - host: foobar.example.com
 
   - host: foobar.example.com
 
     http:
 
     http:
 
       paths:
 
       paths:
 
       - backend:
 
       - backend:
           serviceName: foo
+
           [[serviceName]]: foo
 
           servicePort: 8080
 
           servicePort: 8080
 
         path: /
 
         path: /
  
[[helm install my-release ingress-nginx/ingress-nginx]]
 
  
  apiVersion: networking.k8s.io/v1beta1
+
=== [[AKS]] ===
 +
{{webapprouting.kubernetes.azure.com ex}}
 +
 
 +
== Errors ==
 +
  apiVersion: [[networking.k8s.io/v1]]
 
  kind: Ingress
 
  kind: Ingress
 
  metadata:
 
  metadata:
 
   annotations:
 
   annotations:
     kubernetes.io/ingress.class: nginx
+
     [[kubernetes.io/ingress.class]]: nginx
 
   name: example
 
   name: example
 
   namespace: foo
 
   namespace: foo
Line 36: Line 97:
 
               servicePort: 80
 
               servicePort: 80
 
             path: /
 
             path: /
  # This section is only required if TLS is to be enabled for the Ingress
 
  tls:
 
      - hosts:
 
          - www.example.com
 
        [[secretName:]] example-tls
 
  
 +
Error from server (BadRequest): error when creating "ingress.yaml": [[Ingress in version "v1" cannot be handled as a Ingress: [[strict decoding error]]: unknown field "[[spec.rules]] [0].http.paths[0].backend.[[serviceName]]", unknown field "spec.rules[0].http.paths[0].backend.servicePort"
 +
 +
The Ingress "youingress" is invalid: [[spec.rules]][0].http.paths[0].backend: Required value: port name or number is required
 +
 +
[[Warning  AddedOrUpdatedWithWarning  3s    nginx-ingress-controller  Configuration for default/your-app was added or updated ; with warning(s): TLS secret your-app is invalid: secret doesn't exist or of an unsupported type]]
 +
 +
== Errors ==
 +
{{error validating ingress.yaml}}
  
 
== Related terms ==
 
== Related terms ==
 
* [[Kubernetes: Ingress controllers]]
 
* [[Kubernetes: Ingress controllers]]
* <code>[[kubectl get ingress]]</code>
+
* <code>[[kubectl get ingress]], [[kubectl describe ingress]]</code>
 
* <code>[[kind: ConfigMap]]</code>
 
* <code>[[kind: ConfigMap]]</code>
 
* <code>[[kind: IngressClass]]</code>
 
* <code>[[kind: IngressClass]]</code>
 +
* <code>[[pathType:]] [[ImplementationSpecific]]</code>
 +
* <code>[[field.cattle.io/publicEndpoints]]</code>
 +
* <code>[[cattle.io/creator: norman]]</code>
 +
* <code>[[.local]]</code>
 +
* <code>[[Address:]]</code>
 +
* <code>[[kubectl apply -f ingress.yaml]]</code>
 +
* <code>[[Ingress-nginx-controller ConfigMap]]</code>
 +
* <code>[[IngressSpec.spec.tls]]</code>
 +
* <code>[[labels:]]</code>
 +
* <code>[[kubectl expose deployment]]</code>
  
 
== See also ==
 
== See also ==
* {{kind}}
+
* {{kind: Ingress}}
 +
* {{networking.k8s.io}}
 +
* {{kubectl ingress}}
 
* {{Ingress}}
 
* {{Ingress}}
  
 
[[Category:K8s]]
 
[[Category:K8s]]

Latest revision as of 06:25, 23 July 2024

v1.19 (Aug 2020, as of Jul 2024 has been superseded by kind: Gateway)

Official examples[edit]

 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

TLS

 apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: tls-example-ingress
spec:
  tls:
  - hosts:
      - https-example.foo.com
    secretName: testsecret-tls
  rules:
  - host: https-example.foo.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: service1
            port:
              number: 80

Examples[edit]

with tls and issuer annotation for cert-manager[edit]

 apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: kuard
  annotations:
    cert-manager.io/issuer: "letsencrypt-staging"

spec:
  ingressClassName: nginx
  tls:
  - hosts:
    - example.example.com
    secretName: quickstart-example-tls
  rules:
  - host: example.example.com
    http:
      paths:
       - path: /
         pathType: Prefix
         backend:
           service:
             name: kuard
            port:
              number: 80

With tls[edit]

 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: /


AKS[edit]

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: aks-helloworld
  namespace: hello-web-app-routing
spec:
  ingressClassName: webapprouting.kubernetes.azure.com
  rules:
  - host: <Hostname>
    http:
      paths:
      - backend:
          service:
           name: aks-helloworld
           port:
             number: 80
        path: /
        pathType: Prefix

Errors[edit]

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: /
Error from server (BadRequest): error when creating "ingress.yaml": [[Ingress in version "v1" cannot be handled as a Ingress: strict decoding error: unknown field "spec.rules [0].http.paths[0].backend.serviceName", unknown field "spec.rules[0].http.paths[0].backend.servicePort"
The Ingress "youingress" is invalid: spec.rules[0].http.paths[0].backend: Required value: port name or number is required
Warning  AddedOrUpdatedWithWarning  3s    nginx-ingress-controller  Configuration for default/your-app was added or updated ; with warning(s): TLS secret your-app is invalid: secret doesn't exist or of an unsupported type

Errors[edit]

 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[edit]

See also[edit]

Advertising: