Creating the Split API Pods
Learn to create API Pods using ReplicaSet and establish communication by creating a Service.
Looking into the definition
Let’s see the definition of the backend API go-demo-2-api-rs.yml
.
Press + to interact
apiVersion: apps/v1kind: ReplicaSetmetadata:name: go-demo-2-apispec:replicas: 3selector:matchLabels:type: apiservice: go-demo-2template:metadata:labels:type: apiservice: go-demo-2language: gospec:containers:- name: apiimage: vfarcic/go-demo-2env:- name: DBvalue: go-demo-2-dbreadinessProbe:httpGet:path: /demo/helloport: 8080periodSeconds: 1livenessProbe:httpGet:path: /demo/helloport: 8080
Just as with the database, this ReplicaSet should be familiar since it’s very similar to the one we used before. We’ll comment only on the differences.
-
Line 6: The number of
replicas
is set to3
. That solves one of the main problems we had with the previous ReplicaSets that defined Pods with both containers. Now the number of replicas can differ, and we have one Pod for the database, and three for the backend API. -
Line 14: In the
labels
section,type
label is set toapi
so that both the ReplicaSet and the (soon to come) Service can ...
Access this course and 1400+ top-rated courses and projects.