Leverage bitbucket pipeline to deploy Node.js in Kubernetes

  • npm install
  • npm run build
image: node:8options:
docker: true
pipelines:
# specify the branch name
branches:
development:
- step:
caches:
- node
script:
- npm install create-react-app
- npm install --save
# Treating warnings as errors because process.env.CI = true. Most CI servers set it automatically.
- unset CI
- npm run build
# If you are using private container registry
- docker login REGISTRY_SERVER -u REGISTRY_USERNAME -p REGISTRY_PASSWORD
# tag docker image
- docker build -t tagname
# Push docker image into container registry
- docker push tagname
artifacts:
- build
FROM node:8.11.1#maintain by 
MAINTAINER xyz #maintainer name
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install
# Bundle app source
COPY . /usr/src/app
# start app
CMD ["sh"]
- kubectl config set-cluster <my.cluster.name> --server=<my.kubernetes.host> --certificate-authority=/path/to/ca.pem- kubectl config set-credentials <my.user> --username=$KUBERNETES_USERNAME --password=$KUBERNETES_PASSWORD- kubectl config set-context <my.context> --cluster=<my.cluster.name> --user=<my.user>- kubectl config use-context <my.context>
kubectl set image deployment/<my.app> <my.app>=<my.dockerhub.username>/<my.app>:$BITBUCKET_COMMIT

--

--

--

DevOps Engineer with 10+ years of experience in the IT Industry. In-depth experience in building highly complex, scalable, secure and distributed systems.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

🎊 Event Emitters in Angular 🎊

Random Quote Generator.

The Hidden Power of InjectionToken Factory Functions in Angular

How to call report server in .net 5

Snake Game With Rust, JavaScript, and WebAssembly | Part 8

DLithe_BC_NFS_T_Task14_WebDesigning

Understanding, Creating and Using JavaScript Objects

[ReactJS] How to detect a click outside of the component

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ankur

Ankur

DevOps Engineer with 10+ years of experience in the IT Industry. In-depth experience in building highly complex, scalable, secure and distributed systems.

More from Medium

How we setup Elasticsearch to get better insights in our warehouse

SAML2 Federated IdP Initiated SLO for Tenanted Scenario in WSO2 Identity Server

Node-RED with Qubitro