You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Coworking Space Service is a set of APIs that enables users to request one-time tokens and administrators to authorize access to a coworking space. This service follows a microservice pattern and the APIs are split into distinct services that can be deployed and managed independently of one another.
1: Set Up a Postgres Database with Helm Chart
Pre-requisites:
Have Kubernetes cluster ready.
Have kubectl installed and configured to interact with your cluster.
Have Helm installed.
Instructions:
1 Configure a Database for the Service
1.1 Create PersistentVolume
kubectl apply -f pv.yaml
1.2 Create PersistentVolumeClaim
kubectl apply -f pv.yaml
1.3 Create Postgres Deployment
kubectl apply -f postgresql-deployment.yaml
2 Verify the database:
helm list kubectl get pods
3. Port Forwarding
Use kubectl port-forward to forward PostgreSQL service port (5432) to local machine.
Connect to the database using psql with forwarded port.
Build the Docker image locally:
Access to docker file
cd analystics
docker build -t coworking:v1 .
Run the Docker container locally.
docker run -e DB_USERNAME=hanhkv -e DB_PASSWORD=hanh1998 --network=host coworking:v1
4: AWS CodeBuild Pipeline
Configure CodeBuild to pull the image from the GitHub repository, build it, and push it to the existing ECR repository. Make sure to use the buildspecs.yml file.
Set DB_HOST to the service name of the Kubernetes PostgreSQL pod.
##6: CloudWatch Agent Setup
Set up CloudWatch agent for monitoring.
Saving costs:
Implement Autoscaling:
Utilize Kubernetes Horizontal Pod Autoscaling (HPA) to automatically adjust the number of replicas based on resource metrics. This helps scale resources up during peak demand and down during low demand, optimizing costs.
Rightsize Resources:
Regularly review and adjust resource allocations for your Kubernetes pods based on actual usage. Avoid overprovisioning, and set resource limits and requests appropriately.
Alerts on Costly Resources:
Set up alerts based on cost thresholds to be notified when spending exceeds predefined limits. This allows for proactive cost management.
Remember to monitor your application's resource usage and adjust your instance types based on evolving requirements.