Defining Rules per Host
Learn how we can serve our services in different hosts.
We'll cover the following...
Serving services in different hosts
So that’s nice! Now we can direct requests to the service we want based on the path we receive, such as /
to nginx
, /hello
to hellok8s
.
In practice, though, we usually will want to serve our services in different hosts. For example, we could want to serve nginx
in http://nginx.example.com
and hellok8s
in http://hello.example.com
.
Let’s see how we can change this Ingress
to do that.
Press + to interact
apiVersion: networking.k8s.io/v1kind: Ingressmetadata:name: hello-ingressannotations:# We are defining this annotation to prevent nginx# from redirecting requests to `https` for nownginx.ingress.kubernetes.io/ssl-redirect: "false"spec:rules:- host: nginx.local.comhttp:paths:- path: /pathType: Prefixbackend:service:name: nginx-svcport:number: 1234- host: hello.local.comhttp:paths:- path: /pathType: Prefixbackend:service:name: hellok8s-svcport:number: 4567
It’s pretty much the same ...
Access this course and 1400+ top-rated courses and projects.