Splitting the Pod and Establishing Communication through Services
In this lesson, we will split up the Pods, create a separate DB pod and a Service to communicate with it.
Looking into the Definition
Let’s take a look at a ReplicaSet definition for a Pod with only the database.
cat svc/go-demo-2-db-rs.yml
The output is as follows.
apiVersion: apps/v1beta2kind: ReplicaSetmetadata:name: go-demo-2-dbspec:selector:matchLabels:type: dbservice: go-demo-2template:metadata:labels:type: dbservice: go-demo-2vendor: MongoLabsspec:containers:- name: dbimage: mongo:3.3ports:- containerPort: 28017
We’ll comment only on the things that changed.
Since this ReplicaSet defines only the database, we reduced the number of replicas to 1. Truth be told, MongoDB should be scaled as well, but that’s out of the scope ...
Access this course and 1600+ top-rated courses and projects.