A
A
Anton2021-10-20 12:41:00
Kubernetes
Anton, 2021-10-20 12:41:00

How to make a separate path for each service in k8s within one host?

There are kubernetes. There is 1 external host or another domain.
Kubernetes has different typical applications installed.

helm install ghost --set service.type=ClusterIP bitnami/ghost
helm install drupal --set service.type=ClusterIP bitnami/drupal
helm install tomcat --set service.type=ClusterIP bitnami/tomcat
helm install dokuwiki --set service.type=ClusterIP bitnami/dokuwiki
helm install redmine --set service.type=ClusterIP bitnami/redmine

If we make a port-forward to the service, then it will open and we will see a working application.

How to make a separate path for each service in k8s within one host?

I took an example ingress yaml and added existing services there

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: myingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
  - host: apatsev.178.154.235.82.sslip.io
    http:
      paths:
      - backend:
          serviceName: dokuwiki
          servicePort: 80
        path: /dokuwiki(/|$)(.*)
      - backend:
          serviceName: drupal
          servicePort: 80
        path: /drupal/(.*)
      - backend:
          serviceName: ghost
          servicePort: 80
        path: /ghost/(.*)
      - backend:
          serviceName: redmine
          servicePort: 80
        path: /redmine/(.*)
      - backend:
          serviceName: tomcat
          servicePort: 80
        path: /tomcat/(.*)


While looking for examples in these posts
https://medium.com/ww-engineering/kubernetes-nginx...
https://kubernetes.github.io/ingress-nginx/example...

Tell me which ingress config options look?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2021-10-20
Patsev @chemtech

The config is valid. If it does not work, you need to go to Development Tools and see the errors. Most likely the links are absolute. And you need to make it relative.

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: myingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
  - host: apatsev.178.154.235.82.sslip.io
    http:
      paths:
      - backend:
          serviceName: dokuwiki
          servicePort: 80
        path: /dokuwiki(/|$)(.*)
      - backend:
          serviceName: drupal
          servicePort: 80
        path: /drupal/(.*)
      - backend:
          serviceName: ghost
          servicePort: 80
        path: /ghost/(.*)
      - backend:
          serviceName: redmine
          servicePort: 80
        path: /redmine/(.*)
      - backend:
          serviceName: tomcat
          servicePort: 80
        path: /tomcat/(.*)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question