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

前端 未结 2 382
-上瘾入骨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:48

    Try these manifests and remember to deploy an Ingress Controller (I usually use traefik, here some instructions to set it)

    service.yml: I changed NodePort to ClusterIP (the default, you can remove the line)

    apiVersion: v1
    kind: Service
    metadata:
      name: auth
    spec:
      selector:
        app: auth
        tier: backend
      ports:
        - protocol: TCP
          port: 3000
          targetPort: auth
      type: ClusterIP
    

    ingress.yml: (I set port to 3000, your service port)

    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
      name: test-ingress
    spec:
      backend:
        serviceName: auth
        servicePort: 3000
    

提交回复
热议问题