Answers
Here are the answers to this chapter’s questions:
- Assuming we have a Docker image in a registry for the two application services – the web API and MongoDB – we need to do the following:
- Define a deployment for MongoDB using a
StatefulSet
object; let’s call this deploymentdb-deployment
. TheStatefulSet
object should have one replica (replicating MongoDB is a bit more involved and is outside the scope of this book). - Define a Kubernetes service called
db
of theClusterIP
type fordb-deployment
. - Define a deployment for the web API; let’s call it
web-deployment
. - Let’s scale this service to three instances.
- Define a Kubernetes service called
api
of theNodePort
type forweb-deployment
. - If we are using secrets, then define those secrets directly in the cluster using
kubectl
. - Deploy the application using
kubectl
.
- Define a deployment for MongoDB using a
- Liveness and readiness probes are health checks provided by Kubernetes for containers. A liveness probe checks whether a container...