Kubernetes manifests
To simply the deployment of our application, we have provided two configuration files which will create the necessary resources to run our application. These two files will consist of a Deployment and a Service and are available in the ./deployment directory of the accompanying GitHub repository. Let's take a look at what's in each of these configuration files.

Deployment

A deployment will define the desired state and create a ReplicaSet. Here we are defining the container image we will use as well as cpu and memory limits among other things.
1
apiVersion: apps/v1
2
kind: Deployment
3
metadata:
4
name: goof
5
spec:
6
replicas: 1
7
selector:
8
matchLabels:
9
app: goof
10
tier: frontend
11
template:
12
metadata:
13
labels:
14
app: goof
15
tier: frontend
16
spec:
17
containers:
18
- name: goof
19
image: DOCKER_IMAGE_NAME
20
resources:
21
requests:
22
cpu: 100m
23
memory: 100Mi
24
ports:
25
- containerPort: 3001
26
- containerPort: 9229
27
env:
28
- name: DOCKER
29
value: "1"
30
---
31
apiVersion: apps/v1
32
kind: Deployment
33
metadata:
34
name: goof-mongo
35
spec:
36
replicas: 1
37
selector:
38
matchLabels:
39
app: goof
40
tier: backend
41
template:
42
metadata:
43
labels:
44
app: goof
45
tier: backend
46
spec:
47
containers:
48
- name: goof-mongo
49
image: mongo
50
ports:
51
- containerPort: 27017
Copied!

Service

A service is an abstraction for exposing an application running on a set of Pods as a network service. Here, we are defining a two-tier application that consists of a frontend which is our goof application s well as a backend which in our case will be a mongodb container image.
1
apiVersion: v1
2
kind: Service
3
metadata:
4
name: goof
5
spec:
6
type: LoadBalancer
7
ports:
8
- protocol: TCP
9
port: 80
10
targetPort: 3001
11
name: "http"
12
- protocol: TCP
13
port: 9229
14
targetPort: 9229
15
name: "debug"
16
selector:
17
app: goof
18
tier: frontend
19
---
20
apiVersion: v1
21
kind: Service
22
metadata:
23
name: goof-mongo
24
spec:
25
ports:
26
- protocol: TCP
27
port: 27017
28
targetPort: 27017
29
name: "mongo"
30
selector:
31
app: goof
32
tier: backend
Copied!
Last modified 2d ago
Export as PDF
Copy link
Edit on GitHub