...

>

Creating the Split API Pods

Creating the Split API Pods

In this lesson, we will create API Pods using ReplicaSet and establish communication by creating Service.

Looking into the Definition

Moving to the backend API…

Shell
cat svc/go-demo-2-api-rs.yml

The output is as follows.

Shell
apiVersion: apps/v1beta2
kind: ReplicaSet
metadata:
name: go-demo-2-api
spec:
replicas: 3
selector:
matchLabels:
type: api
service: go-demo-2
template:
metadata:
labels:
type: api
service: go-demo-2
language: go
spec:
containers:
- name: api
image: vfarcic/go-demo-2
env:
- name: DB
value: go-demo-2-db
readinessProbe:
httpGet:
path: /demo/hello
port: 8080
periodSeconds: 1
livenessProbe:
httpGet:
path: /demo/hello
port: 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 to 3. 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 ...

Access this course and 1600+ top-rated courses and projects.