Debug School

Yashin Jalal
Yashin Jalal

Posted on

Kubernetes training -SVC

What is Service?
Service is a kubernetes resource which allows to direct network traffic to pods. Service can also load balance traffic across multiple pods.

There are three types of Services:
CluseterIp : Default
NodePort
LoadBalancer

Why do we need it?
Since pods are ephemeral, it may be created and removed by Deployments, to preserve connection to the nodes, we can use services. Also, NodePort service helps to route traffic from external client through a port in the node.

How it works?
ClusterIp creates a cluster specific service, pods can use the service endpoint to send data to other pods. ClusterIp selects the target pods using the Labels specified in selector configuration. All pods matching the labels in selector will be managed by a Service.

Nodeport exposes the service via an external port in all Nodes.

Load Balancer works in cloud services it creates an external ip using the cloud load balancing capabilities in addition to the service functionality.

Commands

kubectl create svc clusterip svc-name port:targetPort
kubectl create svc nodeport svc-name port:nodeport

Top comments (0)