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.
A deployment will define the desired state and create a ReplicaSet. Here we are defining the container image we will use as well as
memory limits among other things.
apiVersion: apps/v1kind: Deploymentmetadata:name: goofspec:replicas: 1selector:matchLabels:app: gooftier: frontendtemplate:metadata:labels:app: gooftier: frontendspec:containers:- name: goofimage: DOCKER_IMAGE_NAMEresources:requests:cpu: 100mmemory: 100Miports:- containerPort: 3001- containerPort: 9229env:- name: DOCKERvalue: "1"---apiVersion: apps/v1kind: Deploymentmetadata:name: goof-mongospec:replicas: 1selector:matchLabels:app: gooftier: backendtemplate:metadata:labels:app: gooftier: backendspec:containers:- name: goof-mongoimage: mongoports:- containerPort: 27017
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.
apiVersion: v1kind: Servicemetadata:name: goofspec:type: LoadBalancerports:- protocol: TCPport: 80targetPort: 3001name: "http"- protocol: TCPport: 9229targetPort: 9229name: "debug"selector:app: gooftier: frontend---apiVersion: v1kind: Servicemetadata:name: goof-mongospec:ports:- protocol: TCPport: 27017targetPort: 27017name: "mongo"selector:app: gooftier: backend