In this project I create small library Microservices.csproj to improve my knowledge. It's very useful to add CRUD to your API. In this project I used pattern UnitOfWork.
Thank a lot Les Jackson for the course. Really good job and well prepared material. Link to the video - (https://www.youtube.com/watch?v=DgVjEo3OGBI)
- MS SQL Server & MS SQL Studio 18
- Rider 2022.1
- Docker Desktop & Kubernetes
- Postman
- .Net 5
- Entity Framework Core
- Installation Guide
- Rest API Endpoints (Local)
- Platform Service. - 1.Get all platform
- Platform Service. - 2.Get platform by id
- Platform Service. - 3.Post Platform to DB
- Platform Service. - 4.Put Platform in DB
- Platform Service. - 5.Delete Platform in DB
- Command Service. - 6.Get all platform
- Command Service. - 7.Get All command by platform id
- Command Service. - 8.Get Command by commandId with dependent platformId in DB
- Command Service. - 9.Post Commmand with dependent platformId
- Rest API Endpoints (K8S)
- Platform Service. - 1.Get all platform
- Platform Service. - 2.Get platform by id
- Platform Service. - 3.Post Platform to DB
- Platform Service. - 4.Put Platform in DB
- Platform Service. - 5.Delete Platform in DB
- Command Service. - 6.Get all platform
- Command Service. - 7.Get All command by platform id
- Command Service. - 8.Get Command by commandId with dependent platformId in DB
- Command Service. - 9.Post Commmand with dependent platformId
- Local
- 1.1. Clone repository from github https://github.com/kuzmiich/MicroservicesFullCourse
- 1.2. Update database to both microservices
dotnet ef database updateby terminal
- Deploy microservices to K8S
- 2.1. Create docker images
docker build -t opna/platformservice -f Dockerfile_PlatformService .
docker build -t opna/commandservice -f Dockerfile_CommandService .
- 2.2. Push images to https://hub.docker.com/ repository
docker push opna/platformservice (image_id/image_name)
docker push opna/commandservice (image_id/image_name)
- 2.3. Create K8S deployments
kubectl apply -f platforms-deployment.yaml
kubectl apply -f commands-deployment.yaml
kubectl apply -f ingress-service.yaml
kubectl apply -f local-pvc.yaml
kubectl apply -f platforms-nodeport-service.yaml
kubectl apply -f rabbitmq-deployment.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.3.1/deploy/static/provider/cloud/deploy.yaml
kubectl create secret generic mssql --from-literal=SA_PASSWORD="pass55word!"
kubectl apply -f mssql-platform-deployment.yaml- 2.4. Register hostname acme.com Add row '127.0.0.1 acme.com' into this file
C:\Windows\System32\drivers\etc\hosts
Get all
https://localhost:5001/api/platform/getAll
[
{
"id": 1,
"name": "Dot net 2",
"publisher": "Apple",
"cost": "Free"
},
{
"id": 2,
"name": "Sql Server Express",
"publisher": "Microsoft",
"cost": "Free"
},
{
"id": 3,
"name": "Kubernetes",
"publisher": "Cloud Native Computing Foundation",
"cost": "Free"
}
]Get platform with id=1
https://localhost:5001/api/platform/{id}
{
"id": 1,
"name": "Dot net 2",
"publisher": "Apple",
"cost": "Free"
}Post platform
https://localhost:5001/api/platform/
body
{
"Name": "Dot net",
"Publisher": "Facebook",
"Cost": "Free"
} {
"id": 4,
"name": "Dot net",
"publisher": "Facebook",
"cost": "Free"
}Put platform
https://localhost:5001/api/platform/
body
{
"id": 1,
"Name": "Dot net 3",
"Publisher": "Apple",
"Cost": "Free"
} {
"id": 1,
"name": "Dot net 3",
"publisher": "Apple",
"cost": "Free"
}Delete platform by id=1
https://localhost:5001/api/platform/{id}
{
"id": 1,
"name": "Dot net 3",
"publisher": "Apple",
"cost": "Free"
}Get all
https://localhost:6001/api/c/platform/GetAll
[
{
"id": 1,
"name": "Platform 1"
},
{
"id": 2,
"name": "Platform 2"
},
{
"id": 3,
"name": "Platform 3"
}
]Get commands by platformId=1
https://localhost:6001/api/c/platform/{platformId}/command/GetAll
[
{
"id": 1,
"platformId": 1,
"howToDoActivity": "Build image",
"commandLine": "docker build -t (image_id/image_name) -f (Dockerfile_Name) ."
},
{
"id": 5,
"platformId": 1,
"howToDoActivity": "string",
"commandLine": "string"
},
{
"id": 6,
"platformId": 1,
"howToDoActivity": "string",
"commandLine": "string"
}
]Get command with commandId=1 & platformId=1
https://localhost:6001/api/c/platform/{platformId}/command/{commandId}
{
"id": 1,
"platformId": 1,
"howToDoActivity": "Build image",
"commandLine": "docker build -t (image_id/image_name) -f (Dockerfile_Name) ."
}Post command with platformId=1
https://localhost:6001/api/c/platform/{platformId}/command
body
{
"howToDoActivity": "string",
"commandLine": "string"
}{
"id": 0,
"platformId": 1,
"howToDoActivity": "string",
"commandLine": "string"
}Get all
http://acme.com/api/platform/getAll
[
{
"id": 1,
"name": "Dot net 2",
"publisher": "Apple",
"cost": "Free"
},
{
"id": 2,
"name": "Sql Server Express",
"publisher": "Microsoft",
"cost": "Free"
},
{
"id": 3,
"name": "Kubernetes",
"publisher": "Cloud Native Computing Foundation",
"cost": "Free"
}
]Get platform with id=1
http://acme.com/api/platform/{id}
{
"id": 1,
"name": "Dot net 2",
"publisher": "Apple",
"cost": "Free"
}Post platform
http://acme.com/api/platform/
body
{
"Name": "Dot net",
"Publisher": "Facebook",
"Cost": "Free"
} {
"id": 4,
"name": "Dot net",
"publisher": "Facebook",
"cost": "Free"
}Put platform
http://acme.com/api/platform/
body
{
"id": 1,
"Name": "Dot net 3",
"Publisher": "Apple",
"Cost": "Free"
} {
"id": 1,
"name": "Dot net 3",
"publisher": "Apple",
"cost": "Free"
}Delete platform by id=1
http://acme.com/api/platform/{id}
{
"id": 1,
"name": "Dot net 3",
"publisher": "Apple",
"cost": "Free"
}Get all
http://acme.com/api/c/platform/GetAll
[
{
"id": 1,
"name": "Platform 1"
},
{
"id": 2,
"name": "Platform 2"
},
{
"id": 3,
"name": "Platform 3"
}
]Get commands by platformId=1
http://acme.com/api/c/platform/{platformId}/command/GetAll
[
{
"id": 1,
"platformId": 1,
"howToDoActivity": "Build image",
"commandLine": "docker build -t (image_id/image_name) -f (Dockerfile_Name) ."
},
{
"id": 5,
"platformId": 1,
"howToDoActivity": "string",
"commandLine": "string"
},
{
"id": 6,
"platformId": 1,
"howToDoActivity": "string",
"commandLine": "string"
}
]Get command with commandId=1 & platformId=1
http://acme.com/api/c/platform/{platformId}/command/{commandId}
{
"id": 1,
"platformId": 1,
"howToDoActivity": "Build image",
"commandLine": "docker build -t (image_id/image_name) -f (Dockerfile_Name) ."
}Post command with platformId=1
http://acme.com/api/c/platform/{platformId}/command
body
{
"howToDoActivity": "string",
"commandLine": "string"
}{
"id": 0,
"platformId": 1,
"howToDoActivity": "string",
"commandLine": "string"
}