Giter Club home page Giter Club logo

gmemegen's Introduction

gMemegen

CircleCI

gMemegen is a sample application, showcasing Cloud SQL Postgres connectivity from a Kubernetes cluster running on Google Kubernetes Engine.

Deployment

You can find the complete instructions (including resource setup) in the form a codelab, located here.

The app attempts a connection to a postgres server located at 127.0.0.1 unless otherwise specificed. For a full list of available flags, use python app/main.py -help.

Local deployment

Install the requirements (inside a virtualenv)

pip install -r app/requirements.txt

With cloud_sql_proxy running, start the application on the debug server:

python app/main.py --DB_USER <db_user> --DB_PASS <db_pass>

Verify the app is running by navigating to http://127.0.0.1:5000.

Use Ctrl+C to stop the application at any time.

Local deployment inside Docker:

Build the docker with:

docker build -t gmemegen .

With cloud_sql_proxy running, start the container:

docker run  --net="host" -it --rm --name runtime -e "DB_PASS=1qaz2wsx" gmemegen

Verify the app is running by navigating to http://127.0.0.1:5000.

Use Ctrl+C to stop the application at any time.

Kubernetes Deployment

Create a kubernetes secret named cloudsql-instance-credentials from your service account key:

kubectl create secret generic cloudsql-instance-credentials \
    --from-file=credentials.json=service_account_key.json

Create a kubernetes secret named cloudsql-db-credentials from your database credentials key:

kubectl create secret generic cloudsql-db-credentials \
    --from-literal=username=[DB_USER] \
    --from-literal=password=[DB_PASS]

Update the gmemegen_deployment.yaml by replacing variables in the following sections:

  • gcr.io/[PROJECT_ID]/gmemegen with the correct project name.
  • "-instances=<INSTANCE_CONNECTION_NAME>=tcp:5432" with your Cloud SQL connection name.

Create your deployment on your cluster:

kubectl create -f gmemegen_deployment.yaml

To access your deployment via the web, expose it with a LoadBalancer object:

kubectl expose deployment gmemegen --type "LoadBalancer" --port 80 --target-port 8080

After 2-3 minutes, describe the service to find the "LoadBalancer Ingress".

kubectl describe services gmemegen

Your service should be ready at http://[LoadBalancer Ingress]:80. Navigate to your URL and make some memes!

Disclaimer

This is not an official Google product.

gmemegen's People

Contributors

federated-life avatar gabidavila avatar kurtisvg 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.