skip to Main Content

I have two services running on k8s and I am using an ingress to access my services. One of the service requires access to another view env but I added the cluster IP and the port of the required service but it seems to be unaccessible.

User Deployment yaml

...
         - name: WALLET_SERVICE_URL
              value: 'http://10.103.xxx.xx:30611'
            - name: WALLET_SERVICE_API_VERSION
              value: /api/v1
...

my Ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: dev-ingress
  namespace: default
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /api/v1$uri
spec:
  ingressClassName: nginx
  rules:
    - host: demo.localdev.me
      http:
        paths:
          - path: /user
            pathType: Prefix
            backend:
              service:
                name: accounts-service
                port:
                  number: 80
          - path: /wallet
            pathType: Prefix
            backend:
              service:
                name: wallet-service
                port:
                  number: 80

Wallet service

apiVersion: v1
kind: Service
metadata:
  name: wallet-service
spec:
  selector:
    app: wallet-service
  ports:
    - port: 80
      targetPort: 3007
  type: NodePort

2

Answers


    1. Use ClusterIP for wallet-service. There’s no reason to use NodePort — the ingress controller will handle routing to the internal IP.

    2. Your value for the WALLET_SERVICE_URL should be pointing to your service by DNS name, using the port you define for your ClusterIP service. i.e. http://wallet-service:80.

    3. Unless wallet-service should be accessible outside of the cluster, you don’t need to configure ingress for it.

    Login or Signup to reply.
  1. Ingress are for traffic from outside of the cluster, for internal network you can use the dns name of your service, you can read more about service dns in the docs

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search