Running Non-containerized Microservices

Whenever someone says orchestration for microservices, the first thing that usually comes to mind is Kubernetes. I believe that’s normal. I used to think the same but then I came across an interesting scenario that changed the way I used to think about microservice orchestration completely.

Usually, people think microservices mean containers, hence they build their application in a cloud-native approach so that it can easily run on any platform using the containerized approach. Well, I agree that containerization is a decent way of designing a cloud-native application especially when we integrate it with orchestrators like Kubernetes or OpenShift. It takes away a lot of overhead from us like:- scaling, failover, deployment, etc but it doesn’t imply that microservices can only be managed inside a containerized ecosystem. Microservice is an ideology or mindset for designing the application and containerization is a power-up that supports the ideology.

Now, I believe you guys must be thinking what could be the possible scenario that containerization cannot support. Well, the kind of application I was dealing with was .net based which can only run on Windows platform. Now, obviously, we could use windows containers and we did try it but it’s still in the development phase and will take time to mature. Another way was to use static VMs but that will be a wastage of resources. Therefore, we didn’t go with those options and went with another option i.e. “Nomad”.

Why Nomad?

Kubernetes is an orchestration system that is designed to manage the container ecosystem but, as we discussed, here we wanted to orchestrate a windows process (mainly windows IIS webserver-based process). It means we can say that Nomad is an orchestration engine that supports not only containerized but virtualized and standalone applications as well including Docker, Java, IIS on Windows, etc.

Nomad works in a plugin-based model in which you can leverage the existing plugins like Docker, Java, IIS or you can write a custom plugin as well using Golang-SDK.

Nomad doesn’t support Windows IIS webserver by default, to achieve this we need to install the plugin on the Nomad client nodes. We decided to go with the IIS plugin developed by Roblox Developers.

Check Here

Implementation using Nomad

While using the IIS plugin, we evaluated that there’re some gaps that needed to be filled. So we decided to add those features by ourselves. Additional features which we have added are:-

  • Resource Limit on IIS
  • Recycle Parameters
  • Environment Variables

Basic features of an orchestration engine was already supported by Nomad like:-

  • Scaling/Autoscaling
  • Failover
  • Metrics Monitoring
  • Service Discovery
  • Service Mesh

The plugin is available here.

Since we are assuming Nomad and Consul are already part of the setup, we can directly jump to the configuration part of the IIS Job. If you haven’t and want to setup Nomad quickly, please refer to this document.

job "iis-test" {
  datacenters = ["dc1"]
  type = "service"

  group "iis-test" {
    count = 1
    restart {
      attempts = 10
      interval = "5m"
      delay = "25s"
      mode = "delay"
    }
    task "iis-test" {
      driver = "win_iis"

      artifact {
        source = "https://github.com/iamabhishek-dubey/nomad-driver-iis/releases/download/v0.4/test-hello-world.zip"
      }
      config {
        path = "${NOMAD_TASK_DIR}\\netcoreapp2.1"

        apppool_identity {
          identity = "NetworkService"
        }

        bindings {
          type = "http"
          resource_port = "httplabel"
        }
      }
      resources {
        cpu    = 100
        memory = 20
        network {
          port "httplabel" {}
        }
      }
      service {
        name = "iis-test"
        tags = ["iis-test", "windows-iis-test"]
        port = "httplabel"
        check {
          type = "tcp"
          interval = "10s"
          timeout = "2s"
        }
      }
    }
  }
}

Once the job configuration is complete, we can create the job using the Nomad UI in our cluster.

Now, if you try to open the service on your browser, the content will look like this:-

So as we can see the application is working fine here, now let’s see the service health on consul as well.

As we can see the service looks healthy. Further, we can still try the orchestrator’s functionality, like, scaling. Scale the iis-test count and see what changes have been made by Nomad and Consul.

Once we have scaled the application count to 2, the nomad has started another IIS process for the application and the consul registered it as a second replica of the service. If we try to kill the process as well, the nomad will create another replica of the process just like Kubernetes ;).

If you want to access the code of the blog, please check this repository. All the configuration files for nomad and consul are present inside the repository. Also, if you want to test out this setup quickly, there is a Vagrantfile in the repository. To execute the vagrant we simply need to run:-

vagrant up

Conclusion

By thinking out of the box, we solved the issue for non-containerized-based applications as well and we have achieved some basic functionalities of an orchestration engine like- scaling, failover, management, service discovery, etc. for Windows-based applications.

But again, it doesn’t mean that this approach is restricted for Windows-based applications only, by using this plug-n-play method of Nomad we can solve a lot of issues.

I hope you guys have enjoyed the reading but if you have any feedback or suggestions, please reach out to me. In my upcoming blog, I will discuss the production parameters for Nomad and Consul and how we can integrate autoscaling in nomad.

Blog Pundit: Adeel Ahmad & Sandeep Rawat

Opstree is an End to End DevOps solution provider

One thought on “Running Non-containerized Microservices”

  1. Hi, It will be helpful if you had the ARM template with CIS L1 benchmark for PostgreSQL or if you can point me in the direction for one

    Like

Leave a Reply to AJ Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s