Posting system

The posting microservice system that uses Docker. There are two services:

  • user service (port 8070);
  • post service (port 8071);

There some interactions between these services. For example, post service updates amount of posts for user on the user service. Each service uses own database.

Architecture

Postman collection

User service

Build image with tag (2.0.0 in this case)

docker build -t epamvolodymyrsemerkov/user-service:2.0.0 ./

Publish image to Docker repository

docker push epamvolodymyrsemerkov/user-service:2.0.0

User liquibase changelog

Build image with tag (2.0.0 in this case)

docker build -t epamvolodymyrsemerkov/user-liquibase-changelog:2.0.0 -f ../Dockerfile.liquibase ./

Publish image to Docker repository

docker push epamvolodymyrsemerkov/user-liquibase-changelog:2.0.0

Post service

Build image with tag (2.0.0 in this case)

docker build -t epamvolodymyrsemerkov/post-service:2.0.0 ./

Publish image to Docker repository

docker push epamvolodymyrsemerkov/post-service:2.0.0

Post liquibase changelog

Build image with tag (2.0.0 in this case)

docker build -t epamvolodymyrsemerkov/post-liquibase-changelog:2.0.0 -f ../Dockerfile.liquibase ./

Publish image to Docker repository

docker push epamvolodymyrsemerkov/post-liquibase-changelog:2.0.0

Run

For deploying the next command are used

docker-compose up

Kubernetes

To deploy, it should be run kubectl apply command for files in the k8s folder in the following sequence:

kubectl apply -f namespace.yml
kubectl apply -f configMaps.yml
kubectl apply -f secrets.yml
kubectl apply -f storageClass.yml
kubectl apply -f persistentVolumes.yml
kubectl apply -f persistentVolumeClaims.yml
kubectl apply -f statefulSets.yml
kubectl apply -f services.yml
kubectl apply -f deployments.yml

Such as StatefulSet objects' definitions for databases contain volume claim templates for PersistentVolume automatically creation with Delete reclaim policy then run the next command for each of the persistent volumes:

kubectl patch pv [persistent-volume-claim-name] -p "{\"spec\":{\"persistentVolumeReclaimPolicy\":\"Retain\"}}"

The Retain reclaim policy allows for manual reclamation of the resource. When the PersistentVolumeClaim is deleted, the PersistentVolume still exists and the volume is considered "released".