Goals:
- Build a containerized application using the microservices architecture
- Deploy the application on the cloud with Kubernetes
- Configure the required infrastructure with Terraform's IaC approach
Non-goals:
- Create a useful service or API
Name | Framework | Information |
---|---|---|
api-gateway | Spring WebFlux, Spring Cloud Gateway | Centralizes communication between services and exposes them |
user-service | Spring Web | Responsible for information about some "users" |
content-service | Spring Web | Responsible for information about some "content" |
recommendation-service | Spring WebFlux | Aggregates user and content data and produces content recommendations for users |
Note: Each service is intentionally a separate Gradle project, rather than a module of a parent project. That is because microservices should ideally be decoupled. However, for convenience, they are all put in this single repository.
Create a new project in the GCP Console. Enable the Compute Engine API, Kubernetes Engine API, Cloud Build API and Artifact Registry API.
gcloud init
gcloud auth application-default login
gcloud components install kubectl
gcloud components install gke-gcloud-auth-plugin
Configure the variables in terraform.tfvars
, then run
terraform init
terraform apply
For each service run
gcloud builds submit --tag <region>-docker.pkg.dev/<project>/<repo>/<service_name> .
For each service, configure the image location in the deployment.yaml
file, then run
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml