Search This Blog

Tuesday, April 25, 2017

Google Cloud Platform Tutorial Series 102

 

In our last chapter of google cloud computing platform quick start we learned how to quickly setup the google platform and get started with our first instance inside the cloud.

 

There are multiple ways to interact with google platform:

  • Console Access (Easy GUI)
  • REST API(Programming)
  • Google Cloud SDK (Command line)
  • Client Libraries( Google API client library (Java-Python-Node JS etc.) –Discuss later
  •  

    Lets work on the compute engine via the shell and try to create a new instance using shell.

    Console Access

     

    image

    $ gcloud compute instances create instance2 (Created a new instance via command line)

    I selected my zone and the new instance is booted.

    gcloud instance create on cloud

     

    REST API

    Lets see how to see our instances in compute engine via the REST API

     

    https://console.cloud.google.com/apis/api/compute-component.googleapis.com/overview

    Click on API Explorer.

    image

     

    Enter project name and zone and accept OAuth authorization.

    oauth authorization google cloud platform

     

    image

     

    You will get the 200 Response, make sure you enable the API key from console > API manager > Credentials > Create credentials for API key> Generate.

     

    Google Cloud SDK

    Its a good time to install the google command line tools.

    https://cloud.google.com/sdk/

    Download for your platform, mine is windows so I have downloaded Windows binary.

     

     

    General Knowledge about GCP

    Google Platform has  two main parts:

  • Compute Engine (IAAS- Infrastructure as a Service components)
  • App Engine (PAAS- Platform(Java/Python) as a service)
  •  

    An app will be deployed to app engine via the flow.

  • We will develop the app locally on Eclipse or other IDE
  • We will use the SDK to deploy to App engine.
  • App engine scales up as per requirement and use other Google cloud services
  •  

    Google offers two different kind of run time environments.

  • Standard Runtime Environments(By Google containers Java/Python – on Dockers)
  • Flexible Runtime Environments( Custom Dockers containers E.g Web logic )
  •  

    Google also offers cloud endpoints to generate REST API for your code via the annotations for both Java and Python.

    ===========================================

     

    Sample Hello World Code Deployment

    Lets start deploying a sample application to understand it better.

    We will be deploying the python application on the app engine.Also you will need to use the Google’s source repository to make changes to your code.

     

    Lets use the browser shell to create a repository on google cloud and clone it locally for our hello world app.

    Getting the Repository ready

    By default you will have a repository with the name of default, create one with name of helloworld from the google console.

    image

     

    Lets create a folder by name of helloworld nd clone the helloworld project repository into that.

    image

     

    $mkdir helloworld

    $cd helloworld

    $gcloud source repos clone helloworld

    $cd helloworld

    $git pull https://github.com/GoogleCloudPlatform/getting-started-python

    $ git push origin master

     

    Now you should see the source code of getting started in your repository window.

     

     

    image

     

    Now its time to fulfill the app requirements and deploy to cloud.

    We will use PIP to fulfill the FLASK requirements of Python 3 and deploy it to cloud.

    $ pip install -r requirements.txt -t lib

    $ gcloud app deploy

    imagequick start deploy python hello world gcp google cloud

    hello world google cloud platform

     

    So your first hello world app is launched on google cloud engine, in this tutorial we learnt, how to setup the GIT shell to be used with google source repository and how we pushed our first python- hello world app, to the google cloud.

     

    Keep Reading !

    Action Item: Subscribe & Share !

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    No comments:

    Post a Comment