Skip to content

kuzmiich/MicroservicesFullCourse

Repository files navigation

Microservices course


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)

Used tools:

  • MS SQL Server & MS SQL Studio 18
  • Rider 2022.1
  • Docker Desktop & Kubernetes
  • Postman
  • .Net 5
  • Entity Framework Core

Table of Contents

Installation Guide

  1. Local

  1. 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 .
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

Rest API Endpoints Local

1 Platform Service Get All Platform

Request

Get all

https://localhost:5001/api/platform/getAll

Response

[
    {
        "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"
    }
]

2 Platform Service Get Platform By Id

Request

Get platform with id=1

https://localhost:5001/api/platform/{id}

Response

{
    "id": 1,
    "name": "Dot net 2",
    "publisher": "Apple",
    "cost": "Free"
}

3 Platform Service Post Platform to DB

Request

Post platform

https://localhost:5001/api/platform/

body

{
    "Name": "Dot net",
    "Publisher": "Facebook",
    "Cost": "Free"
}    

Response

{
    "id": 4,
    "name": "Dot net",
    "publisher": "Facebook",
    "cost": "Free"
}

4 Platform Service Put Platform in DB

Request

Put platform

https://localhost:5001/api/platform/

body

{
    "id": 1,
    "Name": "Dot net 3",
    "Publisher": "Apple",
    "Cost": "Free"
}    

Response

{
    "id": 1,
    "name": "Dot net 3",
    "publisher": "Apple",
    "cost": "Free"
}

5 Platform Service Delete Platform in DB

Request

Delete platform by id=1

https://localhost:5001/api/platform/{id}

Response

{
    "id": 1,
    "name": "Dot net 3",
    "publisher": "Apple",
    "cost": "Free"
}

6 Command Service Get All Platform

Request

Get all

https://localhost:6001/api/c/platform/GetAll

Response

[
    {
        "id": 1,
        "name": "Platform 1"
    },
    {
        "id": 2,
        "name": "Platform 2"
    },
    {
        "id": 3,
        "name": "Platform 3"
    }
]

7 Command Service Get All Command By Platform Id

Request

Get commands by platformId=1

https://localhost:6001/api/c/platform/{platformId}/command/GetAll

Response

[
    {
        "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"
    }
]

8 Command Service Get command by commandId with dependent platformId

Request

Get command with commandId=1 & platformId=1

https://localhost:6001/api/c/platform/{platformId}/command/{commandId}

Response

{
    "id": 1,
    "platformId": 1,
    "howToDoActivity": "Build image",
    "commandLine": "docker build -t (image_id/image_name) -f (Dockerfile_Name) ."
}

9 Command Service Post command with dependent platformId

Request

Post command with platformId=1

https://localhost:6001/api/c/platform/{platformId}/command

body

{
    "howToDoActivity": "string",
    "commandLine": "string"
}

Response

{
    "id": 0,
    "platformId": 1,
    "howToDoActivity": "string",
    "commandLine": "string"
}

Rest API Endpoints K8S

10 Platform Service Get All Platform

Request

Get all

http://acme.com/api/platform/getAll

Response

[
    {
        "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"
    }
]

11 Platform Service Get platform by id

Request

Get platform with id=1

http://acme.com/api/platform/{id}

Response

{
    "id": 1,
    "name": "Dot net 2",
    "publisher": "Apple",
    "cost": "Free"
}

12 Platform Service Post Platform to DB

Request

Post platform

http://acme.com/api/platform/

body

{
    "Name": "Dot net",
    "Publisher": "Facebook",
    "Cost": "Free"
}    

Response

{
    "id": 4,
    "name": "Dot net",
    "publisher": "Facebook",
    "cost": "Free"
}

13 Platform Service Put Platform in DB

Request

Put platform

http://acme.com/api/platform/

body

{
    "id": 1,
    "Name": "Dot net 3",
    "Publisher": "Apple",
    "Cost": "Free"
}    

Response

{
    "id": 1,
    "name": "Dot net 3",
    "publisher": "Apple",
    "cost": "Free"
}

14 Platform Service Delete Platform in DB

Request

Delete platform by id=1

http://acme.com/api/platform/{id}

Response

{
    "id": 1,
    "name": "Dot net 3",
    "publisher": "Apple",
    "cost": "Free"
}

15 Command Service Get all platform

Request

Get all

http://acme.com/api/c/platform/GetAll

Response

[
    {
        "id": 1,
        "name": "Platform 1"
    },
    {
        "id": 2,
        "name": "Platform 2"
    },
    {
        "id": 3,
        "name": "Platform 3"
    }
]

16 Command Service Get all command by platform id

Request

Get commands by platformId=1

http://acme.com/api/c/platform/{platformId}/command/GetAll

Response

[
    {
        "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"
    }
]

17 Command Service Get command by commandId with dependent platformId

Request

Get command with commandId=1 & platformId=1

http://acme.com/api/c/platform/{platformId}/command/{commandId}

Response

{
    "id": 1,
    "platformId": 1,
    "howToDoActivity": "Build image",
    "commandLine": "docker build -t (image_id/image_name) -f (Dockerfile_Name) ."
}

18 Command Service Post command with dependent platformId

Request

Post command with platformId=1

http://acme.com/api/c/platform/{platformId}/command

body

{
    "howToDoActivity": "string",
    "commandLine": "string"
}

Response

{
    "id": 0,
    "platformId": 1,
    "howToDoActivity": "string",
    "commandLine": "string"
}

Releases

No releases published

Languages