Giter Club home page Giter Club logo

udacity-devops-capstone-project's Introduction

Capstone Project for Udacity DevOps Nanodegree

This project fulfills the requirements of the Udacity DevOps Capstone Project. A web app is containerized and deployed to a kubernetes cluster. This webapp runs a simple apache site.

๐Ÿ“ƒ Information on Some of the files

1) initial-setup.sh - This file is the first file to look at when setting up this project. It installs the required packakages to make this project work such as Docker, Jenkins, Kubectl, eksctl, hadolint etc. Refer to the Medium article to see how and when it is used.

2) kubernetes/ - This folder contains the kubernetes resource configuration files that will deploy the application image on AWS EKS using kubectl once configured properly.

3) Jenkinsfile - This file contains the definition of the stages in the pipeline. The stages in this project's pipeline are Lint files, Building image, Upload Image to Docker hub, Remove Unused docker image, Update Kube Config and Deploy Updated Image to Cluster.

4) Makefile - This file contains shell commands that can be executed using the Make linux tool.

5) Dockerfile - This file contains all the commands needed to assemble the app image.

6) run_docker.sh - This file contains the shell commands needed to build the image on docker locally and also run a container.

7) run_kubernetes.sh - This file contains the shell commands needed to deploy the app in a kubernetes cluster running locally.

8) upload_docker.sh - This file contains the shell commands needed to upload the docker image to docker hub.

๐Ÿ“ƒ Deploying on Amazon EKS using a CI/CD pipeline

1) A Jenkins server needs to be provisioned to setup your CI/CD pipeline. You can follow this tutorial to setup Jenkins on an Ubuntu Server.

2) Once your server is provisioned, you'll need to install Docker, ansible, hadolint, pylint and install the latest AWS CLI

3) The reason for installing the latest AWS CLI is to have the EKS module available for you. Once you install the AWS CLI you might not be able to run AWS commands. You can source your bash profile to get it working:

โ source ~/.bash_profile

4) With AWS CLI installed you can setup it up as the Jenkins User. Follow this tutorial to see how. This is to allow you run aws commands in your pipeline without getting errors. Also set up aws credentials on Jenkins dashboard.

5) You'll need to add the jenkins user to the sudoer group to enable it run ansible-playbooks. Follow this tutorial to see how to. Note: This is not best practices standard.

6) You might need to disable password request for the jenkins user for your pipeline to run smoothly. Note: This is not best practices standard.

7) Create swap space on your server. I got an out of memory error after running ansible multiple times. This is only necessary if the ansible-setup branch is used.

8) One of the stages in the pipeline requires Docker login information. You can set this up in Jenkins credentials. Save it as the same name as the registryCredentials in the Jenkinsfile. Also edit the registry in the Jenkinsfile to match your repo on Docker hub.

9) Once all this is done you can start working on Jenkins. Install BlueOcean for a nice interface. Setup up your CI/CD pipeline and everything should run smoothly. Note your IAM user should have permissions to use EKS.

10) You might get blocked by RBAC policies while trying to access the cluster. Basically, RBAC policies set to restrict the resources you use and limits a few of your action. Visit this link to see how to resolve this.

11) A command line tool 'sed' is used in updating the kubernetes configuration file in other to force the pods to update with the new image. The reason for this is that Kubernetes (wrongly) considers Docker tags as immutable (i.e., once a tag is set, it is never changed). The rolling update is also activated by the change in image name.

๐Ÿ“ƒ Local Docker and Kubernetes Setup

To run this app using docker, a script has been attached that builds an image from the Dockerfile and spins up a container running the web app:

โ ./run_docker.sh

There is also a script that uploads the Docker image to a designated repo. This should be edited before execution:

โ ./upload_docker.sh

A script that deploys the Docker Image to a local Kubernetes Cluster is also available:

โ ./run_kubernetes.sh

Please view the aforementioned scripts before running to understand the logic behind them.

Happy developing!

udacity-devops-capstone-project's People

Contributors

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