The paper

Using the xxxLogapI-nj project as an example, this document explains the process of containerizing javascript projects developed based on Node.js+Express. It is hoped that similar projects can be extended with this as a reference.

Xxxlogapi-nj itself is a microservitization project, whose function is to simply collect relevant release logs for the system, so that it can be displayed to users in a timely manner.

*** The operation of this document begins with the process after the coding is complete. Do not involve GIT, JENKINS, etc.

*** In order to maintain professional operation, relevant company information has been sensitized.

*** In this series, I have done container operations for spring Boot, Beego, Django, and Node. js frameworks at the same time.

 

steps

The operation process of the whole project is as follows:

A € I ¼Œ Develop the business code and pass the test.



Because javascript is an interpreted language, move the developed directory to the production directory first



 

Second, download the base image, to reduce the image, the base image is node:9.0.0-alpine, and upload to the Harbor warehouse.



Third, write dockerfile and generate project image.

Dockerfile File content

 

The FROM 2 / public/node: 9.0.0 - alpine MAINTAINER CHENGANG WORKDIR/data COPY prismlogapi - nj / / data/EXPOSE was 8000 ENTRYPOINT ["node", "index.js", "8000"]Copy the code


Fourth, write the deployment file of K8S and deploy it.

Xxxlognj-deployment. yaml file contents



 

Deployment command:

kubectl apply -f xxxlognj-deployment.yaml

 

Fifth, prepare the SERVICE file of K8S and deploy it.

Xxxlognj-deployment. yaml file contents

     

Deployment command:

kubectl apply -f xxxlognj-deployment.yaml

 

6. Check the Dashborad service status in K8S and verify the service




Seven, add