ClusterIP is the default Service type. It exposes the Service on a cluster-internal IP. Pods in the cluster could reach the Service via the IP address, environment variables, or DNS. In the following example, we'll learn how to use both native Service environment variables and DNS to access the pods behind Services in the cluster.

Before starting a Service, we'd like to create two sets of RS with different version labels, as follows:

// create RS 1 with nginx 1.12.0 version# cat 3-2-3_rs1.yamlapiVersion: apps/v1kind: ReplicaSetmetadata:  name: nginx-1.12spec:  replicas: 2  selector:    matchLabels:      project: chapter3      service: web      version: "0.1"   template:    metadata:      name: nginx      labels:        project: chapter3        service: web        version: "0.1" spec: ...

Get DevOps with Kubernetes - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.