NodePort

Contents

    Documentation

    Exposes a container to the outside world.
    Provides a ClusterIP + opens a port (node port) on all the cluster nodes to contact the service from the outside.

    Node port creation

    Configuration file

    apiVersion: v1
    kind: Service
    metadata:
      name: client-node-port
    spec:
      type: NodePort
      selector:
        component: web
      ports:
        - port: 3050
          targetPort: 3000
          nodePort: 31512
    

    Note: here, the service does NOT reference the deployment. Only the pods, thanks to a selector.

    kubectl

    kubectl expose deployment <deployment-name> --name=<new-service-name> --type=NodePort --target-port 3000 --port 3050 --node-port 3000

    Note: here, the deployment referenced. It's selector is used to construct the service.


    Attachments

    Proudly Powered by Zim 0.75.2.

    Template by Etienne Gandrille, based on ZeroFiveEight and using JQuery Toc Plugin.