Skip to content

A sample project to implement a web api in kubernetes

License

Notifications You must be signed in to change notification settings

tadayoni1/books

Repository files navigation

books

A sample project to implement a web api in kubernetes.

This project first deploys a Kubernetes cluster in AWS. Then a Jenkins pipeline lints the python web api application in the python folder, containerizes it, and uploads it to AWS ECR. After that it deploys the application to AWS EKS with a rolling update strategy.

Prerequisites

  1. AWS Account
  2. A workstation(automation server) either local or on aws and install Terraform on it.
    1. The workstation should either have an IAM role with EC2 and VPC access or you need to install awscli and run aws configure and enter credentials that have access to create EC2 and VPC resources.
  3. Checkout the code to the automation server
  4. In parent directory of the code folder create a file named secret.tfvars and enter the IP's which you want to limit eks access to.
    1. my_workstations_ip = ["1.2.3.4/32", "5.6.7.8/32"]
  5. An S3 bucket. The same bucket must be used in provision_ekc.sh and user-data.sh.tpl for jenkins server.

Deployment Steps

  1. First we need to deploy an EKS cluster to AWS. It is done by terraform.
    1. run ./provision_eks.sh
  2. Then we need to deploy a jenkins server and then configure it. A launch template can be created by terraform that installs all the requirements for jenkins server to run the pipeline.
    1. run ./provision_jenkins_lc.sh
  3. After jenkins is running configure it and install all recommended plugins.
  4. Create following creadentials in form of a secret text in jenkins
    1. jenkins-aws-secret-key-id
    2. jenkins-aws-secret-access-key
  5. run sudo systemctl restart jenkins so jenkins can connect to docker

Jenkins Pipeline

After Kubernetes cluster is deployed and jenkins server is ready and configured, connect jenkins to the github repo and run the pipeline.

Other resources

Python web application has been imported from https://github.com/rmotr/flask-api-example.

About

A sample project to implement a web api in kubernetes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published