0

I have installed Kubernetes on bare metal and figured out, how to use Ingress and route hosts to my service.

But when I use same configuration for different host, I get default backend - 404.

Working configuration:

apiVersion: v1
kind: Namespace
metadata:
    name: k8s-mariyo-host-1-sk-node-hello-world

---

apiVersion: v1
kind: Service
metadata:
    namespace: k8s-mariyo-host-1-sk-node-hello-world
    name: node-hello-world
    labels:
        app: node-hello-world
spec:
    ports:
        -   port: 80
            targetPort: 8080
    selector:
        app: node-hello-world

---

apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
    namespace: k8s-mariyo-host-1-sk-node-hello-world
    name: node-hello-world
spec:
    selector:
        matchLabels:
            app: node-hello-world
    strategy:
        type: Recreate
    template:
        metadata:
            namespace: k8s-mariyo-host-1-sk-node-hello-world
            labels:
                app: node-hello-world
        spec:
            containers:
                -   image: 10.100.100.1:5000/local-node-hello-world:1.5
                    name: hello-world
                    ports:
                        -   containerPort: 8080
                            name: hello-world

---

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
    namespace: k8s-mariyo-host-1-sk-node-hello-world
    name: node-hello-world
spec:
    rules:
        -   host: "node-hello-world.host-1.sk"
            http:
                paths:
                    -   path: /
                        backend:
                            serviceName: node-hello-world
                            servicePort: 80

default backend - 404 configuration:

apiVersion: v1
kind: Namespace
metadata:
    name: k8s-mariyo-host-2-sk-k8s

---

apiVersion: v1
kind: Service
metadata:
    namespace: k8s-mariyo-host-2-sk-k8s
    name: k8s
    labels:
        app: k8s
spec:
    ports:
        -   port: 80
            targetPort: 8080
    selector:
        app: k8s

---

apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
    namespace: k8s-mariyo-host-2-sk-k8s
    name: k8s
spec:
    selector:
        matchLabels:
            app: k8s
    strategy:
        type: Recreate
    template:
        metadata:
            namespace: k8s-mariyo-host-2-sk-k8s
            labels:
                app: k8s
        spec:
            containers:
                -   image: 10.100.100.1:5000/local-node-hello-world:1.5
                    name: k8s-hello
                    ports:
                        -   containerPort: 8080
                            name: k8s-hello

---

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
    namespace: k8s-mariyo-host-2-sk-k8s
    name: k8s
spec:
    rules:
        -   host: "k8s.host-2.sk"
            http:
                paths:
                    -   path: /
                        backend:
                            serviceName: k8s
                            servicePort: 80

Can anybody see what could couse strange/different behaviour of almost simillar configurations? Here is link to diff: https://www.diffchecker.com/9AlnFQGz

old_timer
  • 69,149
  • 8
  • 89
  • 168
Mariyo
  • 486
  • 7
  • 15
  • 1
    Can you include the output of `curl -vH 'host: k8s.host-2.sk' http://${the_name_of_your_ingress_host}:80` (or you can use the ingress controller's NodePort and any Node IP) – mdaniel Feb 03 '19 at 04:28
  • You will also want to grab a copy of the nginx.conf from any one of the ingress controller Pods via `kubectl cp ${ingress_controller_pod}:/etc/nginx/nginx.conf .` (assuming, of course, that you're using the kubernetes nginx ingress) – mdaniel Feb 03 '19 at 04:29
  • Thank you for proposals, they helped me figured out, that it was CloudFlare SSL issue, I had `Full` mode but my configuration works on `Flexible` mode. – Mariyo Feb 03 '19 at 07:55

1 Answers1

0

As @Mariyo mentioned in the comments, seems the problem was with Cloudflare SSL configuration; in the scenario where your web site does not hold any SSL certificate and you consider using secure connection only with web users and Cloudflare but not with web serve. Then, you might choose Flexible SSL mode instead of Full SSL Strict mode. Answer has been provided for any further contributors research.

Black_Bacardi
  • 324
  • 4
  • 10
Nick_Kh
  • 5,089
  • 2
  • 10
  • 16