This is a simple Node.js web app using the Express framework. It serves the index.html file. The app can be containerize using Docker and deployed to any Kubernetes cluster. There is an example delpoyment config file to run it in AWS Elastic Kubernetes Service (EKS) from a Docker image in a AWS Elastic Container Repository (ECR).
This is the Capstone project for Udacity Devops Engineering Nanodegree.
- Open a terminal and clone the project repository, then navigate to the project folder.
git clone https://github.com/softveda/udacity-devops-capstone.git
cd udacity-devops-capstone
- Create Docker Image for the app
docker build -t simple_node_app .
- Run the app in Docker container
docker run --name simple_node_app -p 8080:80 -d simple_node_app
- Test the app using Curl
curl -s http://localhost:8080
This should show the contents of index.html on the console.
Alternately open your web browser and browse to the URL http://localhost:8080
- Check the logs
docker logs -f simple_node_app
This should write some logs to terminal like
Simple node web app listening on port 80
::ffff:192.168.65.3 - - [19/Apr/2020:01:24:46 +0000] "GET / HTTP/1.1" 200 337
- Stop the running Docker container
docker stop simple_node_app
-
Create a new repository on Docker hub named simple_web_app
-
Tag the image
docker tag simple_node_app:latest <docker account>/simple_node_app:latest
- Push the image to Docker hub
docker push <docker account>/simple_node_app:latest
- Deploy the application and service to Kubernetes
kubectl apply -f app-deployment.yml
- Check that pods, deployment and service are created and running
kubectl get all
- Test the app using Curl
curl -s http://localhost:8080
This should show the contents of index.html on the console.
Alternately open your web browser and browse to the URL http://localhost:8080
- Check the logs
kubectl logs deployment.apps/simple-web-app
This should write some logs to terminal like
Simple node web app listening on port 80
::ffff:192.168.65.3 - - [19/Apr/2020:01:24:46 +0000] "GET / HTTP/1.1" 200 337
- Delete the kubernetes deployment and service
kubectl delete deployment.apps/simple-web-app
kubectl delete service/simple-web-app
- Application files
- app.js - This is the Node.js web application
- views\index.html - This is the default index.html file
- .eslintrc - ESLint configuration file
- .gitignore - This has the files that should not be added to the git repository
- Docker files
- Dockerfile - This is the docker build file to containerize the app inside Docker
- .dockerignore - This has the files that should not be copied when building the Docker image
- Script files
- run_docker.sh - This script will build the Docker image of the app and run the app inside the container
- upload_docker.sh - This script uploads the Docker image to Docker hub repository
- run_kubernetes.sh - This script deploys the Docker image to a Kubernetes cluster and runs the app in pods.