Running UIPath Robots on Kubernetes
This article will go through the steps in configuring UIPath Robots on a Kubernetes Cluster, specifically on Linux nodes. This setup enables you to run unattended automation as Kubernetes pods and helps you scale up resources when the demand increases.
Before we start as a disclaimer, it is assumed that the reader is a bit familiar with Kubernetes and Terraform, as this knowledge is essential in provisioning the infrastructure and deploying robots into the cluster. So let’s get started.
Pre-requisites
- UIPath Cloud Account
- Terraform
- AWS Account
- Kubectl CLI
Setup
1. Infrastructure
As an initial setup, we need to create a Kubernetes cluster to host our Robots on Linux nodes. So the provisioning of infrastructure(EKS) is done using Terraform on AWS. I have re-used the EKS modules available in the Hashicorp Registry, so things will be provisioned right out of the box.
provider.tf
To start the provisioning, we need to first export AWS Access ID and Secret Key
export AWS_ACCESS_KEY_ID=""
export AWS_SECRET_ACCESS_KEY=""
Finally, we will execute it using terraform
terraform init #Intialize the terraform modules
terraform fmt -recursive #Lint the TF scripts recursively
terraform plan -var-file=prod.tfvars #Terraform plan using value file as input
terraform apply -var-file=prod.tfvars #Terraform apply using value file as input
2. Deploying Robots as Pods
The next step is to deploy the robots as pods on the cluster. For simplicity, I have made use of manifests files, which will create a namespace, config map, and deployment objects. The manifest files are shown below
Namespace
Configmap
There are three variables that need to provide for the deployment
- LICENSE_AGREEMENT —
accept
- ORCHESTRATOR_URL —
https://cloud.uipath.com/organizationname/tenantname
- MACHINE_KEY — You need to get the key from the Orchestrator -> Machines -> Machine template. Since it's a collection of pods that will act as a robot, a machine template needs to be selected.
Couple of things to note while adding the machine template are
- The process type should be
Background
as this would be used for unattended automation - Process Compatibility should be
Cross-platform only
deployment
In the deployment container image used is registry.uipath.com/robot/runtime:22.10.3
which is the current latest. You may refer to the latest tag in the UIPath docs. The config map values which we defined before, will be referred to in the deployment manifest.
Now let's deploy the robots to the Kubernetes cluster
kubectl create -f deployment.yaml
kubectl create -f configmap.yaml
kubectl create -f deployment.yaml
Once deployment is complete, you can check whether robots are running fine or not by using the below command
kubectl get pods -n robot-workers -o wide
We can check the logs of the running robots with the below command
kubectl logs <podname> -n robot-workers
UiPath.Service.NetCoreHost Information: 0 : Started /root/application/UiPath.Service.NetCoreHost.dll, ID=1
UiPath.Service.NetCoreHost Information: 0 : D:\a\1\s\src\client\UiPath.UpdateService.Client\Impl\InstallationIdService.ReadOrCreateInstallationId line 49: Setting installation id to fd1231f0-a8ae-40a0-9b1d-1fdb7aa46006
UiPath.Service.NetCoreHost Information: 0 : Trying to connect to Orchestrator using machine key
UiPath.Service.NetCoreHost Information: 0 : GetRunningJobs for ROOT
UiPath.Service.NetCoreHost Information: 0 : Request URI:https://cloud.uipath.com/mysticrenji/DefaultTenant/odata/$metadata Response:OK Start:2023-01-10T16:32:11.0965683+00:00 Id:00-b8f605f2fcf2fc6db9cae5a240fbddd6-b89cb4d8e213fa0a-00
UiPath.Service.NetCoreHost Information: 0 : Request URI:https://cloud.uipath.com/mysticrenji/DefaultTenant/odata/Settings/UiPath.Server.Configuration.OData.GetServicesSettings Response:OK Start:2023-01-10T16:32:11.6048007+00:00 Id:00-528a5f495dced17892096717b3667044-1aac87a0a6bfceb4-00
UiPath.Service.NetCoreHost Warning: 0 : OrchestratorSettings: ClusterId empty
UiPath.Service.NetCoreHost Information: 0 : Request URI:https://cloud.uipath.com/mysticrenji/DefaultTenant/orchestrator_/api/robotsservice/StartService Response:OK Start:2023-01-10T16:32:11.7756272+00:00 Id:00-ea35442babc10c9dd64418ab500b6039-d728698ea86ffc32-00
UiPath.Service.NetCoreHost Information: 0 : Starting SignalR, hub: https://cloud.uipath.com/mysticrenji/DefaultTenant/orchestrator_/signalr/robots, transports: WebSocket, ServerSentEvents, LongPolling
UiPath.Service.NetCoreHost Information: 0 : Successfully connected to Orchestrator
UiPath.Service.NetCoreHost Information: 0 : Request URI:https://cloud.uipath.com/mysticrenji/DefaultTenant/orchestrator_/api/robotsservice/HeartbeatV2 Response:OK Start:2023-01-10T16:32:12.0313083+00:00 Id:00-1058f063e02ad29a1a31268d416e7f80-7200a82fa26a10d7-00
UiPath.Service.NetCoreHost Information: 0 : Request URI:https://cloud.uipath.com/mysticrenji/DefaultTenant/orchestrator_/api/robotsservice/HeartbeatV2 Response:OK Start:2023-01-10T16:32:42.2058925+00:00 Id:00-948f303652aea1eda027113ce29f169b-641fca89d7f1d2d8-00
On the orchestrator end, we could see 4 robots connected and available as well.
Finally, you have shiny robots running in the Kubernetes cluster, waiting for your commands to execute processes.
That's all for now. Thanks for reading the article and let me know your feedback.
References
In case of any queries, please feel free to connect me via the below links