Giter Club home page Giter Club logo

hellologgingnodejs's Introduction

Hello Logging NodeJS

This is a basic Hello World example application written in NodeJS and designed to explore some of Google's Operations Suite features. You can run it in App Engine, Kubernetes Engine, or Cloud Run.

Note: If running the example in a GKE cluster, you will need to enable full security scope access for the cluster when creating, or add appropriate roles to your cluster Service Account, or you will receive errors from some of the operations related agents.

Load the dependencies and test locally

Install the dependencies

npm install

Start the server

npm start

Test by visiting http://localhost:8080

If it's working, shut down the server (ctrl-c)

Building and deploying to Container Registry

Use Cloud Build to build the Docker image and push to GCR

export PROJECT=$(gcloud config list --format 'value(core.project)')
gcloud builds submit . --tag gcr.io/$PROJECT/hello-logging

Running the app in Cloud Run

Now create a new Cloud Run app named hello-logging based on the just pushed image

gcloud run deploy hello-logging --image gcr.io/$PROJECT/hello-logging --region us-central1 --platform managed --quiet --allow-unauthenticated

Rebuilding the Cloud Run app

Remember, if you change the code you'll have to save the change, Cloud Build the image into the GCR, and push a new Cloud Run revision. This command will fail if the $PROJECT env variable isn't set, FYI.

gcloud builds submit --tag gcr.io/$PROJECT/hello-logging
gcloud run deploy hello-logging --image gcr.io/$PROJECT/hello-logging --region us-central1 --platform managed --quiet --allow-unauthenticated

Deploying to App Engine

There's already an app.yaml file so no need to create one yourself. Create the App Engine app (if needed):

gcloud app create

Then deploy the application to it:

gcloud app deploy

GKE

If you'd like to deploy to GKE, make sure you have the appropriate permissions enabled on the cluster (see note at top of this file. There's a k8sapp.yaml containing configurations to create a Deployment, and build a LoadBalancer for it. You will need to edit the file before applying to set the proper path to the container in GCR. The simply apply the file:

kubectl apply -f k8sapp.yaml

hellologgingnodejs's People

Contributors

haggman 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.