The system provides next functionality:
- view list of warehouses, items and warehouse items
- add or edit an item with particular price
- add, edit or delete an item to/from warehouse with particular amount
Note. Warehouses, Items and WarehouseItems -- are different tables.
Languages, technologies, instruments, etc.:
- OOP and SOLID principles
- only server side (WebAPI controllers)
- .NET Core
- EF Core
- PostgreSQL
- integration tests (webhost, xUnit)
- docker
- docker-compose
- kubernetes (minikube)
- helm
- curl
- PowerShell
| Id | Name | Price |
|---|---|---|
| 1 | pencil | 10.00 |
| 2 | pen | 20.00 |
| 3 | felt-tip pen | 30.00 |
| Id | Name | MaximumItems |
|---|---|---|
| 1 | miniature | 100 |
| 2 | decent | 10000 |
| 3 | hefty | 1000000 |
| Id | WarehouseId | ItemId | Count |
|---|---|---|---|
| 1 | 1 | 1 | 50 |
| 2 | 2 | 2 | 5000 |
| 3 | 3 | 3 | 500000 |
dotnet run --project WMS.UI/WMS.UI.csproj| # | GET | POST | PUT | DELETE |
|---|---|---|---|---|
| Warehouses | ✔️ | ❌ | ❌ | ❌ |
| Items | ✔️ | ✔️ | ✔️ | ❌ |
| WarehouseItems | ✔️ | ✔️ | ✔️ | ✔️ |
- Get Docker
- Dockerfile reference
- Dockerize an ASP.NET Core application
- postgres - How to use this image
- Network settings
docker build -t wms:latest .
# docker tag <image>:<tag> <login>/<image>:<tag>
docker tag wms:latest rhinock/wms:latest
# docker push <login>/<image>:<tag>
docker push rhinock/wms:latest
docker image ls -adocker image rm rhinock/wms:latest
docker image rm wms:latest
docker image rm mcr.microsoft.com/dotnet/sdk:3.1-alpine
docker image rm mcr.microsoft.com/dotnet/aspnet:3.1-alpine
docker image prune -f
docker volume prune -f
docker image ls -a
docker volume lsdocker network create app --driver bridge
docker run --name postgres -e POSTGRES_PASSWORD=1234 -e POSTGRES_DB=WMS -d --network=app postgres:12-alpine
docker run --name wms -e ConnectionStrings__WmsDbContextPostgres="Host=postgres;Port=5432;Database=WMS;Username=postgres;Password=1234" -d --network=app -p 8080:80 rhinock/wms:latest
docker network ls
docker image ls -a
docker container ls -adocker container rm -f wms
docker container rm -f postgres
docker image rm postgres:12-alpine
docker image rm rhinock/wms:latest
docker network rm app
docker volume prune -f
docker network ls
docker image ls -a
docker volume ls
docker container ls -adocker run --name postgres -e POSTGRES_PASSWORD=1234 -e POSTGRES_DB=WMS -d postgres:12-alpine
docker run --name wms -e ConnectionStrings__WmsDbContextPostgres="Host=postgres;Port=5432;Database=WMS;Username=postgres;Password=1234" -d -p 8080:80 --link postgres:postgres rhinock/wms:latest
docker image ls -a
docker container ls -a
docker exec postgres env | grep 'POSTGRES_PASSWORD\|POSTGRES_DB'
docker exec wms env | grep ConnectionStrings__WmsDbContextPostgresdocker exec -it postgres psql -U postgres# list databases
\l
# connect to database 'WMS'
\c WMS
# list all schemas
\dn
# list all tables in schema 'public'
\dt public.*
# select data from all tables
SELECT * FROM public."Items";
SELECT * FROM public."Warehouses";
SELECT * FROM public."WarehouseItems";
# delete non-initial data
DELETE FROM public."Items" WHERE "Id">3;
DELETE FROM public."WarehouseItems" WHERE "Id">3;
docker container rm -f wms
docker container rm -f postgres
docker image rm postgres:12-alpine
docker image rm rhinock/wms:latest
docker volume prune -f
docker image ls -a
docker volume ls
docker container ls -a- Install Docker Compose
- Get started with Docker Compose
- How to dockerize my dotnet core + postgresql app?
- Docker-compose override not overriding connection string
- docker-compose.yml
- images:
- db-data (data for postgres)
- volume for docker-compose
- for database recreating should be removed manually
- docker-compose.yml
docker-compose up -d
docker network ls
docker image ls -a
docker container ls -adocker-compose down
docker image rm rhinock/wms:latest
docker image rm postgres:12-alpine
docker image rm mcr.microsoft.com/dotnet/sdk:3.1-alpine
docker image rm mcr.microsoft.com/dotnet/aspnet:3.1-alpine
docker image prune -f
docker volume prune -f
docker network ls
docker image ls -a
docker volume ls
docker container ls -adocker-compose pull
docker-compose up -d
docker network ls
docker image ls -a
docker volume ls
docker container ls -adocker-compose down
docker image rm postgres:12-alpine
docker image rm rhinock/wms:latest
docker volume prune -f
docker network ls
docker volume ls
docker image ls -a
docker container ls -a- minikube start
- kubectl Cheat Sheet
- Hack the StorageClass
- StatefulSets Components
- Connectionstring that an pod should use to connect to an postgresql pod in same cluster?
- The Ingress resource
- Ingress Path Matching
# <minikube ip> wms.com
192.168.49.2 wms.comk apply -f k8s/k delete -f k8s/
k delete pvc pg-data-postgres-statefulset-0k get sc
k get pv
k get pvc
k get sts
k get deploy
k get rs
k get svc
k get ingress
k get endpoints
k get po- Installing Helm
- Getting Started
- Helm Create
- Helm Template
- Built-in Objects
{{ .Chart.Name }}
- Values not exist with loop over a range
{{- $root := . -}}{{ $root.Values.service.port }}
- Kubernetes Helm, combine two variables with a string in the middle
"{{ $root.Chart.Name }}-service"
- Helm Install
- Helm Get Manifest
- Helm Upgrade
- Helm History
- Helm Rollback
- Helm Uninstall
helm template charthelm create charttar -cvzf chart.tgz chartOutput:
chart/
chart/Chart.yaml
chart/values.yaml
chart/.helmignore
chart/templates/
chart/templates/ingress.yaml
chart/templates/wms-service.yml
chart/templates/wms-deployment.yml
chart/templates/postgres-statefulset.yaml
chart/templates/postgres-service.yaml
chart/templates/storageClass.yaml
helm install wms chart.tgzhelm install wms chart/helm upgrade wms chart/helm history wmshelm rollback wms 1helm uninstall wms
k delete pvc pg-data-wms-postgres-statefulset-0helm list
helm get manifest wms
helm get manifest wms --revision 1
helm get manifest wms --revision 2k get sc
k get pv
k get pvc
k get sts
k get deploy
k get rs
k get svc
k get ingress
k get endpoints
k get poNew-Item -Type Directory -Name PowerShell# Use splatting technique to make it more readable
$ModuleManifestParams = @{
Path = "PowerShell\WMS.psd1" # Notice that the psd1 file has the same name as the folder it resides in
Guid = [GUID]::NewGuid().Guid # A unique GUID for the module for identification
Author = "Your Name Here" # Optional
CompanyName = "Company Name here" # Optional
ModuleVersion = "0.0.1" # Semantic versioning as recommended best practice for PowerShell modules
Description = "A PowerShell module to interact with the HttpBin API" # A short description of what the module does
}
# Run New-ModuleManifest with the splatted parameters
New-ModuleManifest @ModuleManifestParamsNew-Item -ItemType File -Path PowerShell\ -Name WMS.psm1The .psm1 file is the file that will hold all module functions. Creating the PowerShell module file (.psm1) is just as simple as using PowerShell editor of our choice to create a new, blank text file at the C:.psm1 path.
$script:BaseUri = "api"
$script:InvokeParams = @{
ContentType = "application/json"
}Now that you've created the first function in the module, it's time to start using it. Import the module using the Import-Module command as shown below.
Import-Module -Name .\PowerShell\WMS.psm1 -Verbose -Forcecurl variables:
# local deployment
HOST=localhost:5000
# docker and docker-compose
HOST=localhost:8080
# kubernetes (minikube) and helm
HOST=wms.com:80PowerShell parameters:
# local deployment
-Protocol https
-Host localhost
-Port 44385
# docker and docker-compose
-Protocol http
-Host localhost
-Port 8080
# kubernetes (minikube) and helm
-Protocol http
-Host wms.com
-Port 80curl -v -H "Content-Type: application/json" http://$HOST/api/warehouses
curl -v -H "Content-Type: application/json" http://$HOST/api/warehouses/1GetObjects -Objects Warehouses
GetObjects -Objects Warehouses -Id 1curl -v -H "Content-Type: application/json" http://$HOST/api/warehouses/999GetObjects -Objects Warehouses -Id 999curl -v -H "Content-Type: application/json" http://$HOST/api/items
curl -v -H "Content-Type: application/json" http://$HOST/api/items/1GetObjects -Objects Items
GetObjects -Objects Items -Id 1curl -v -H "Content-Type: application/json" http://$HOST/api/items/999GetObjects -Objects Items -Id 999curl -v -H "Content-Type: application/json" -X POST http://$HOST/api/items -d @"payload/CreateItem.json"PostOrPutObject -Objects Items -Method Post -JsonFilePath .\payload\CreateItem.jsoncurl -v -H "Content-Type: application/json" -X POST http://$HOST/api/items -d @"payload/CreateItemWithId.json"
curl -v -H "Content-Type: application/json" -X POST http://$HOST/api/items -d @"payload/CreateItemWithNegativePrice.json"PostOrPutObject -Objects Items -Method Post -JsonFilePath .\payload\CreateItemWithId.json
PostOrPutObject -Objects Items -Method Post -JsonFilePath .\payload\CreateItemWithNegativePrice.jsoncurl -v -H "Content-Type: application/json" -X PUT http://$HOST/api/items -d @"payload/UpdateItem.json"PostOrPutObject -Objects Items -Method Put -JsonFilePath .\payload\UpdateItem.jsoncurl -v -H "Content-Type: application/json" -X PUT http://$HOST/api/items -d @"payload/UpdateItemWithIncorrectId.json"
curl -v -H "Content-Type: application/json" -X PUT http://$HOST/api/items -d @"payload/UpdateItemWithIncorrectData.json"PostOrPutObject -Objects Items -Method Put -JsonFilePath .\payload\UpdateItemWithIncorrectId.json
PostOrPutObject -Objects Items -Method Put -JsonFilePath .\payload\UpdateItemWithIncorrectData.jsoncurl -v -H "Content-Type: application/json" http://$HOST/api/WarehouseItems
curl -v -H "Content-Type: application/json" http://$HOST/api/WarehouseItems/1GetObjects -Objects WarehouseItems
GetObjects -Objects WarehouseItems -Id 1curl -v -H "Content-Type: application/json" http://$HOST/api/WarehouseItems/999GetObjects -Objects WarehouseItems -Id 999curl -v -H "Content-Type: application/json" -X POST http://$HOST/api/warehouseitems -d @"payload/CreateWarehouseItem.json"PostOrPutObject -Objects WarehouseItems -Method Post -JsonFilePath .\payload\CreateWarehouseItem.jsoncurl -v -H "Content-Type: application/json" -X POST http://$HOST/api/warehouseitems -d @"payload/CreateWarehouseItemWithId.json"
curl -v -H "Content-Type: application/json" -X POST http://$HOST/api/warehouseitems -d @"payload/CreateWarehouseItemWithNegativeCount.json"PostOrPutObject -Objects WarehouseItems -Method Post -JsonFilePath .\payload\CreateWarehouseItemWithId.json
PostOrPutObject -Objects WarehouseItems -Method Post -JsonFilePath .\payload\CreateWarehouseItemWithNegativeCount.jsoncurl -v -H "Content-Type: application/json" -X PUT http://$HOST/api/warehouseitems -d @"payload/UpdateWarehouseItem.json"PostOrPutObject -Objects WarehouseItems -Method Put -JsonFilePath .\payload\UpdateWarehouseItem.jsoncurl -v -H "Content-Type: application/json" -X PUT http://$HOST/api/warehouseitems -d @"payload/UpdateWarehouseItemWithIncorrectId.json"
curl -v -H "Content-Type: application/json" -X PUT http://$HOST/api/warehouseitems -d @"payload/UpdateWarehouseItemWithIncorrectIds.json"
curl -v -H "Content-Type: application/json" -X PUT http://$HOST/api/warehouseitems -d @"payload/UpdateWarehouseItemWithIncorrectData.json"PostOrPutObject -Objects WarehouseItems -Method Put -JsonFilePath .\payload\UpdateWarehouseItemWithIncorrectId.json
PostOrPutObject -Objects WarehouseItems -Method Put -JsonFilePath .\payload\UpdateWarehouseItemWithIncorrectIds.json
PostOrPutObject -Objects WarehouseItems -Method Put -JsonFilePath .\payload\UpdateWarehouseItemWithIncorrectData.jsoncurl -v -H "Content-Type: application/json" -X DELETE http://$HOST/api/warehouseitems/1DeleteObject -Objects WarehouseItems -Id 1curl -v -H "Content-Type: application/json" -X DELETE http://$HOST/api/warehouseitems/999DeleteObject -Objects WarehouseItems -Id 999