Sign inSign up

denizgokcin/hepsiburada-devops-challenge

By denizgokcin

•Updated over 5 years ago

A simple Flask web-app for Hepsiburada's DevOps challenge

Image
0

2.7K

denizgokcin/hepsiburada-devops-challenge repository overview

⁠hepsiburada-devops-challenge

⁠DevOps Challenge

This challenge should demonstrate that you understand the world of containers and microservices. We want to build a simple but resilient Hello World app, deploy it to Kubernetes as a minimal. There are 4 main Challenges:

  • writing a Docker container
  • automating the build of the container
  • defining the whole infrastructure as code
  • Autoscale k8s cluster
⁠Demo

gif

⁠Tech-Stack
  • kubespray: Kubespray is a composition of Ansible playbooks, inventory, provisioning tools, and domain knowledge for generic OS/Kubernetes clusters configuration management tasks. Kubespray provides: a highly available cluster. composable attributes. support for most popular Linux distributions
  • flask-prometheus-exporter: A python Library used for generating metrics that prometheus can scrape.
  • helm: A package manager for kubernetes. Used in the deployment of prometheus-operator and prometheus-adapter.
  • prometheus: Prometheus is a free software application used for event monitoring and alerting. It records real-time metrics in a time series database built using a HTTP pull model, with flexible queries and real-time alerting.
  • prometheus-operator: Prometheus Operator is a tool created by CoreOS to simplify deployment and management of Prometheus instances in K8s.
  • prometheus-adapter: Prometheus Adapter is required for using Custom Metrics API in K8s. It is used primarily for Horizontal Pod Autoscaler to scale based on metrics retrieved from Prometheus.
  • github-actions: GitHub actions is used to automatically deploy docker images and update the hello-hepsiburada deployment in kubernetes with ssh. Check out main.yml⁠ to view the entire pipeline.
  • kubernetes-python-client: The Python Client of Kubernetes is used to list cluster objects in the cluster.
⁠Servers
  • 3 Ubuntu instances in the LONDON region with the following specs were used.
    R Linux DistroSpecsRegionIPv4private IP
    Ubuntu 20.04 (LTS) x641vCPUs 2GB / 50GB Disk ($10/mo)LON138.68.188.21710.106.0.2
    Ubuntu 20.04 (LTS) x641vCPUs 2GB / 50GB Disk ($10/mo)LON138.68.179.9810.106.0.4
    Ubuntu 20.04 (LTS) x641vCPUs 2GB / 50GB Disk ($10/mo)LON138.68.179.9810.106.0.3
⁠Installation
⁠Deploying a kubernetes cluster using kubespray

ansible-playbook -i hosts.ini --become --become-user=root kubespray/cluster.yml

⁠Installing kube-prometheus-stack and prometheus-adapter with helm using custom helm values
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm install prometheus-operator prometheus-community/kube-prometheus-stack -f k8s/helm-values/prometheus-operator-values.yml
helm install prometheus-adapter prometheus-community/prometheus-adapter -f k8s/helm-values/prometheus-adapter-values.yml
⁠Deploying the hello-hepsiburada app

kubectl apply -f k8s/webapp

⁠Screenshots

pic pic

⁠Deployed Apps
⁠Resource Collector(Bonus)
  • The resource collector script⁠, can be used to list the cluster resources. pic
⁠Notes

Use this command to watch the horizontal pod autoscaler, deployments and pods.

watch -n 1 "kubectl get hpa,deployment,pods -o wide && kubectl top nodes"

Use this command to trigger the horizontal pod autoscaler.

while true; do sleep 1; curl http://138.68.188.217:32472; echo -e '\n\n\n\n'$(date);done

Tag summary

Content type

Image

Digest

Size

123.1 MB

Last updated

over 5 years ago

docker pull denizgokcin/hepsiburada-devops-challenge