- Flask
- SQLAlchemy
- Flask-Migrate
- Postgres
- Gunicorn
- PyJWT
- Github Actions
- Prometheus
- Grafana
- Docker & docker-compose
- Kubernetes
- Minikube
- APIs:
- Prometheus
- Grafana
- Github Actions
docker-compose up -d
or
make minikube
make kubernetes
make databases
make kube-services
kubectl -n internet-banking get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
bank-account-svc ClusterIP 10.109.219.209 <none> 5002/TCP 18d
postgres-svc ClusterIP 10.107.25.52 <none> 5432/TCP 18d
user-svc ClusterIP 10.97.213.50 <none> 5001/TCP 18d
With httpie:
Notice that your services with Flask application has avaliable at 5001
, 5002
and 5003
port address. Use ingress
to acess then.
make kube-ingress
kubectl -n internet-banking get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
ingress ingress * 192.168.49.2 80 15d
http -f POST <ingress-address>:80/user username="user" email="user@teste.com" password="password123" name="user"
HTTP/1.1 200 OK
Connection: close
Content-Length: 54
Content-Type: application/json
Date: Sun, 14 Mar 2021 23:38:35 GMT
Server: gunicorn/20.0.4
[
{
"active": true,
"created": "2021-03-15T00:08:14.180200",
"email": "user@teste.com",
"id": 1,
"name": "user",
"username": "user"
}
]
http <ingress-address>:80/user
HTTP/1.1 200 OK
Connection: close
Content-Length: 54
Content-Type: application/json
Date: Sun, 14 Mar 2021 23:39:01 GMT
Server: gunicorn/20.0.4
[
{
"active": true,
"created": "2021-03-15T00:08:14.180200",
"email": "user@teste.com",
"id": 1,
"name": "user",
"username": "user"
}
]
http -f POST <ingress-address>:80/user/auth -a user:password123
HTTP/1.1 200 OK
Connection: close
Content-Length: 54
Content-Type: application/json
Date: Sun, 14 Mar 2021 23:39:01 GMT
Server: gunicorn/20.0.4
{
"expired": 1615813569.092066,
"token": "token"
}
It's important, just one time, to include a balance for user. In this case, use the POST method.
http -f POST <ingress-address>:80/bank_account/balance/ value="2500.00" 'Authorization: Bearer {token}'
HTTP/1.1 200 OK
Connection: close
Content-Length: 40
Content-Type: application/json
Date: Sun, 21 Mar 2021 13:58:50 GMT
Server: gunicorn/20.0.4
{
"id": 1,
"user_id": 1,
"value": 2500.0
}
Otherwise, GET method for check the balance.
http <ingress-address>:80/bank_account/balance/ 'Authorization: Bearer {token}'
HTTP/1.1 200 OK
Connection: close
Content-Length: 40
Content-Type: application/json
Date: Sun, 21 Mar 2021 13:58:50 GMT
Server: gunicorn/20.0.4
{
"id": 1,
"user_id": 1,
"value": 2500.0
}
http -f POST <ingress-address>:80/bank_account/credit value="2.6" 'Authorization: Bearer {token}'
HTTP/1.1 200 OK
Connection: close
Content-Length: 38
Content-Type: application/json
Date: Sat, 20 Mar 2021 22:33:03 GMT
Server: gunicorn/20.0.4
{
"id": 1,
"user_id": 1,
"value": 2.6
}
http -f POST <ingress-address>:80/bank_account/debit value="2.6" 'Authorization: Bearer {token}'
HTTP/1.1 200 OK
Connection: close
Content-Length: 38
Content-Type: application/json
Date: Sat, 20 Mar 2021 22:33:03 GMT
Server: gunicorn/20.0.4
{
"id": 1,
"user_id": 1,
"value": 2.6
}
http <ingress-address>:80/bank_account/statement 'Authorization: Bearer {token}'
HTTP/1.1 200 OK
Connection: close
Content-Length: 142
Content-Type: application/json
Date: Sun, 21 Mar 2021 13:57:57 GMT
Server: gunicorn/20.0.4
{
"credits": [
{
"id": 1,
"user_id": 1,
"value": 2.6
},
{
"id": 2,
"user_id": 1,
"value": 5.1
}
],
"debits": [
{
"id": 1,
"user_id": 1,
"value": 4.9
}
]
}
http://localhost:9090
http://localhost:3000
http://localhost:8081
docker exec jenkins cat /var/jenkins_home/secrets/initialAdminPassword
Copy the password and join the Jenkins plataform.