Coder Social home page Coder Social logo

gcprov's Introduction

GCProv Service

Goals

Implements a small service that can be used to spawn cloud instances on Google Cloud(GCE) using Compute API. Service also configures​ ​instance(boostraps)​ ​with​ ​a​ user ​given​ ​username/password​ ​and​ ​responds​ ​with​ ​the​ ​newly created​ ​instance’s​ ID.

As a devops guy, I end up using Terraform/Ansible for Provisioning but this is an exercise to peek behind and explore/provision instance using the Google Compute API. Google compute API while has good documentation doesn't have a lot of example code so this would help if you plan on using the Compute API.

Routes

gcProv ​service​ ​ ​accepts​ ​HTTP​ ​requests​ ​with​ ​the​ ​following​ ​endpoints:

  • GET​ ​/healthcheck

  • POST​ ​/v1/instances/create

GET​ ​/healthcheck

GET http://localhost:8000/healtcheck

Implements​ ​a​ ​basic​ ​health​ ​check,​ ​returning​ ​HTTP​ ​status​ ​code​ ​200​ ​and​ ​a​ message ​page.

POST​ ​/v1/instances/create

Receives​ ​a​ ​username​ ​and​ ​password​ ​as​ ​query​ ​parameters​ ​(ideally SSH keys ​it’s​ ​just​ ​a​ ​basic API for now)​ ​and​ ​responds​ ​with​ ​instanceID. This​ ​endpoint​ ​creates​ ​a​ ​small​ ​cloud​ ​instance​ ​of​ ​a​ ​configurable​ ​type,​ ​configures​ ​a​ ​user​ ​with​ ​the given​ ​username​ ​and​ ​password,​ ​ensures​ ​password​ ​authentication​ ​is​ ​working,​ ​and​ ​ensures​ ​the user​ ​can​ ​be​ ​used​ ​to​ ​log​ ​in​ ​as​ ​root. The​ ​response​ ​is​ ​sent​ ​back​ ​to​ ​the​ ​client​ ​as​ ​soon​ ​as​ ​the​ ​server​ ​is​ ​ready,​ ​so​ ​the​ ​client​ ​must​ ​expect to​ ​wait​ ​for​ ​a​ ​few​ ​seconds​ ​until​ ​the​ ​instance​ ​becomes​ ​healthy.

Parameters

project          // project name in GCP where to launch the instance
region           // Region location under GCP
zone             // zone
username         // username to be created in the spawned instance
userpass         // userpassword so the user can log in

Sample parameters project is "demo" region is "us-west1" zone is "us-west1-c" username is "demouser" userpass is "demopass"

GET /v1/instances/status

GET http://localhost:8000/status

Receives the Google compute instance name and returns instance status

Status Parameters

project          // project name in GCP
zone             // zone under region
instance         // instance name 

Instance customization

To customize the instance name, image and disk size or the network interfaces and service account look at attributes under provisionInstance.

Project structure

gc

-routes.go                  //routes definitions
-healthCheckHandlers.go     //Healtcheck handlers
-instanceHandlers.go        //instance prov and status

main.go                     //entrypoint for the app

gcprov's People

Contributors

seeker815 avatar deepsourcebot 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.