0

I tried to deploy mysql and cassandra databases using kubernetes.io/docs instructions. In both of them, within the service.yaml files, they use clusterIP: None like following:

For cassandra:

apiVersion: v1
kind: Service
metadata:
  labels:
    app: cassandra
  name: cassandra
spec:
  ports:
  - port: 9042
  selector:
    app: cassandra
  clusterIP: None

For mysql:

apiVersion: v1
kind: Service
metadata:
  name: mysql
spec:
  ports:
  - port: 3306
  selector:
    app: mysql
  clusterIP: None

I would like to know, why they don't specify clusterIP in the service.yaml file? How should we specify it and what would be the use cases?

best_of_man
  • 367
  • 1
  • 3
  • 12

1 Answers1

1

Here you are using headless service. Whenever the clusterIP is set to none that means that it is a headless service. StatefulSets currently require a Headless Service to be responsible for the network identity of the Pods. Because unlike the stateless deployments the statefulset pods will have Stable, unique network identifiers(pod names).

To answer your question we don't set clusterIP in the case of headless service. We need to set it as none. So the service will use the unique identifier(DNS lookups) of a statefulset pods and assign IP on its own at the time of communication.

To know more in detail with example you can refer to this offical k8 document