Ingress and Ingress controller how to use them with NodePort Services?

前端 未结 2 379
-上瘾入骨i
-上瘾入骨i 2021-01-21 02:00

I have a single service running on a NodePort service. How do i use ingress to access multiple services.

deployment.yml

apiVersion: apps/v1
kind: Deplo         


        
2条回答
  •  伪装坚强ぢ
    2021-01-21 02:54

    Your service is running in port 3000 but your Ingress routing rule is matching to port 8080. It will probably work if you just change the servicePort to 3000 in the backend section of your Ingress resource definition.

    I'd suggest making sure it works with NodePort first before trying Ingress. I suggest this because I notice your Service only specifies values for port and targetPort but not nodePort. If you do not specify a nodeport value, you will get a random port number. As you want to use ingress with NodePort service type, the random port number should not matter.

    For NodePort tutorials you could start with https://medium.com/@markgituma/kubernetes-local-to-production-with-django-2-docker-and-minikube-ba843d858817 as I notice you've tagged your post with django

    For nginx ingress you could see https://cloud.google.com/community/tutorials/nginx-ingress-gke but you might want to find something specific to your cloud platform if you're not using gke

    It is best to start with one service but to understand how this can work for multiple services you could have a look at the fanout ingress example in the docs https://kubernetes.io/docs/concepts/services-networking/ingress/#simple-fanout

提交回复
热议问题