k8s set up ready

This commit is contained in:
Mikhail Shabanov committed 2021-01-07 13:38:37 +01:00
1 parent 36f02ce738
commit 480c453bfa
4 files changed
+85 -6

No files matched your search

+64 -5
View File
@@ -7,10 +7,10 @@ Detailed player & tank statistics and history for [World of Tanks: Blitz](ht
## Technologies used:
- Backend - GraphQL API based on .Net core 3 Web server ([GraphQL HotChocolate](https://hotchocolate.io/) + MongoDB)
- Backend - GraphQL API based on .NET 5.0 Web server ([GraphQL HotChocolate](https://hotchocolate.io/) + MongoDB)
- Frontent - Blazor WebAssembly (coming soon)
### Local MongoDB Installation for debugging ([Docker desktop for Windows](https://www.docker.com/products/docker-desktop))
## Local MongoDB Installation for debugging ([Docker desktop for Windows](https://www.docker.com/products/docker-desktop))
For the developing and debugging purposes, you have to istall MongoDB locally on your dev machine and run it as a service. Alternatively, if you have istalled [Docker desktop for Windows](https://www.docker.com/products/docker-desktop), you can deploy MongoDB inside the container. To do so, create an empty folder and make 2 files there: ```docker-compose.yml``` and ```.env```. Second one will contain sensitive data.
<details>
@@ -80,7 +80,7 @@ To use this mongo instance in application, use this connection string in ```apps
}
```
### Backup and restore database using mongodump/mongorestore
## Backup and restore database using mongodump/mongorestore
[Mongudump/mongorestore documentation](https://docs.mongodb.com/manual/tutorial/backup-and-restore-tools/)
@@ -98,9 +98,68 @@ mongodump --host=localhost --port=27017 --username=root --password="[YOUR PASSWO
mongorestore --host=localhost --port=27017 --username=root --password="[YOUR PASSWORD]" --authenticationDatabase=admin mongodump-2020-12-27
```
## Deploying solution using docker-compose
1. First, build container image to have it locally:
```bash
- docker build -t mike/wot-blitz-statistics-pro:v1 .
```
2. Create environment file `.env` and fill the values in it (without square brackets):
```env
WARGAMING_APPLICATION_ID=[your_application_id]
MONGO_CONNECTION_STRING=mongodb://[your_db_user]:[your_db_password]@mongo:27017/?authSource=admin
MONGO_DATABASE_NAME=WotBlitzStatisticsPro
DB_USERNAME=[your_db_user]
DB_PASSWORD=[your_db_password]
```
3. Deploy application, using command:
```bash
docker-compose up -d
```
4. Navigate to http://localhost:8000 (or http://localhost:8000/graphql/ for GraphQl playground)
5. Do delete the deployment, use command:
```bash
docker-compose down
```
## Deploying solution using Kubernetes and kubectl
1. First, build container image to have it locally:
```bash
- docker build -t mike/wot-blitz-statistics-pro:v1 .
```
2. Create a k8s `secret` and fill the values in it (without square brackets), using command:
```bash
kubectl create secret generic wot-blitz-statistics-secret --from-literal='MONGO_INITDB_ROOT_PASSWORD=[your_db_password]' --from-literal='MONGO_INITDB_ROOT_USERNAME=[your_db_user]' --from-literal='Mongo__ConnectionString=mongodb://[your_db_user]:[your_db_password]@wot-blitz-statistics-pro-app-mongo-service:27027/?authSource=admin' --from-literal='Mongo__DatabaseName=WotBlitzStatisticsPro' --from-literal='WargamingApi__ApplicationId=[your_application_id]'
```
3. Deploy application, using command:
```bash
kubectl apply -f k8s
```
4. Navigate to http://localhost:8040 (or http://localhost:8040/graphql/ for GraphQl playground)
5. Do delete the deployment, use command:
```bash
kubectl delete -f k8s
```
### Hosting solution (k8s)
(Coming soon)
## Contact me:
[[email protected]](mailto:[email protected])
+1 -1
View File
@@ -1,7 +1,7 @@
version: "3"
services:
web:
image: "mike/wot-blitz-statistics-pro:latest"
image: "mike/wot-blitz-statistics-pro:v1"
ports:
- "8000:80"
container_name: "wot-blitz-statististics-web"
+8
View File
@@ -19,7 +19,15 @@ spec:
containers:
- env:
- name: MONGO_INITDB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: wot-blitz-statistics-secret
key: MONGO_INITDB_ROOT_PASSWORD
- name: MONGO_INITDB_ROOT_USERNAME
valueFrom:
secretKeyRef:
name: wot-blitz-statistics-secret
key: MONGO_INITDB_ROOT_USERNAME
image: mongo
imagePullPolicy: ""
name: wot-blitz-statistics-mongo
+12
View File
@@ -18,8 +18,20 @@ spec:
containers:
- env:
- name: Mongo__ConnectionString
valueFrom:
secretKeyRef:
name: wot-blitz-statistics-secret
key: Mongo__ConnectionString
- name: Mongo__DatabaseName
valueFrom:
secretKeyRef:
name: wot-blitz-statistics-secret
key: Mongo__DatabaseName
- name: WargamingApi__ApplicationId
valueFrom:
secretKeyRef:
name: wot-blitz-statistics-secret
key: WargamingApi__ApplicationId
image: mike/wot-blitz-statistics-pro:v1
imagePullPolicy: ""
name: wot-blitz-statististics-web