Simple REST API in GO to manage information. This repository is part of a delivery stack, aiming to simulate an application in production, exploring its automation/improvement points.
You will need these tools installed on your PC: docker | docker-compose | helm | terraform | gcloud-auth | gcloud
Port | URI | Description | Method |
---|---|---|---|
:8080 | / | Returns Home | GET |
:8080 | /health | Returns Health | GET |
:8080 | /version | Returns Version | GET |
:8080 | /accounts | Returns List Accounts | GET |
:8080 | /accounts/{person_id} | Returns Person Account | GET |
:8080 | /accounts | Insert account | POST |
:8080 | /accounts/{person_id} | Update/Replace account | PUT |
:8080 | /accounts/{person_id} | Update/Modify account | PATCH |
:8080 | /accounts/{person_id} | Delete account | DELETE |
Port | URI | Description | Method |
---|---|---|---|
:8080 | /swagger/doc.json | Open Swagger Docs | GET |
:8080 | /swagger/index.html | Open Swagger Page | GET |
make stop && make run
make tests
make stop && make dev
make tests
make stop && make prod
Examples in structure/calls.tpl
make stop
Deploy PaaS/Run Test | Fly APP - PaaS |
---|---|
Page Actions of project | https://appcloud.fly.dev |
First, you should create bucket and export variables you are going to use.
-
After accessing the gcp console, create a bucket named poc-from-gke-tf-state. The reference of this bucket is described in the provider.tf file.
-
Then export the necessary environment variables to start the configuration process
export GOOGLE_PROJECT="<YOUR-PROJECT-NAME>" USE_GKE_GCLOUD_AUTH_PLUGIN="True" KUBE_CONFIG_PATH="~/.kube/config"
Authenticate into Google Cloud console, to so run the following command:
make terraform-login project_name=<YOUR-PROJECT-NAME>
Check your project to make sure everything goes well
make terraform-validation
Now, we will continue with the creation of the cluster/pools
make terraform-apply-cluster cluster_name=<YOUR-CLUSTER-NAME>
After a few minutes, your infra is ready to be used. It will show you everything that will be created by terraform, take a moment to check this output. Once you are ready, you just need to run:
make terraform-apply-pkgs cluster_name=<YOUR-CLUSTER-NAME> project_name=<YOUR-PROJECT-NAME>
echo "DASH - $(kubectl get svc -n lab-dashboard | awk '{print $4}')"
echo "APP - $(kubectl get svc -n lab-app | awk '{print $4}' | grep -v none)"
Once you port-foward
your services, you can easily access it on your browser via localhost.
kubectl port-forward \
$(kubectl get pods -l=app="kibana" -o name -n lab-logging) 5601 -n lab-logging
kubectl port-forward \
$(kubectl get pods -l=app.kubernetes.io/instance="monitor" -o name -n lab-monitoring) 3000 -n lab-monitoring
kubectl port-forward \
$(kubectl get pods -l=app="prometheus" -o name -n lab-monitoring | tail -n1) 9090 -n lab-monitoring
kubectl port-forward \
$(kubectl get pods -l=app="elasticsearch-master" -o name -n lab-logging) 9200 -n lab-logging
kubectl get secret --namespace lab-monitoring grafana -o jsonpath="{.data.admin-user}" | base64 --decode | xargs echo
kubectl get secret --namespace lab-monitoring grafana -o jsonpath="{.data.admin-password}" | base64 --decode | xargs echo
To facilitate the understanding of the logs, the following tags were used to view the logs
- kubernetes.container_name
- kubernetes.pod_name
- kubernetes.namespace_name
- log
Now, to clean up everything you just need to run
make terraform-destroy cluster_name=<YOUR-CLUSTER-NAME>