--- myst: html_meta: "description lang=en": "Kasm Workspaces auto-scaled Windows" "keywords": "Kasm, Windows, RDP, RDS, auto-scaling, windows" "property=og:locale": "en_US" --- ```{title} Windows Auto-Scaling ``` ## Auto Scaled Kasm Workspaces can auto-scale VMs in supported [Cloud Providers/Hypervisors](../compute/pools.md#vm-provider-configs). The [VM Provider](../compute/pools.md#vm-provider-configs) documentation provides a referece for the individual fields of each supported cloud provider/hypervisor. This document will focus on the Windows specific implications of each environment, since each cloud environment has different idiosyncrasies. Servers auto-scaled by Kasm should be seen as individual servers connected to via RDP. Kasm Workspaces provides session handling and ensures users a distributed to the pool of servers. Kasm auto-scaling is not supported as a way to scale [RDS](./rds.md) deployments. ```{important} Auto-scaling requires an Enterprise license for Kasm Workspaces. ``` ### Auto Scaling Pool Before you can create an auto-scaling configuration, you need to create a Pool that will be the target of the auto-scaling. A pool can have multiple auto-scaling configurations, allowing you to, for example, auto scale servers in Azure and AWS and have the VMs be part of the same pool that users will get assigned to. A more typical scenario, however, is to create one pool per Cloud environment, per region. To create a Pool, in the Admin Dashboard go to Infrastructure, Pools, and click the Add button on the Pool list. 1. Provide a Name 2. Select `Server` as the Type 3. Press Save ```{figure} /images/compute/create_server_pool.webp :align: center **Create Server Pool** ``` ### Auto Scale Configuration Auto-Scale configurations have two parts, the AutoScale Details and the VM Provider Details. The AutoScale details are common to any cloud provider/hypervisor. To create an auto-scale configuration... 1. Navigate to Infrastructure->Pools 2. From the Pool list, click the arrow icon next to the desired pool and click Edit 3. Scroll to the bottom of the Pool Configuration page to the AutoScale Configuration list and click the Add button. ```{figure} /images/compute/create_autoscale_server.webp :align: center **Create Autoscaling Config** ``` 4. Enter a Name 5. Check the Enabled box 6. Select the [Deployment Zone](../zones/deployment_zones.md), by default there is a single zone called `default`. 7. Select RDP as the connection type. 8. Enter the Connection Port, RDP uses port 3389 by default. 9. Enter an appropriate value for the username and password fields. See the [Windows Authentication](./authentication.md) documentation for guidance. 10. The connection info can be left empty, unless you are using [RemoteApp](../../how_to/windows_remote_apps.md). 11. If desired, check the Create Active Directory Computer Record. See the [Auto-Join Active Directory](./auto_scaled_servers.md#auto-join-active-directory) guide for more details. 12. Check the reusable box if you want VMs to be re-used after a user terminates their session. For privacy reasons, servers should only be reusable if single sign-on is configured. See the [Windows Authentication](./authentication.md) documentation for guidance on SSO. 13. Set a desired **Minimum Available Sessions**, this is the number of available sessions you want at all times. For example, if each server could support up to 4 concurrent sessions and you set **Minimum Available Sessions** to 10, Kasm would ensure that across all servers there are at least 10 open sessions available. As soon as the number of available sessions drops below this number, additional VMs will be provisioned. 14. Set the **Max Simultaneous Sessions Per Server** to the desired limit. Note that you must be using a version of Windows that supports multiple concurrent RDP sessions in order to set the number to greater than 1. Kasm will ensure each server will only be assigned this maximum number of current user sessions. ### VM Providers The next page in the auto-scale configuration is the VM Provider Configuration, which is specific to the Cloud Service Provider or Hypervisor you are targeting. ```{toctree} providers/azure providers/aws ``` #### VM Startup Scripts Each [VM Provider](#vm-providers) has special caveats around how their startup scripts are handled, see the VM Provider page for your target environment for more details. While each VM Provider may behave a bit differently or expect a slightly different format, they all support PowerShell scripts and that script will have access to Kasm managed variables. The following table lists variables that are accessible from the startup PowerShell script. **Startup Script Variables** | Variable Name | Description | | ------------------ | ---------------------------------------- | | connection_username | If the auto-scale configuration is set to use a static username for Kasm user sessions, the username will be contained in this variable. | | connection_password | If the auto-scale configuration is set to use a static password for Kasm user sessions, this variable will contain the password. | | ad_join_credential | If the auto-scale configuration is set to join the VM to an Active Directory domain, Kasm creates the AD record and sets a random password that can only be used for joining the VM to the domain. This can then be used in a Powershell startup script to complete the process of joining the system to the domain. | | domain | If the auto-scale configuration is set to join the VM to an Active Directory domain, this variable will contain the name of the domain. | ```{important} If your script uses curly brackets, aside from Kasm variables, you must escape them by doubling them up. Here is an example. ``` ```powershell $joinCred = New-Object pscredential -ArgumentList ([pscustomobject]@{{ UserName = $null; Password = (ConvertTo-SecureString -String '{ad_join_credential}' -AsPlainText -Force)[0] }}) Add-Computer -Domain "{domain}" -Options UnsecuredJoin,PasswordPass -Credential $joinCred -Force -Restart ``` In this example, curly open and closing brackets that are not in reference to Kasm variables, are doubled up. This example joins the system to the domain, using the `ad_join_credential` and `domain` variables that are provided by Kasm. #### Auto Join Active Directory [Auto-scaled servers](./auto_scaled_servers.md) can be configured to automatically join active directory. This is a two step process which involves Kasm first creating a Computer Object in Active Directory, within a specified AD container. When the Computer Object is created, a random single use password is created, which can only be used to join the computer to the domain. The final step of joining the computer to the domain must be done from the Windows server itself. This is facilitated through the [startup script](./auto_scaled_servers.md#vm-startup-scripts) of the [VM Provider](./auto_scaled_servers.md#vm-providers) configuration. The Powershell startup script will join the computer to the domain using the single use random password that was created by Kasm. 1. Create an [LDAP Configuration](../ldap.md) that will be used for user authentication to Kasm. 2. Create an [LDAP Configuration](../ldap.md), that will be used to create computer objects in AD. The service account used by this LDAP configuration must have permissions to create and remove computers from the domain. You can use the same LDAP configuration that is used to authenticate users or you can create a different LDAP configuration used specifically for joining and removing systems. If you use a separate LDAP configuration, leave it disabled so that it cannot be used for authentication purposes. 3. In the [Auto-scale Configuration](./auto_scaled_servers.md#auto-scale-configuration), set the **Connection Username** to `{sso_username}` and the **Connection Password** to `{sso_cred}`. 4. In the [Auto-scale Configuration](./auto_scaled_servers.md#auto-scale-configuration), check the **Create Active Directory Computer Record** box. - In the **LDAP Config** select the LDAP configuration created in step 2. - In the **Active Directory Computer OU DN**, enter the AD OU Distinguished Name. **Example:** OU=Computers,DC=example,DC=local - Enable **Recursively Cleanup Active Directory Computer Record** if you anticipate the Computer objects having child objects. This can prevent `notAllowedOnNonLeaf` errors when cleaning Azure VMs. - Click Next to save the auto-scale configuration. 5. The next page is the [VM Provider](./auto_scaled_servers.md#vm-providers) configuration. Scroll down to the startup script. See the example in the [VM Startup Script](./auto_scaled_servers.md#vm-startup-scripts), which is a Powershell script that will add the VM to the domain specified by the LDAP configuration. Each [VM Provider](./auto_scaled_servers.md#vm-providers) has different caveats for script formats and execution, see the VM Provider page for the environment you are in. ### Workspace To provide users access to the auto-scaled server pool, you must create a Workspaces. 1. Navigate to Worksapces -> Workspaces 2. Click the **Add Workspace** button at the top of the Workspaces list. 3. Select `Pool` from the **Workspace Type**. 4. Provide a **Friendly Name** and **Description**. 5. Check the Enable box. 6. In the **Pool** drop down, select the Pool you created earlier. 7. Click Save. You should now see the Workspaces on the user dashboard.