romanbovda / crypto-currency-api

Demo for a crypto currency API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build and Deploy Test Python app

Coinbase's currency API Demo:

This is a simple API service, which helps you to get fiat BTC price. For instance:

{hostname}/currency/UAH

Architecture:

  • Simple Python API on Flask
  • AWS EKS cluster managed by Terraform
  • Github actions as a CI/CD
  • Docker and Helm for app deployment

Run API locally

$ make develop

Perform tests

$ make test

Infrastructure provisioning

For MacOs, use the package manager homebrew to install the AWS CLI.

$ brew install awscli

After you've installed the AWS CLI, configure it by running aws configure.

When prompted, enter your AWS Access Key ID, Secret Access Key, region and output format.

$ aws configure
AWS Access Key ID [None]: YOUR_AWS_ACCESS_KEY_ID
AWS Secret Access Key [None]: YOUR_AWS_SECRET_ACCESS_KEY
Default region name [None]: YOUR_AWS_REGION
Default output format [None]: json

In your terminal, clone the following repository.

$ cd terraform/crypto-eks-cluster

$ terraform init

$ terraform verify

$ terraform plan

$ terraform apply

(Optionally) Deploy Kubernetes Metrics Server

The Kubernetes Metrics Server, used to gather metrics such as cluster CPU and memory usage over time, is not deployed by default in EKS clusters.

Download and unzip the metrics server by running the following command.

$ wget -O v0.3.6.tar.gz https://codeload.github.com/kubernetes-sigs/metrics-server/tar.gz/v0.3.6 && tar -xzf v0.3.6.tar.gz

Deploy the metrics server to the cluster by running the following command.

$ kubectl apply -f metrics-server-0.3.6/deploy/1.8+/

Verify that the metrics server has been deployed. If successful, you should see something like this.

$ kubectl get deployment metrics-server -n kube-system

NAME             READY   UP-TO-DATE   AVAILABLE   AGE
metrics-server   1/1     1            1           4s

Slack notifications

Test and deploy actions served by Mr. Bender - SRE helper bot img.png

Get endpoint name:

$ kubectl get svc crypto-currency-api -o json | jq -r '.status.loadBalancer.ingress[0].hostname'

ad8a6f27128824f538fa4c35b6e57444-2138826783.us-east-1.elb.amazonaws.com

Encode kube config

cat $HOME/.kube/config | base64

About

Demo for a crypto currency API


Languages

Language:HCL 83.4%Language:Python 13.8%Language:Dockerfile 1.7%Language:Makefile 1.1%