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
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.