Git Product home page Git Product logo

amazon-eks-node-express-sample's Introduction

How to Deploy a Node-Express App on Amazon EKS

The purpose of this repository is to demonstrate how to deploy a simple web application built by Express - Node.js web application framework on Amazon EKS by using Amazon ECR (Elastic Container Registry)

Requirements

  • AWS Command Line Interface configured with a profile having sufficient access.

  • Your environment needs to have Git and Docker installed. Dockerfile and the sample code are provided in this repository.

  • We'll push the image to Amazon ECR. If you're using the EC2 Instance for this, make sure its assigned role has necessary rights (such as AmazonEC2ContainerRegistryFullAccess )

  • The eksctl command line utility ( a sample yaml file are provided in this repository) and kubectl

Step-1: Build a Docker Image and Push to Amazon ECR

In this part we will build an image and then push it to a container registry - Amazon ECR in order to use it in an Kubernetes object. We'll proceed with a private repository in this demo, but public repositories and Docker Hub are also supported.

# install git
$ sudo yum install -y git
$ git clone https://github.com/aws-samples/amazon-eks-node-express-sample

# build docker image & verify 
$ cd amazon-eks-node-express-sample/sample-nodejs-app
$ docker build -t sample-nodejs-app .
$ docker images

# Authenticate to your default registry
# update the region and aws_account_id on the below command
$ aws ecr get-login-password --region <region> | docker login --username AWS --password-stdin <aws_account_id>.dkr.ecr.<region>.amazonaws.com

# Once you receive 'Login Succeeded" , you can create your private repo on ECR
# update the region on the below command
$ aws ecr create-repository \
    --repository-name sample-nodejs-app \
    --image-scanning-configuration scanOnPush=true \
    --region <region>

# tag and push your image
# update the region and aws_account_id on the below command
$ docker tag sample-nodejs-app:latest <aws_account_id>.dkr.ecr.<region>.amazonaws.com/sample-nodejs-app:latest
$ docker push <aws_account_id>.dkr.ecr.<region>.amazonaws.com/sample-nodejs-app:latest

Congratulations! Now, you've pushed this image to a private repository of Amazon ECR. This should now be listed on your images under Amazon ECR repositories. Copy the Image URI as we'll need it in the next step.

Step-2: Creating an Amazon EKS cluster

There are two getting started guides available for creating a new Kubernetes cluster with nodes in Amazon EKS:

  • Getting started with Amazon EKS – eksctl – This getting started guide helps you to install all of the required resources to get started with Amazon EKS using eksctl, a simple command line utility for creating and managing Kubernetes clusters on Amazon EKS.

  • Getting started with Amazon EKS – AWS Management Console and AWS CLI – This getting started guide helps you to create all of the required resources to get started with Amazon EKS using the AWS Management Console and AWS CLI. At the end of the tutorial, you will have a running Amazon EKS cluster that you can deploy applications to.

In this sample we'll proceed with the 1st option and launch an EKS development environment with 1 node :

# Check that you've an updated version of eksctl installed
$ eksctl version
$ eksctl create cluster -f eks-sample-cluster.yaml
$ kubectl get nodes

Step-3: Deploy Kubernetes Objects

$ kubectl apply -f k8s/sample-k8s-deployment.yaml
$ kubectl apply -f k8s/sample-k8s-service.yaml
# Now that we have a running service that is type: LoadBalancer we need to find the ELB’s address. We can do this by using the get services operation of kubectl:
$ kubectl get service amazon-eks-node-express-sample -o wide

It will take several minutes for the ELB to become healthy and start passing traffic to the frontend pods.

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

amazon-eks-node-express-sample's People

Contributors

amazon-auto avatar burak-aws avatar mburakunuvar avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.