Kubernetes: expose multiple containers using service and ingress with static ip Kubernetes: expose multiple containers using service and ingress with static ip kubernetes kubernetes

Kubernetes: expose multiple containers using service and ingress with static ip


You can't have a single service port send traffic to two different target ports. There must be two different ports on your service (or use two separate services).Then you should have two paths in your ingress that route to the appropriate service port.

You need to do something like this...

apiVersion: v1kind: Servicemetadata:  name: service-kubespec:  type: LoadBalancer  ports:    - targetPort: service1-port      port: 81      protocol: TCP    - targetPort: service2-port      port: 82      protocol: TCP  selector:    app: service-backend1
apiVersion: extensions/v1beta1kind: Ingressmetadata:  labels:    app: service-backend1  name: ingress-kube  annotations:    kubernetes.io/ingress.global-static-ip-name: app-static-ipspec:  tls:  - hosts:    - custom-host.com    secretName: custom-host-secret-name  rules:  - host: custom-host.com    http:      paths:      - backend:          serviceName: service-kube          servicePort: 81        path: /api      - backend:          serviceName: service-kube          servicePort: 82        path: /