Skip to content

dkozlov/revolut

Repository files navigation

Home Task - SRE/DevOps Engineer

Build and push the image to Docker Hub

sudo make all

Docker Compose

Build the images and spin up the containers:

sudo docker-compose up -d --build

(Optional) Recreate the database:

sudo docker-compose exec server python manage.py recreate_db

Test it out at:

curl http://localhost:8080/hello/user -d '{"dateOfBirth":"2018-08-12"}' -H "Content-Type: application/json" -X PUT -v
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> PUT /hello/user HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.58.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 28
> 
* upload completely sent off: 28 out of 28 bytes
< HTTP/1.1 204 NO CONTENT
< Server: gunicorn/19.9.0
< Date: Mon, 12 Aug 2019 11:47:20 GMT
< Connection: close
< Content-Type: application/json
< Access-Control-Allow-Origin: *
< 
* Closing connection 0
curl http://localhost:8080/hello/user -v
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /hello/user HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.58.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: gunicorn/19.9.0
< Date: Mon, 12 Aug 2019 11:48:08 GMT
< Connection: close
< Content-Type: application/json
< Content-Length: 44
< Access-Control-Allow-Origin: *
< 
{"message": "Hello, user! Happy birthday!"}
* Closing connection 0
  1. http://localhost:8080/hello/user
  2. http://localhost:8080/healthz
  3. http://localhost:8080/readiness
  4. http://localhost:8080/metrics

Stop and remove containers, networks, images, and volumes:

sudo docker-compose down

  1. Install Google Cloud SDK Command-line interface for Google Cloud Platform products and services.
  2. You need to configure both auth application-default login and auth login
  3. After installing Google Cloud SDK you should have kubectl configured.

Once you authenticated successfully, credentials are preserved. To see a list of components that are available and currently installed, run gcloud components list

┌────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                 Components                                                 │
├───────────────┬──────────────────────────────────────────────────────┬──────────────────────────┬──────────┤
│     Status    │                         Name                         │            ID            │   Size   │
├───────────────┼──────────────────────────────────────────────────────┼──────────────────────────┼──────────┤
│ Installed     │ Cloud Storage Command Line Tool                      │ gsutil                   │  3.6 MiB │
│ Installed     │ gcloud Alpha Commands                                │ alpha                    │  < 1 MiB │
│ Installed     │ gcloud Beta Commands                                 │ beta                     │  < 1 MiB │
│ Installed     │ kubectl                                              │ kubectl                  │  < 1 MiB │
└───────────────┴──────────────────────────────────────────────────────┴──────────────────────────┴──────────┘
gcloud auth application-default login; gcloud auth login;

Start the cluster:

gcloud beta container clusters create "standard-cluster-2" \
 --machine-type "n1-standard-2" --image-type "COS" \
 --disk-type "pd-standard" --disk-size "100" \
 --preemptible --num-nodes "3" \
 --addons HorizontalPodAutoscaling,HttpLoadBalancing

Volume

Create the volume claim:

kubectl apply -f ./kubernetes/persistent-volume-claim.yml

Secrets

Create the secret object:

kubectl apply -f ./kubernetes/secret.yml

Postgres

Production HA-Postgres could be installed via helm chart, but we will use simplified deployment version

Create deployment:

kubectl create -f ./kubernetes/postgres-deployment.yml

Create the service:

kubectl create -f ./kubernetes/postgres-service.yml

Flask

Create the deployment:

kubectl create -f ./kubernetes/flask-deployment.yml

(Optional) Drop all entries in the database and recreate tables:

kubectl exec deployment.apps/server --stdin --tty -- python manage.py recreate_db

Create the service:

kubectl create -f ./kubernetes/flask-service.yml

Try it out:

export EXTERNAL_IP=`kubectl get services server --output jsonpath='{.status.loadBalancer.ingress[0].ip}'`

curl http://$EXTERNAL_IP/hello/user -d '{"dateOfBirth":"2018-08-12"}' -H "Content-Type: application/json" -X PUT -v
curl http://$EXTERNAL_IP/hello/user -v
curl http://$EXTERNAL_IP/healthz -v
curl http://$EXTERNAL_IP/metrics -v
curl http://$EXTERNAL_IP/readiness -v

To remove all deployments:

kubectl delete -f kubernetes/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors