Developer’s Life with Microservices made easy with Tye

Gayan Fonseka
5 min readMay 24, 2020

Having to develop microservices-based solutions throws various challenges at the team and at the forefront of all that are the developers. I’ll have to fill the article with challenges if I were to write all of them but to name a few faced by developers, running multiple services manually from different IDEs (two, three backend services and a front-end), discover services when they are running locally, view logs and identify issues, deploy are some of them.

To address all the above issues and to make developing, testing, and deploying microservices and distributed systems easier Microsoft has come up with a solution named Tye.

The benefits of Tye

  1. Running many services from one command
  2. Service Discovery via configuration conventions
  3. Logs, metrics and etc displayed locally in a Dashboard
  4. Run docker dependencies such as Databases, Caching &, etc
  5. Automatically containerize .Net applications
  6. Deploy to Kubernetes, locally or cloud

All of the above is done with a single configuration file.

Let’s take a tour of Tye

Make sure you have Dot Net Core 3.1 installed. After the confirmation run the following command to get Tye installed,

dotnet tool install -g Microsoft.Tye --version "0.2.0-alpha.20258.3"

Now that we have Tye installed, let’s create two services one frontend application and one backend application so that we can check if we are able to do the stuff mentioned above. Run the following commands one after another,

dotnet new razor -n frontend
dotnet new webapi -n backend
dotnet new sln
dotnet sln add frontend backend

I did all of these in a folder called TryTye and the output is as follows,

Then open the folder you created in VS Code to see the files that are there.

Now that we know that both the applications are available as a single solution let’s run the command,

Tye run

The above shows how tye is building, running, and monitoring the applications. Now let me navigate to http://127.0.0.1:8000 to view the dashboard.

I can see the two services that I included in the solution shown in the dashboard. The Bindings column has links to the listening URLs of the service and you can view the logs by clicking on view in the Logs column.

Now if you have created a webapi project (our backend) you’ll know that it creates a WeatherForecast controller by default and I am going to create a similar class in the frontend and add a little bit of code so that the frontend will show the data coming from the backend. The code is as follows,

The entire source code could be found here in Github.

Now when you run the command: Tye run and navigate to http://localhost:8000/ you will see both the projects and clicking on Binding for front-end will show a page with data.

What did Tye do up to now

Tye made it possible for the frontend to find the backend based on the following,

services.AddHttpClient<WeatherClient>(client => { client.BaseAddress = Configuration.GetServiceUri(“backend”); });

That is based on the name of the service (At this point the project name “backend”) the frontend was able to communicate with the backend. Also, it allocated the necessary ports for the services, so that there won’t be any conflict. That is a great deal.

Time to Deploy

The deployment can be done to a local Kubernetes cluster or to any other provider of your choice which may include any cloud vendor. I’ll be deploying to my local machine where I have installed Docker Desktop. For this, I’ll be running the following command,

Tye deploy --interactive

In the process of deployment, it will do the following things

  • Create a docker image for each project in the solution
  • Push each docker image to your container registry (Dockerhub in my case).
  • Generate a Kubernetes Deployment and Service for each project.
  • Apply the generated Deployment and Service to your current Kubernetes context.

I have cleared the default namespace and there are no pods

Gave it a try from a Windows PowerShell as well.

The deployment was successful. The next step was to do a port forwarding so that I could test if the frontend works.

I was able to access the site which was hosted in Kubernetes from my local machine. You can add containers with other software such as SQL Server, Redis and etc to the tye.yaml file so that they all get deployed to cater to your needs.

This is a cool gift from Microsoft to the developers. They mention this as an experiment but I have a strong feeling these features are there to stay.

--

--