GithubHelp home page GithubHelp logo

sachsenhofer / microservice_nodejs Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 540 KB

This is a template for a Node.js microservice on Kubernetes

Home Page: https://sachsenhofer.io

JavaScript 100.00%
microservice nodejs kubernetes

microservice_nodejs's Introduction

microservice_nodejs

This is a template for a Node.js microservice on Kubernetes.


Checkout repository:

git clone https://github.com/sachsenhofer/microservice_nodejs.git

App

const express = require('express')
const app = express()

app.get('/', (req, res) => res.send('Hello World!'))

app.listen(8080, () => console.log('App listening on port 8080!'))

Dockerfile

FROM node:8.11.2-alpine

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 8080

CMD [ "npm", "start" ]

Usage

Build

Builds the Docker image.

Execute in terminal:

sudo docker build -t microservice-nodejs:latest .

Push

Pushes an image or a repository to the Google Container Registry.

A Google Cloud account is needed. Replace 'public-207110' with your own Project-ID.

Execute in terminal:

sudo docker tag microservice-nodejs:latest eu.gcr.io/public-207110/microservice-nodejs:latest
sudo docker push eu.gcr.io/public-207110/microservice-nodejs:latest

Pull

Pulls the image from the Google Container Registry.

Execute in terminal:

sudo docker pull eu.gcr.io/public-207110/microservice-nodejs:latest

Run

Runs the image on your local machine.

Execute in terminal:

sudo docker run -p 8080:8080 eu.gcr.io/public-207110/microservice-nodejs:latest

Deploy

Deploys the application to the Kubernetes cluster.

Execute in terminal:

kubectl create -f deploy/kubernetes

Check all ressources that have been created:

kubectl get deployments,pods,services -n microservice
NAME                      DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
microservice-nodejs-dep   2         2         2            2           8m

NAME                                       READY     STATUS    RESTARTS   AGE
microservice-nodejs-dep-85bc599557-2g7fj   1/1       Running   0          8m
microservice-nodejs-dep-85bc599557-gzzdz   1/1       Running   0          8m

NAME                      TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)          AGE
microservice-nodejs-svc   LoadBalancer   10.63.253.93    35.233.81.3     8080:31666/TCP   8m

Delete

To delete all resources, execute the following command.

Execute in terminal:

kubectl delete -f deploy/kubernetes

microservice_nodejs's People

Contributors

sachsenhofer avatar

Stargazers

 avatar

Watchers

James Cloos avatar  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.