Ali Ilman
Ali Ilman

Ali Ilman

What is the Kubernetes Service Object

What is the Kubernetes Service Object

The purpose of a Service is to set up networking in a Kubernetes cluster.

There are four types of Services.

  1. ClusterIP
  2. NodePort - Mostly used for development purposes
  3. LoadBalancer
  4. Ingress

Here's a sample Service config file.

apiVersion: v1
kind: Service
metadata:
  name: client-node-port
spec:
  # Specifying the type of Service
  type: NodePort

  # An array of ports
  ports:
      # port specifies the port that other pods can access to
    - port: 3000
      # targetPort specifies the port being used for a container
      targetPort: 8080
      # nodePort specifies the port mapped to the targetPort
      nodePort: 4000

  # selector will basically look for Pods that have a matching key-value pair.
  # Pods that meet the criteria will use client-node-port as their Service.
  selector:
    component: web

Resources

 
Share this