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

A Collection of CSS Grid Resources

Closest pair of points

The ABC of Unit Testing in Rails, Part 2.

Asynchronous messaging for integrating microservices

Messaging system for microservices

Linear icons in iOS. You will be happy you learned this.

Loading Scenes in Unity!!

A Simple Guide to Being a Software Developer

How To: Passwordless Wi-Fi sign-in with the Chirp Alexa Toolkit

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

Securities in NodeJs

Deploying a NodeJS application with Heroku using git

Upload a document using multipart form using Kotlin rest template

Django Function-Based View of Update Functionality