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

If you are running this on Google Cloud with the expectation that the libraries will work, please specify the project using:

export GCLOUD_PROJECT=$DEVSHELL_PROJECT_ID

Test by visiting http://localhost:8080

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

Building and deploying to Artifact Registry

Use Cloud Build to build the Docker image and push to Artifact Registry. Use the buildContainer.sh script

. buildContainer.sh

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 us-docker.pkg.dev/${PROJECT}/demos/hello-operations-demo:latest --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.

. buildContainer.sh
gcloud run deploy hello-logging --image us-docker.pkg.dev/${PROJECT}/demos/hello-operations-demo:latest --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. Then simply apply the file:

kubectl apply -f k8sapp.yaml

hellologgingnodejs's People

Contributors

haggman avatar paulleroyza avatar dependabot[bot] avatar

Stargazers

M.Zulfikar Isnaen avatar Waya Putra Ragil avatar Koen avatar Muhammad Razin Syakib avatar Dimaspadma avatar Hubert Machała avatar  avatar nabil avatar Joseph avatar Amaury Quintero avatar Dinko Osrecki avatar  avatar Hrishikesh Kadam avatar Atadzhan K avatar AsierCidon avatar Hari Kishan Nanduri avatar Yahya Hassanzadeh, Ph.D. avatar

Watchers

Brian Eiler avatar  avatar

hellologgingnodejs's Issues

Nodejs14 support will end Jan 30th 2024

Please update the Nodejs version as it is going to be out of support soon.

"WARNING: Node.js 14 is no longer supported by the Node.js community as of 30 April, 2023. Node.js 14 will be end of support on 2024-01-30. As of 2024-01-30 you will no longer be able to deploy your App Engine Standard using nodejs14. We recommend you to upgrade to the latest version of Node.js as soon as possible."

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.