PostgreSQL database is deployed as a statefulset kuebernetes object. StatefulSet is used to manage stateful applications with persistent storage. Storage stays associated with replacement pods. Volumes persist when pods are deleted.. You can find more information about statefulset [here](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/)
A ConfigMap is used to store nginx configuration file. The front pod will consume the ConfigMaps as the default configuration files for nginx web server. This ConfigMap contains the rules for mapping the `/api` request to the backend service.
PVC is binding between a Pod and PV. Pod request the Volume through the PVC.PVC is the request to provision persistent storage with a specific type and configuration.PVCs describe the storage capacity and characteristics a pod requires, and the cluster attempts to match the request and provision the desired persistent volume.
We used a persitent volume in order to save the database data in a persistent volume which is independent of the lifecycle of the Pods. It means that data represented by a PV continue to exist as the cluster changes and as Pods are deleted and recreated.
For persisting the data of the db container, we used a persistent volume using the kubernetes host localfile as we do not have any NFS for this purpose. This persistent volume is mapped to the local `/mnt/pg` folder.
## A description of the container configuration performed.
Two configuration was made to adapt the application to new architecture.
- Connection between database and the backend :
The credentials for PostgreSQL in the statefulset.yml file are also passed as environement variables in the deployment.yml file for the products manager backend deployment.
- Connection between the frontend and the backend: Nginx based image is used to serve the frontend files. A ConfigMap is used to store nginx configuration file to forward all the `/api` request to the products manager backend service.
As We used minikube the local docker registry is not reachable for it, we should proxy the docker daemon to the minikube registry before building our application images, for this we have to run the following command.
The `stop-app.sh` script will remove the namespace and its resources also it will remove the persistent volume we created in the run script.
# Viewing the app
After deploying the app. We need to expose the application service outside the kubernetes we used the `kubectl port-forwading` to forward the front end service localy .