Coder Social home page Coder Social logo

python-api's Introduction

python-api

This is a simple python api meant to be deployed in docker, and then k8s.

Requirements

Docker

Google Cloud https://cloud.google.com/sdk/docs/quickstart#linux

There will be some manual steps to setup Google Cloud so that it allows k8s deploys.

Setting up

  1. Select or create a Google Cloud Platform project

  2. Enable Billing

  3. Use the following commands on your cli:

docker pull google/cloud-sdk
docker run -it --name gcloud-config google/cloud-sdk:latest gcloud auth login
docker run --volumes-from gcloud-config -it google/cloud-sdk:latest gcloud set project {{project-id}}
docker run --volumes-from gcloud-config -it google/cloud-sdk:latest gcloud services enable compute.googleapis.com deploymentmanager.googleapis.com
docker run --volumes-from gcloud-config -it google/cloud-sdk:latest gcloud container clusters create pythonapi --region us-west1
  1. In the GCP console setup and download your access key. Then run cat secret.json | base64. Set this as GKE_SA_KEY in this project.

  2. In this project, add GKE_PROJECT as a secret.

Using Deployment Manager

After your secret key is setup, you can use Deployment Manager to create a more repeatable and customized setup of GKE. https://github.com/GoogleCloudPlatform/deploymentmanager-samples/tree/master/examples/v2/gke In the link above is Google's Deployment manager repo for GKE & other resources. Using this repo as a base you can customize your GKE as much as needed.

Architecture

This is a python application built into a Docker container.

The python api is built using flask, and will run on port 5000.

The container will be deployed on k8s (into GKE as of 20-Oct-2020) The loadbalancer will be on an external ip address listening on port 8080. To see the api you can curl http:<external-ip>:8080/api/v1/message/

The external ip can be found in the output of the app deployment in the google action

For now, the initial setup of GKE is to be done manually in the GCloud console.

Everything will be automatically built, deployed, and tested via a GitHub action.

Note: You need your flask app to run on 0.0.0.0 or External sources won't be able to access the app without using a GCP proxy

Notes:

This is just a demo app, but feel free to use it to build awesome things if you'd like

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.