Giter Site home page Giter Site logo

eladjmc / k8s-jenkins-aws Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 1.0 524 KB

Deploying app on eks using ECR with jenkins pipe-line

Dockerfile 28.75% JavaScript 71.25%
assignment aws ci devops docker ecr expressjs fast github jenkins pipeline project

k8s-jenkins-aws's Introduction

Deploying App to K8S Cluster Using Jenkins declarative pipeline

In this project I used a Jenkins process based on Jenkins declarative pipeline to pull a repository from github, compile the code in it, make a docker image from it, push it to a private ECR and and deploy the app using EKS.


Prerequisites

  • Account in AWS
  • Set up an EKS on aws with at lease 2 t2.micro nodes
  • Setting up ECR on AWS
  • Jenkins with all the ECR and EKS credentials + kubectl, docker, AWS CLI and eksctl installed on it and make sure it has access to your github repo and able to push images to your ECR
  • Big cup of coffee ๐Ÿ˜‰โ˜• X5

Jenkins:

  1. Log in to your Jenkins server
  2. Connect your Jenkins to your Github account using a private key(Github should have the public key) - This step can be skipped if the repo is public - How to connect Github to Jenkins video
  3. Create a new Jenkins Pipeline linked to your GitHub repository
  4. Make a secret file with the id of 'secret-yml' that will contain a kubernetes yaml secret with your ECR credentials on it The file should look like this
        apiVersion: v1
        kind: Secret
        metadata:
        name: ecr-secret
        namespace: default
        type: kubernetes.io/basic-auth
        data:
        username: "base64 access key"
        password: "base64 secret access key"

  1. Add your credentials EKS credentials to your Jenkins

Running the pipeline:

  1. After making sure everything is set up to start you need to create a new Jenkins pipeline. this pipeline should be connected to the project git repo
  2. Running the the pipeline, in this project we did not set a triggered pipelined (pipeline that will run at every commit to a specific branch) so you will manually run the pipeline.
    Jenkins will take you repo, clone it and then execute the stages we defined in the Jenkins file - NPM build -> Docker build -> Push image to ECR -> Deploy/update load balancer svc -> Deploy secrets -> Deploy/update app -> Output URL

It should look like this:


3. If it fails you can view the logs and output to figure out what went wrong, and if it passed successfully you can find the link to app in the output.

it should look like this:


Feel free to edit the app I kept it a simple 'hello world' this time and the output looks like this:


Summary

By going through all the steps and making sure you have the prerequisites you:

  • Deployed an app to EKS pod while storing the image in ECR the app serves a 'hello world' page.
  • All the stages from build, push to ECR and deploy on EKS where made with a Jenkins process based on Jenkins declarative pipeline.

Feel free to contact me for questions or opinions about the project. ๐Ÿค™


*** Note: I was not able to make the app accessible via port 443 (Https) within the given time frame for the task, I would appreciate it if someone can send me a guide about tls/ssl certificates for EKS apps/ingress/lb ๐Ÿ™

k8s-jenkins-aws's People

Contributors

eladjmc avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  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.