GithubHelp home page GithubHelp logo

vtluu / eks-microservice Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thestacks-io/eks-microservice

0.0 2.0 0.0 10 KB

AWS EKS Microservice - Easy Setup

License: MIT License

Dockerfile 15.37% JavaScript 75.96% CSS 2.49% HTML 6.18%

eks-microservice's Introduction

AWS EKS Kubernetes Microservice Web Application

In this example we use CodePipeline, CodeBuild, and ECR to build, test, publish, and deploy a simple microservice web app to our new Kubernetes cluster.

Check out our AWS EKS Kubernetes Cluster project to see how we use CloudFormation to spin up a new EKS Kubernetes cluster.

Prerequisites

Stacks

We use CodePipeline and CodeBuild to build, test, and deploy a new image to ECR on every commit so you will need to fork this repo into your account.

Microservice Stack

1.) Update the input parameters within _cim.yml.

  parameters:
    AppName: 'eks-test'
    GitHubOwner: 'thestacks-io'
    GitHubRepo: 'eks-microservice'
    GitHubToken: '${kms.decrypt(AQICAHgiu9XuQb...mJrnw==)}'

You will need to replace the GitHubOwner, GitHubRepo, and GitHubToken. Follow the steps below to encrypt your GitHubToken.

Encrypt Secrets:

In order to protect your configuration secrets like your GitHub token we need to create a KMS key first.

  • Open the AWS console to KMS and create a new KMS key.
  • Install https://github.com/ddffx/kms-cli and setup your AWS environment vars.
  • Encrypt each string as outlined below.
  • Add the encrypted strings to the _cim.yml. The format is ${kms.decrypt(<encreted string>)}

How to Encrypt:

Create a file called encrypt.json

{
  "keyId" : "<your kms key id>",
  "plainText": "<your client id>",
  "awsRegion": "<aws region>",
  "awsProfile": "<aws profile"
}

Use this command to perform the encryption : kms-cli encrypt --file encrypt.json

2.) Now we're ready to deploy our stack.

Deploy stack.

cim stack-up

Once an image is built and placed in ECR we can deploy our microservice.

Record the ECRUrl stack output parameter because we will need it in the next step.

3.) Configure and create the Kubernetes deployment.

Update the eks-deployment.yml file and replace the <ecr-url> and <image-version>. Both of these can be found in your ECR console. The <image-version> is the first 8 characters of the commit hash that triggered the new image.

Now that your eks-deployment.yml file is ready we can create the Kubernetes deployment.

Create the Kubernetes deployment:

kubectl create -f eks-deployment.yml

Check the status of your pods.

kubectl get pods

4.) Create the Kumbernetes service.

Create the Kubernetes service (Routing for pods)

kubectl create -f eks-service.yml

This will create a classic load balancer you can use to access your web app. You can also use the load balancer url to create a Route53 DNS route if you wish.

Get domain. It may take several minutes before the IP address is available.

kubectl get services -o wide

Tear down

kubectl delete -f eks-service.yml
kubectl delete -f eks-deployment.yml
cim stack-delete

eks-microservice's People

Contributors

rgfindl avatar

Watchers

James Cloos avatar Viet Luu 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.