Skip to content

Testing Containerization and orchestration on local

Notifications You must be signed in to change notification settings

geeky-sh/load_testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Containerisation testing on local

(the name load_testing is deceptive. Beware!)

To run the app without docker

export FLASK_APP="app.app:app"
flask run

# OR
gunicorn app.app:app

Steps for configuring docker and kubectl:

  • Install minikube
  • create dockerfile for the project you are running
    • VSCode provides a docker plugin which automatically generates the docker file depending on the type of application
  • Test dockerfile and see if the application is running properly (See docker commands for more help)
  • Create deployment.yaml that contains deployment config for k8s
  • Create service.yaml that contains service config for k8s

Docker Standalone helpful commands:

docker build -f Dockerfile -t load_testing:v1 . # build image
docker run -p 5000:5000 load_testing:v1 # run container

Kubernetes Orchestration Steps for local:

minikube start # start local k8s cluster
kubectl create --filename deployment.yaml # create deployment in cluster
kubectl create --filename service.yaml # create service in cluster
minikube load image load_testing:v1 # get locally built image into minikube cluster
kubectl get all # get details of all pods, deployments, services
minikube tunnel # creates a tunnel from localip to all the loadbalancer services. Basically access the service from local
minikube service --url <service-name> # to get the customer url + port through which one can access the service

kubectl delete -f service.yaml # delete resource (deployment / service)
kubectl delete <resource> <name> # delete resource (deployment / service)
minikube delete # delete local kubernetes cluster

kubectl logs <resource>/<name> -f # view logs -f is for follow
kubectl exec -it pod/load-testing-5b696fc88c-57fdl -- /bin/bash # to get in a shell of a particular pod
kubectl port-forward pod/load-testing-5b696fc88c-57fdl 8000:5000 # forwarding port for a particular pod from local to pod. This is used for testing whether pod APIs are working fine

How to make life easy

Add the below lines in ~/.zshrc or ~/.bashrc

alias d="docker"
alias di="docker image"
alias dc="docker container"
alias dr="docker run"
alias kl="kubectl"
alias mk="minikube"

Info

  • Used locust to do load testing.

Remaining learnings:

  • Learn autoscale strategies and how to implement them.
    • Using locust lib, replicate load and see how autoscaling strategies work
  • Check how can images be loaded from remote server
  • Connect to an external database.
  • Install vault in minikube via helm to configure environment variables. Help

Ref:

About

Testing Containerization and orchestration on local

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published