Score:0

When and How we should specify "clusterIP" inside the "service.yaml" file?

pl flag

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?

Score:1
mc flag

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

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.