liveBook · Manning

Service IP

As explained in Road to Kubernetes

A cluster IP is the virtual IP address assigned to provide an internal network endpoint for a Kubernetes Service.

A service IP, or ClusterIP, is the internal virtual address assigned to a Kubernetes Service. Use it as the host value when connecting to that Service from within the cluster. section 8.4.3

Connect to a database Service

After entering a running Pod with kubectl exec and installing the psql client, run kubectl get service postgres-svc. Read the Cluster-IP value, such as 10.128.189.63, and use it to connect to the PostgreSQL Service from inside the cluster. section 8.4.3

Use a service IP with these practical limitations:

  • Treat the address as internal; a ClusterIP-type Service does not accept traffic from outside the cluster. section 8.6
  • Do not hard-code the address for durable configuration: Kubernetes provisions it dynamically, so its value is unpredictable. section 8.4.3
  • Prefer the Kubernetes built-in DNS Service when predictable Service addressing is needed. section 8.4.3
Figure 8.13 kubectl get service output

Inspect the Cluster-IP value returned by kubectl get service. section 8.4.3

How Road to Kubernetes covers it

How deep it goes
Explains retrieval and in-cluster use, then flags address unpredictability without detailing forwarding internals.
Examples
Uses kubectl get service postgres-svc to obtain an address for an in-cluster psql connection.
What it assumes
Assumes a running Kubernetes cluster, a Service, and an in-cluster Pod with a client such as psql.
What you can do after
Apply it via kubectl and an in-cluster psql client to reach a database Service.
How it connects
Connects Kubernetes Services with Pods, container-to-container communication, and built-in DNS.

Also explained in

Compare how 3 books explain service IP →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Road to Kubernetes. The section links point to the parts of the book it draws on.