Giter Site home page Giter Site logo

icp-nodejs-sample-2's Introduction

Node.js sample Helm Chart

This sample is for demonstrative purposes only and is NOT for production use.

For all features to be available this is best viewed in Google Chrome or Safari with client-side JavaScript enabled.

Image scan results

Be aware that, as with anything you deploy using Docker, this image may become vulnerable over time; as can your applications! it's your responsibility to ensure your images are free of problems: Dockerhub and various IBM offerings including the IBM Container Service allow for on-demand image scanning.

Introduction

This sample application is intended to guide you through the process of deploying your own Node.js applications into IBM Cloud Private. Useful links and examples are provided and the application itself is one that makes use of various monitoring capabilities. Note that this sample was produced in early October 2017 and so the code you are provided with by using the generators may differ! The application provided uses the node Docker images.

This sample was created using idt create with the following choices:

  • Web App
  • Basic Web
  • Node

Modifications were then made to use EJS, to add a gulp task, and to add the content. The stylesheet provided is largely based on the Node.js @ IBM developer center.

  • This example uses appmetrics and appmetrics-dash: the endpoint being /appmetrics-dash.
  • This example features the "scrape" annotation in the <chart directory>/templates/service.yaml file. In combination with the appmetrics-prometheus module inclusion and usage, this enables the sample to be automatically scraped by a deployed instance of Prometheus in order for metrics to be gathered and displayed using the Prometheus web UI. You can view the raw data that will be available to Prometheus at the /metrics endpoint. This allows developers to quickly determine how the application is performing across potentially many Kubernetes pods.
  • This example uses appmetrics-zipkin. If Zipkin is deployed (e.g. with the Microservice Builder fabric), trace information will be available under the service name "icp-nodejs-sample". To enable this feature, modify Dockerfile and set USE_ZIPKIN. You can dynamically modify applications as well using the IBM Cloud Private web UI - this includes the setting of environment variables and it's recommended you restart the pod for the change to take effect.
  • This example can be deployed using the IBM Cloud Developer Tools, for example: idt deploy -t container --deploy-image-target mycluster.icp:8500/default/nodejs-sample.

The mycluster.icp example here should match up with the entry you've added in /etc/hosts: it is the location of the private registry.

Prerequisites

As well as having a Kubernetes cluster you can deploy to (such as Kubernetes included with IBM Cloud Private), you should have Prometheus deployed into your Kubernetes cluster where this sample will be installed. This is not a mandatory step and can be done after deployment. Optionally you can set up a Zipkin server (for example, as part of the Microservice Builder Fabric or a standalone Zipkin image), which is where you can configure the sample to use the appmetrics-zipkin module, to discover the Zipkin server, and to send its trace data there. This is especially useful for end-to-end tracing of your Node.js deployments and more information should be consulted from the appmetrics-zipkin Github repository.

Installing the Chart

The Helm chart can be installed from the app center by clicking the ibm-nodejs-sample tile in the IBM Cloud Private catalog and following the installation steps.

If you don't have the ibm-charts repository already available in your install of IBM Cloud Private, or you want to install the sample without using IBM Cloud Private, you can do the following:

  • helm repo add ibm-charts https://raw.githubusercontent.com/IBM/charts/master/repo/stable/
  • helm install --name sample ibm-charts/ibm-nodejs-sample

The Helm chart can also be installed with the following command from the directory containing Chart.yaml:

helm install --name tester . where tester can be anything.

You can find more information about deployment methods in the IBM Cloud Private documentation.

Verifying the Chart

You can view the deployed sample in your web browser. To retrieve the IP and port:

export SAMPLE_NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")

export SAMPLE_NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "fullname" . }})

Open your web browser at http://${SAMPLE_NODE_IP}:${SAMPLE_NODE_PORT} to view the sample.

Uninstalling the Chart

If you installed it with helm install --name tester . you'd remove the sample with helm delete --purge tester. You can find the deployment with helm list --all and searching for an entry with the chart name "ibm-nodejs-sample".

Testing the Chart with Helm

You can programatically run the test in the following ways.

  • cd chart/ibm-nodejs-sample then do ./test-chart.sh OR
  • helm test sample: assuming you've deployed it with the release name sample.

Configuration

The following table lists the configurable parameters of the ibm-nodejs-sample chart and their default values.

Parameter Description Default
replicaCount How many pods to deploy 1
revisionHistoryLimit Optional field that specifies the number of old ReplicaSets to retain to allow rollback 1
image.repository image repository ibmcom/icp-nodejs-sample
image.tag Image tag latest
image.pullPolicy Image pull policy Always
livenessProbe.initialDelaySeconds How long to wait before checking the pod(s) are up 30
livenessProbe.periodSeconds The interval at which we'll check if a pod is running OK before being restarted 10
service.name Kubernetes service name Node
service.type Kubernetes service type for exposing port NodePort
service.port TCP port for this service 3000
resources.limits.memory Memory resource limits 128m
resources.limits.cpu CPU resource limits 100m

Configuring Node.js applications

See the Node.js @ IBM developer center for all things Node.js - including more samples, tutorials and blog posts. For configuring Node.js itself, consult the official Node.js community documentation.

Deploying on platforms other than x86-64

  • Multiarch images are used so the correct Node.js Docker image will be pulled based on your platform. Supported platforms for this sample include ppc64le, x86-64 and s390x.
  • Note that the IBM Cloud Developer Tools are not available for every platform: consult the CLI docs to find out more.

Multiple Node.js versions

  • This sample is built on the latest LTS version of Node.js.
  • Developers are welcome to bring Node.js LTS release applications to IBM Cloud Private and can do so by modifying their Dockerfile to pull from the specified tag that corresponds with the desired version.

Disclaimers

Node.js is an official trademark of Joyent. Images are used according to the Node.js visual guidelines - no copyright claims are made. You can view the guidelines here.

This icp-nodejs-sample is not formally related to or endorsed by the official Node.js open source or commercial project.

icp-nodejs-sample-2's People

Contributors

a-roberts avatar rafal-szypulka avatar

Watchers

 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.