Deploy NodeJS Docker to QiO Edge Cloud using Kubernetes

Create App and build docker image

Create a file of the name Dockerfile with the content below and put into your project root folder.

# specify the node base image with your desired version node:<version>
FROM node:8

WORKDIR /app

RUN chown -R node:node /usr/local/lib/node_modules
RUN chown -R node:node /usr/local/bin
USER node

RUN npm install node-red -g
RUN npm install node-red-node-mongodb -g
RUN npm i node-red/node-red-dashboard -g

# port 1880 for node-red-dashboard
EXPOSE 1880

CMD node-red

Build using docker build -t nodejs .

Tag & Push docker image to the private registry

docker tag nodejs qio01:5000/nodejs:1.0.1
docker push qio01:5000/nodejs:1.0.1

Deploy in Kubenetes

  1. Goto default Stack.
  2. Add a service, fill in Name, Hostname, Select Image, and rote Port Map.
  3. Goto nginx load balancer in Rancher.
  4. Add a port rule, select Protocol and Target image, fill in host Port and target Port.

Enjoy

    原文作者:HiroshiFuu
    原文地址: https://segmentfault.com/a/1190000011359974
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞