GithubHelp home page GithubHelp logo

romuloslv / challengeapp Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 2.29 MB

REST API GO running local/cloud

Home Page: https://appcloud.fly.dev

License: MIT License

Go 61.64% Dockerfile 1.67% Makefile 4.88% Shell 1.56% HCL 24.75% Smarty 5.51%
cloud cluster go-rest-api iac-terraform monitoring

challengeapp's Introduction

GitHub Deploy to fly.io app Run test suite codecov

Hands On ๐Ÿ‘‹๐Ÿผ

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.


Requirements

You will need these tools installed on your PC: docker | docker-compose | helm | terraform | gcloud-auth | gcloud


Local APP

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

Local Docs

Port URI Description Method
:8080 /swagger/doc.json Open Swagger Docs GET
:8080 /swagger/index.html Open Swagger Page GET

To provision the local stack using docker run

make stop && make run

To run built-in tests using the local stack provisioned with make run

make tests

To provision the local stack using docker compose (only tests)

make stop && make dev

To run built-in tests using the local stack provisioned with make dev

make tests

To provision the local stack using docker compose (production ready)

make stop && make prod

To run tests, make calls consuming the API

Examples in structure/calls.tpl

Remove stack local

make stop


Deploy PaaS/Run Test Fly APP - PaaS
Page Actions of project https://appcloud.fly.dev

IAC

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>

Cluster/APP info

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

Grafana info

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

Kibana filter

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

Wrapping up

Now, to clean up everything you just need to run

make terraform-destroy cluster_name=<YOUR-CLUSTER-NAME>

Reference

challengeapp's People

Contributors

romuloslv avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.