Nodeport service is not showing the application, coming up with page cant reach

sns 9,241 Reputation points
2023-01-11T12:44:26.8933333+00:00

Nodeport service is not showing the application, coming up with page cant reach, where as it worked when I changed the type to "Loadbalncer" in the YAML file. Please suggest.

User's image

Below is the nodeport IP , am I doing something wrong?

User's image

Please suggest.

Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,221 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Adrian Dobrescu 266 Reputation points Microsoft Employee
    2023-01-11T13:00:41.8066667+00:00

    Hello @sns
    When you declare a service as NodePort exposes the Service on each Node’s IP at the NodePort (a fixed port for that Service, in the default range of 30000-32767). You can then access the Service from outside the cluster by requesting **<NodeIp>:<NodePort>.
    **
    For example you have the following service definition:

    apiVersion: v1
    kind: Service
    metadata:
      name: my-service
    spec:
      type: NodePort
      selector:
        app.kubernetes.io/name: MyApp
      ports:
          # By default and for convenience, the 
        - port: 80
          targetPort: 80
          # Optional field
          # By default and for convenience, the Kubernetes control plane will allocate a port from a range (default: 30000-32767)
          nodePort:30007 
    
    ---
    
    
    

    This Service is visible as <NodeIP>:spec.ports[*].nodePort

    You can find more information in the official k8s doc: [https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
    Hope this helps.

    Please "Accept as Answer" if it helped and Upvote, so that it can help others in the community looking for help on similar topics.
    Thank you!

    0 comments No comments

  2. Adrian Dobrescu 266 Reputation points Microsoft Employee
    2023-01-11T13:15:45.1566667+00:00

    Hello @SNS Admin (SNS) ,

    When you declare a service as NodePort exposes the Service on each Node’s IP at the NodePort (a fixed port for that Service, in the default range of 30000-32767). You can then access the Service from outside the cluster by requesting <NodeIp>:<NodePort>.

    Please check the following example with service definition file:

    apiVersion: v1
    kind: Service
    metadata:
      name: my-service
    spec:
      type: NodePort
      selector:
        app.kubernetes.io/name: MyApp
      ports:
          # By default and for convenience, the `targetPort` is set to the same value as the `port` field.
        - port: 80
          targetPort: 80
          # Optional field
          # By default and for convenience, the Kubernetes control plane will allocate a port from a range (default: 30000-32767)
          nodePort: 30007
    
    

    This Service is visible as <NodeIP>:spec.ports[*].nodePort, hence <NodeIP>:30007

    You can find more information in the official k8s doc: [https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport

    Hope it helps.

    Please "Accept as Answer" if it helped and Upvote, so that it can help others in the community looking for help on similar topics.

    Thank you

    0 comments No comments

  3. Eddie Neto 1,231 Reputation points Microsoft Employee
    2023-01-11T13:35:58.3066667+00:00

    Hi @SNS Admin (SNS) ,

    Looks like you are missing to do the "kubectl port-forward <pod name> 80" or "kubectl port-forward <pod name> 32285:80"

    Hope this helps. Please "Accept as Answer" if it helped, so that it can help others in the community looking for help on similar topics.

    User's image

    User's image

    User's image

    User's image


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.