Container 1 serves as a gatekeeper for storing files to a persistent volume in Google Kubernetes Engine (GKE) and calculating products from the stored files. It is deployed as a service in GKE to communicate with the internet and has access to a persistent volume in GKE for storing and retrieving files. Container 1 communicates with Container 2 to calculate product totals and validates input JSON requests.
-
POST /store-file
This endpoint expects Container 1 to create a file and store the data provided in the JSON request to the GKE persistent storage. If successful, it returns a success message. If there's an error storing the file or if invalid JSON input is provided, appropriate error messages are returned.
JSON Input:
{ "file": "file.dat", "data": "product, amount \nwheat, 10\nwheat, 20\noats, 5" }
JSON Output (Success):
{ "file": "file.dat", "message": "Success." }
JSON Output (Error - Invalid JSON Input):
{ "file": null, "error": "Invalid JSON input." }
-
POST /calculate
This endpoint allows Container 1 to calculate the total of a product stored in the file. If the file exists and follows the specified CSV format, it returns the total. Otherwise, appropriate error messages are returned.
JSON Input:
{ "file": "file.dat", "product": "wheat" }
JSON Output (Success):
{ "file": "file.dat", "sum": 30 }
JSON Output (Error - Input File Not in CSV Format):
{ "file": "file.dat", "error": "Input file not in CSV format." }
Container 2 listens on a defined port and endpoint, interacts with Container 1, and calculates the total of a product from the given file stored in the GKE persistent volume.
-
POST /store-file: This endpoint receives JSON data from Container 1 for storing files. Container 2 does not process this endpoint but should respond appropriately as per the requirements.
-
POST /calculate: This endpoint calculates the total of a product from the given file stored in the GKE persistent volume. If successful, it returns the total. If the file is not found or is not in the proper CSV format, appropriate error messages are returned.
- Container 2 interacts with Container 1.
- Accesses the GKE persistent volume.
- Calculates product totals from the given file.
- Returns appropriate JSON responses based on success or error conditions.
- Folders container1 and container2 contains source code of the server.
- It also contains the yaml for kubernestes cluster deployment, service, persistent volume.
- CloudBuild.yaml file is present in respective container1 and container2 folder.
- Terraform folder container terraform script to create Google Kubernetes Cluster.
- Create separate repositories for each container in GCP Cloud Source Repository and implement CI/CD pipelines using GCP Cloud Build.
- Utilize GCP CI/CD tools (Cloud Source Repository, Cloud Build, and Artifact Registry).
- Utilize Terraform for managing GKE cluster creation.
- Create a Terraform script to start the GKE cluster and deploy the application workload.
- Follow specified configurations for GKE cluster creation to optimize cost and resource usage.
- Attach a persistent volume (1GB) to the GKE cluster and ensure proper access permissions for file operations.
- Expose Container 1 as a service to the internet and test the functionality before shutting down the cluster.