Sunday, July 24, 2022

Create kubernetes NodePort service using yaml

A NodePort is a kubernetes service type where an open port on every node of your cluster. Kubernetes transparently routes incoming traffic on the NodePort to your service, even if your application is running on a different node. The default range for the NodePort service ports are 30000-32767

Below is a sample nodeport service yaml file

       
# cat NodePort.yaml
apiVersion: v1
kind: Service
metadata:  
  name: my-nodeport-service
spec:
  selector:    
    app: my-app
  type: NodePort
  ports:  
  - name: http
    port: 80
    targetPort: 80
    nodePort: 30036
    protocol: TCP
Run following command to create NodePort service in your Kubernetes cluster
       
# kubectl apply -f NodePort.yaml

No comments:

Post a Comment

Create Kubernetes ClusterIP Service Definition using YAML

A ClusterIP service is the default Kubernetes service. It gives you a service inside your cluster that other apps/pods inside your cluster c...