hashicorp / consul

Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
https://www.consul.io
Other
28.31k stars 4.42k forks source link

Ingress gateway not working with IP #10592

Open ukreddy-erwin opened 3 years ago

ukreddy-erwin commented 3 years ago

I am trying to configure ingress gateway for consul deployed in aks.

As per their documentation , I have created a sample deployment and ingress gateway to it.

yaml files: github

kubectl apply -f static-app/ I changed the static app service from CluserIP to LoadBalancer and can get the page using http://

But, with ingress gateway, I can access only by adding the header as below. curl -H "Host: static-server.ingress.consul" "http://:8080"

if I try without header, it is not getting the page.

Any suggestion on how to make it work without header, so that I can utilize the same for my main application.

Once, it is deployed, I am able to see in the consul window and got the ip address of the ingress-gateway using

blake commented 3 years ago

Hi @ukreddy-erwin,

When an ingress gateway's listener is configured with a protocol of http, the HTTP Host header is normally required to be sent in request so that the gateway can route to the correct backend service. That requirement is documented on the hosts field under the ingress gateway configuration entry, and on the initial paragraphs in https://www.consul.io/docs/connect/gateways/ingress-gateway.

The exception is when the Hosts field contains a wildcard. This will match on any Host value, or in your case the absence of the Host header, and route those requests to the specified service.

apiVersion: consul.hashicorp.com/v1alpha1
kind: IngressGateway
metadata:
  name: ingress-gateway
spec:
  listeners:
    - port: 8080
      protocol: http
      services:
        - name: static-server
          hosts: ['*']

I hope this helps. Please let me know if you have any additional questions.

ukreddy-erwin commented 3 years ago

Thanks for the reply, it works. To be frank, the documentation is so round routed and complicated and hard to understand. Not any proper content available outside also for consul unlike other service mesh alternatives.

Is there any content you can guide for the beginners to start with?

And to this post, currently I have an application in kubernetes and to connect we use this approach. http://:/CustomApplication

I have installed consul related containers in the cluster and please guide me further steps to create a service mesh approach for this.

This app internally connects to database hosted in azure.And our cluster also in azure.