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 -a
docker 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 ls
docker 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 -a
docker 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 -a
docker 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__WmsDbContextPostgres
docker 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 -a
docker-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 -a
docker-compose pull
docker-compose up -d
docker network ls
docker image ls -a
docker volume ls
docker container ls -a
docker-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.com
k apply -f k8s/
k delete -f k8s/
k delete pvc pg-data-postgres-statefulset-0
k 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 chart
helm create chart
tar -cvzf chart.tgz chart
Output:
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.tgz
helm install wms chart/
helm upgrade wms chart/
helm history wms
helm rollback wms 1
helm uninstall wms
k delete pvc pg-data-wms-postgres-statefulset-0
helm list
helm get manifest wms
helm get manifest wms --revision 1
helm get manifest wms --revision 2
k 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
New-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 @ModuleManifestParams
New-Item -ItemType File -Path PowerShell\ -Name WMS.psm1
The .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 -Force
curl variables:
# local deployment
HOST=localhost:5000
# docker and docker-compose
HOST=localhost:8080
# kubernetes (minikube) and helm
HOST=wms.com:80
PowerShell 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 80
curl -v -H "Content-Type: application/json" http://$HOST/api/warehouses
curl -v -H "Content-Type: application/json" http://$HOST/api/warehouses/1
GetObjects -Objects Warehouses
GetObjects -Objects Warehouses -Id 1
curl -v -H "Content-Type: application/json" http://$HOST/api/warehouses/999
GetObjects -Objects Warehouses -Id 999
curl -v -H "Content-Type: application/json" http://$HOST/api/items
curl -v -H "Content-Type: application/json" http://$HOST/api/items/1
GetObjects -Objects Items
GetObjects -Objects Items -Id 1
curl -v -H "Content-Type: application/json" http://$HOST/api/items/999
GetObjects -Objects Items -Id 999
curl -v -H "Content-Type: application/json" -X POST http://$HOST/api/items -d @"payload/CreateItem.json"
PostOrPutObject -Objects Items -Method Post -JsonFilePath .\payload\CreateItem.json
curl -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.json
curl -v -H "Content-Type: application/json" -X PUT http://$HOST/api/items -d @"payload/UpdateItem.json"
PostOrPutObject -Objects Items -Method Put -JsonFilePath .\payload\UpdateItem.json
curl -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.json
curl -v -H "Content-Type: application/json" http://$HOST/api/WarehouseItems
curl -v -H "Content-Type: application/json" http://$HOST/api/WarehouseItems/1
GetObjects -Objects WarehouseItems
GetObjects -Objects WarehouseItems -Id 1
curl -v -H "Content-Type: application/json" http://$HOST/api/WarehouseItems/999
GetObjects -Objects WarehouseItems -Id 999
curl -v -H "Content-Type: application/json" -X POST http://$HOST/api/warehouseitems -d @"payload/CreateWarehouseItem.json"
PostOrPutObject -Objects WarehouseItems -Method Post -JsonFilePath .\payload\CreateWarehouseItem.json
curl -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.json
curl -v -H "Content-Type: application/json" -X PUT http://$HOST/api/warehouseitems -d @"payload/UpdateWarehouseItem.json"
PostOrPutObject -Objects WarehouseItems -Method Put -JsonFilePath .\payload\UpdateWarehouseItem.json
curl -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.json
curl -v -H "Content-Type: application/json" -X DELETE http://$HOST/api/warehouseitems/1
DeleteObject -Objects WarehouseItems -Id 1
curl -v -H "Content-Type: application/json" -X DELETE http://$HOST/api/warehouseitems/999
DeleteObject -Objects WarehouseItems -Id 999