Sobes.tech
Middle

What is a service in Kubernetes?

sobes.tech AI

Answer from AI

In Kubernetes, a Service is an abstraction that defines a logical set of Pods and a policy by which to access them. The Service provides a stable IP address and DNS name for accessing the group of Pods, even though the Pods themselves can be created and deleted dynamically.

Main types of services:

  • ClusterIP — access to the service only within the cluster.
  • NodePort — opens a port on each node for external access.
  • LoadBalancer — integrates with an external load balancer.
  • ExternalName — redirects to an external DNS address.

Example of a service manifest:

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: MyApp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 9376
  type: ClusterIP

Thus, a Service in Kubernetes allows abstracting access to Pods and managing traffic routing inside and outside the cluster.