You need an Azure Arc-enabled Kubernetes cluster to deploy Azure IoT Operations. This article explains how to prepare that cluster, with guidance for Ubuntu, Windows, Azure Local, vSphere Kubernetes Service (VKS), and Red Hat OpenShift Container Platform (OpenShift).
If you want to deploy Azure IoT Operations quickly and run a sample workload in a test environment, see the Quickstart: Run Azure IoT Operations in GitHub Codespaces with K3s.
Prerequisites
For multi-node deployments, use K3s on Ubuntu, AKS on Azure Local, vSphere Kubernetes Service (VKS), or OpenShift. AKS Edge Essentials on Windows supports single-node deployments only.
To prepare an Azure Arc-enabled Kubernetes cluster, you need:
An Azure subscription with either the Owner role or a combination of Contributor and User Access Administrator roles. You can check your access level by navigating to your subscription, selecting Access control (IAM) on the left-hand side of the Azure portal, and then selecting View my access. If you don't have an Azure subscription, create one for free before you begin.
The Azure CLI installed on your development machine. Check Available Azure CLI extensions for the minimum required version for the connectedk8s extension. Use az --version to check your version and az upgrade to update if necessary. For more information, see Install the Azure CLI.
The connectedk8s extension for the Azure CLI. Use the following command to add the extension or update it to the latest version:
az extension add --upgrade --name connectedk8s
An Azure resource group. Only one Azure IoT Operations instance is supported per resource group. To create a new resource group, use the az group create command. For the list of currently supported Azure regions, see Supported regions.
az group create --location $LOCATION --resource-group $RESOURCE_GROUP --subscription $SUBSCRIPTION_ID
Hardware that meets the system requirements:
If you're going to deploy Azure IoT Operations to a multi-node cluster with fault tolerance enabled, review the hardware and storage requirements in Prepare Linux for Edge Volumes.
To prepare an Azure Arc-enabled Kubernetes cluster, you need:
- An Azure subscription. If you don't have an Azure subscription, create one for free before you begin.
To prepare an Azure Arc-enabled Kubernetes cluster, you need:
- An Azure subscription. If you don't have an Azure subscription, create one for free before you begin.
To prepare a vSphere Kubernetes Service (VKS) workload cluster, you need:
An Azure subscription with either the Owner role or a combination of Contributor and User Access Administrator roles. You can check your access level by navigating to your subscription, selecting Access control (IAM) on the left-hand side of the Azure portal, and then selecting View my access. If you don't have an Azure subscription, create one for free before you begin.
The Azure CLI installed on your development machine. Check Available Azure CLI extensions for the minimum required version for the connectedk8s extension. Use az --version to check your version and az upgrade to update if necessary. For more information, see Install the Azure CLI.
The connectedk8s extension for the Azure CLI. Use the following command to add the extension or update it to the latest version:
az extension add --upgrade --name connectedk8s
An Azure resource group. Only one Azure IoT Operations instance is supported per resource group. To create a new resource group, use the az group create command. For the list of currently supported Azure regions, see Supported regions.
az group create --location $LOCATION --resource-group $RESOURCE_GROUP --subscription $SUBSCRIPTION_ID
To prepare an Azure Arc-enabled OpenShift cluster, you need:
An Azure subscription with either the Owner role or a combination of Contributor and User Access Administrator roles. You can check your access level by navigating to your subscription, selecting Access control (IAM) on the left-hand side of the Azure portal, and then selecting View my access. If you don't have an Azure subscription, create one for free before you begin.
The Azure CLI installed on your development machine. Check Available Azure CLI extensions for the minimum required version for the connectedk8s extension. Use az --version to check your version and az upgrade to update if necessary. For more information, see Install the Azure CLI.
The connectedk8s extension for the Azure CLI. Use the following command to add the extension or update it to the latest version:
az extension add --upgrade --name connectedk8s
An Azure resource group. Only one Azure IoT Operations instance is supported per resource group. To create a new resource group, use the az group create command. For the list of currently supported Azure regions, see Supported regions.
az group create --location $LOCATION --resource-group $RESOURCE_GROUP --subscription $SUBSCRIPTION_ID
A Red Hat OpenShift cluster, version 4.20 or later.
The OpenShift CLI (oc) installed on your development machine, signed in to your cluster with an account that has the cluster-admin role. Granting security context constraints requires cluster-admin.
Hardware that meets the system requirements:
The Azure CLI examples in this article use environment variables so that you can set each value once and then copy and paste the commands as-is. If you're using the Azure IoT Operations Codespaces environment from the quickstart, these variables are already set for you and you can skip this step. Otherwise, set the following environment variables in your shell before you run the commands.
The following scripts set the most commonly used environment variables:
| Environment variable |
Description |
SUBSCRIPTION_ID |
The ID of the subscription that contains your Azure IoT Operations instance. |
RESOURCE_GROUP |
The name of the resource group that contains your Azure IoT Operations instance. |
AIO_INSTANCE_NAME |
The name of your Azure IoT Operations instance. To list your instances, run az iot ops list -o table. |
CLUSTER_NAME |
The name of the Azure Arc-enabled Kubernetes cluster that hosts your instance. |
LOCATION |
The Azure region to use for new resources, for example eastus. |
SUBSCRIPTION_ID=
RESOURCE_GROUP=
AIO_INSTANCE_NAME=
CLUSTER_NAME=
LOCATION=
$SUBSCRIPTION_ID = ""
$RESOURCE_GROUP = ""
$AIO_INSTANCE_NAME = ""
$CLUSTER_NAME = ""
$LOCATION = ""
You only need to set the variables that this article uses. This article might use additional environment variables for resource names that you choose. The article explains how to set them where they're introduced.
Create and Arc-enable a cluster
This section provides steps to create clusters in validated environments on Ubuntu, Windows, Azure Local, vSphere Kubernetes Service (VKS), and OpenShift.
To prepare a K3s Kubernetes cluster on Ubuntu:
Create a single-node or multi-node K3s cluster. For examples, see the K3s quick-start guide or K3s related projects.
Check that K3s installed kubectl. If not, follow the instructions to Install kubectl on Linux.
kubectl version --client
Follow the instructions to Install Helm.
Create a K3s configuration YAML file in .kube/config:
mkdir ~/.kube
sudo KUBECONFIG=~/.kube/config:/etc/rancher/k3s/k3s.yaml kubectl config view --flatten > ~/.kube/merged
mv ~/.kube/merged ~/.kube/config
chmod 0600 ~/.kube/config
export KUBECONFIG=~/.kube/config
#switch to k3s context
kubectl config use-context default
sudo chmod 644 /etc/rancher/k3s/k3s.yaml
Run the following command to increase the user watch/instance limits.
echo fs.inotify.max_user_instances=8192 | sudo tee -a /etc/sysctl.conf
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
For better performance, increase the file descriptor limit:
echo fs.file-max = 100000 | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
Arc-enable your K3s cluster
Connect your cluster to Azure Arc so that you can manage it remotely.
From a machine that has kubectl access to your cluster, sign in to Azure CLI with your Microsoft Entra user account that has the required roles for the Azure subscription:
az login
If at any point you get an error that says Your device is required to be managed to access your resource, run az login again and make sure that you sign in interactively by using a browser.
After you sign in, the Azure CLI shows all of your subscriptions and indicates your default subscription with an asterisk *. To continue with your default subscription, select Enter. Otherwise, type the number of the Azure subscription that you want to use.
Register the required resource providers in your subscription.
Note
You need to run this step only once per subscription. To register resource providers, you need permission to do the /register/action operation, which subscription Contributor and Owner roles include. For more information, see Azure resource providers and types.
az provider register -n "Microsoft.ExtendedLocation"
az provider register -n "Microsoft.Kubernetes"
az provider register -n "Microsoft.KubernetesConfiguration"
az provider register -n "Microsoft.IoTOperations"
az provider register -n "Microsoft.DeviceRegistry"
az provider register -n "Microsoft.SecretSyncController"
Use the az connectedk8s connect command to Arc-enable your Kubernetes cluster and manage it as part of your Azure resource group.
az connectedk8s connect --name $CLUSTER_NAME -l $LOCATION --resource-group $RESOURCE_GROUP --subscription $SUBSCRIPTION_ID --enable-oidc-issuer --enable-workload-identity --disable-auto-upgrade
To prevent unplanned updates to Azure Arc and the system Arc extensions that Azure IoT Operations uses as dependencies, this command disables autoupgrade. Instead, manually upgrade agents as needed.
Get the cluster's issuer URL.
az connectedk8s show --resource-group $RESOURCE_GROUP --name $CLUSTER_NAME --query oidcIssuerProfile.issuerUrl --output tsv
Save the output of this command to use in the next steps.
Create a K3s config file.
sudo nano /etc/rancher/k3s/config.yaml
Add the following content to the config.yaml file, replacing the placeholder with your cluster's issuer URL.
kube-apiserver-arg:
- service-account-issuer=
- service-account-max-token-expiration=24h
Save the file and exit the nano editor.
Prepare for enabling the Azure Arc service, custom location, on your Arc cluster by getting the custom location object ID and saving it as the environment variable, OBJECT_ID. You must sign in to Azure CLI with a Microsoft Entra user account, not a service principal, to run the command successfully. Run the following command exactly as written, without changing the GUID value.
export OBJECT_ID=$(az ad sp show --id bc313c14-388c-4e7d-a58e-70017303ee3b --query id -o tsv)
Note
If you receive the error: "Unable to fetch oid of 'custom-locations' app. Proceeding without enabling the feature. Insufficient privileges to complete the operation," then your service principal might lack the necessary permissions to retrieve the object ID of the custom location. Sign in to Azure CLI with a Microsoft Entra user account that meets the prerequisites. For more information, see Create and manage custom locations.
Use the az connectedk8s enable-features command to enable the custom location feature on your Arc cluster. This command uses the OBJECT_ID environment variable that you saved in the previous step to set the value for the custom-locations-oid parameter. Run this command on the machine where you deployed the Kubernetes cluster:
az connectedk8s enable-features -n $CLUSTER_NAME -g $RESOURCE_GROUP --custom-locations-oid $OBJECT_ID --features cluster-connect custom-locations
Restart K3s.
systemctl restart k3s
Azure Kubernetes Service Edge Essentials is an on-premises Kubernetes implementation of Azure Kubernetes Service (AKS) that automates running containerized applications at scale. AKS Edge Essentials includes a Microsoft-supported Kubernetes platform that includes a lightweight Kubernetes distribution with a small footprint and simple installation experience that supports PC-class or "light" edge hardware.
The AksEdgeQuickStartForAio.ps1 script automates creating and connecting a cluster, and is the recommended path for deploying Azure IoT Operations on AKS Edge Essentials.
For instructions on running the script, see Configure an AKS Edge Essentials cluster for Azure IoT Operations.
By default, a Kubernetes cluster includes a node pool that can run Linux containers. If you add more node pools after creation, make sure to set the OS to Linux. Azure IoT Operations doesn't support deployment to Windows nodes.
After you have an Azure Arc-enabled Kubernetes cluster, you can deploy Azure IoT Operations.
To prepare a VKS workload cluster, you need a single-node or multi-node VKS workload cluster.
Update pod security admission settings
Before deploying Azure IoT Operations, update the Pod Security Admission settings on your VKS cluster. Applying this file pre-creates namespace labels and sets pod security to privileged.
kubectl apply -f https://raw.githubusercontent.com/Azure-Samples/explore-iot-operations/main/samples/tanzu-config/psa.yaml
Arc-enable your VKS cluster
Connect your cluster to Azure Arc so that you can manage it remotely.
On the machine where you deployed the Kubernetes cluster, sign in to Azure CLI with your Microsoft Entra user account that has the required roles for the Azure subscription:
az login
After you sign in, the Azure CLI shows all of your subscriptions and indicates your default subscription with an asterisk *. To continue with your default subscription, select Enter. Otherwise, type the number of the Azure subscription that you want to use.
Register the required resource providers in your subscription.
Note
You need to run this step only once per subscription. To register resource providers, you need permission to do the /register/action operation, which subscription Contributor and Owner roles include. For more information, see Azure resource providers and types.
az provider register -n "Microsoft.ExtendedLocation"
az provider register -n "Microsoft.Kubernetes"
az provider register -n "Microsoft.KubernetesConfiguration"
az provider register -n "Microsoft.IoTOperations"
az provider register -n "Microsoft.DeviceRegistry"
az provider register -n "Microsoft.SecretSyncController"
Use the az connectedk8s connect command to Arc-enable your Kubernetes cluster and manage it as part of your Azure resource group.
az connectedk8s connect --name $CLUSTER_NAME -l $LOCATION --resource-group $RESOURCE_GROUP --subscription $SUBSCRIPTION_ID --enable-oidc-issuer --enable-workload-identity --disable-auto-upgrade
To prevent unplanned updates to Azure Arc and the system Arc extensions that Azure IoT Operations uses as dependencies, this command disables autoupgrade. Instead, manually upgrade agents as needed.
Configure workload identity on your VKS cluster. For instructions, see Deploy and configure workload identity on an AKS cluster. Running Azure IoT Operations with secure settings requires workload identity.
Prepare for enabling the Azure Arc service, custom location, on your Arc cluster by getting the custom location object ID and saving it as the environment variable, OBJECT_ID. You must sign in to Azure CLI with a Microsoft Entra user account, not a service principal, to run the command successfully. Run the following command exactly as written, without changing the GUID value.
export OBJECT_ID=$(az ad sp show --id bc313c14-388c-4e7d-a58e-70017303ee3b --query id -o tsv)
Note
If you receive the error: "Unable to fetch oid of 'custom-locations' app. Proceeding without enabling the feature. Insufficient privileges to complete the operation," then your service principal might lack the necessary permissions to retrieve the object ID of the custom location. Sign in to Azure CLI with a Microsoft Entra user account that meets the prerequisites. For more information, see Create and manage custom locations.
Use the az connectedk8s enable-features command to enable the custom location feature on your Arc cluster. This command uses the OBJECT_ID environment variable saved from the previous step to set the value for the custom-locations-oid parameter. Run this command on the machine where you deployed the Kubernetes cluster:
az connectedk8s enable-features -n $CLUSTER_NAME -g $RESOURCE_GROUP --custom-locations-oid $OBJECT_ID --features cluster-connect custom-locations
To prepare an OpenShift cluster, you need a single-node or multi-node OpenShift cluster, version
4.20 or later.
OpenShift enforces security context constraints (SCCs), which control the privileges that pods can request. By default, OpenShift assigns each project a UID range and admits pods under the restricted-v2 constraint. Some Azure IoT Operations components request fixed user IDs outside that range, so you grant additional constraints before you deploy.
Grant security context constraints
Before you deploy Azure IoT Operations, grant the security context constraints that its components require. The following command targets the service account group for the namespace, so it applies to every service account that the deployment creates later. You can run it before the namespace exists.
for scc in anyuid privileged hostnetwork-v2 hostaccess hostmount-anyuid nonroot-v2; do
oc adm policy add-scc-to-group $scc system:serviceaccounts:azure-iot-operations
done
If you skip this step, deployment fails and the affected workloads report an admission error similar to the following:
pods "aio-akri-operator-0" is forbidden: unable to validate against any security context
constraint: provider restricted-v2: .spec.securityContext.fsGroup: Invalid value:
[]int64{65532}: 65532 is not an allowed group
Arc-enable your OpenShift cluster
Connect your cluster to Azure Arc so that you can manage it remotely.
Register the required resource providers in your subscription.
Note
You need to run this step only once per subscription. To register resource providers, you need
permission to do the /register/action operation, which subscription Contributor and Owner
roles include. For more information, see Azure resource providers and types.
az provider register -n "Microsoft.ExtendedLocation"
az provider register -n "Microsoft.Kubernetes"
az provider register -n "Microsoft.KubernetesConfiguration"
az provider register -n "Microsoft.IoTOperations"
az provider register -n "Microsoft.DeviceRegistry"
az provider register -n "Microsoft.SecretSyncController"
Use the az connectedk8s connect command to Azure Arc-enable your Kubernetes cluster and manage it as part of your Azure resource group.
az connectedk8s connect --name $CLUSTER_NAME -l $LOCATION --resource-group $RESOURCE_GROUP --subscription $SUBSCRIPTION_ID --enable-oidc-issuer --enable-workload-identity --disable-auto-upgrade
To prevent unplanned updates to Azure Arc and the system Azure Arc extensions that Azure IoT Operations uses as dependencies, this command disables autoupgrade. Instead, manually upgrade agents as needed.
The Azure Arc agents create the security context constraints that they need, so no extra OpenShift configuration is required for this step.
Get the cluster's issuer URL.
az connectedk8s show --resource-group $RESOURCE_GROUP --name $CLUSTER_NAME --query oidcIssuerProfile.issuerUrl --output tsv
Save the output of this command to use in the next step.
Configure the cluster to use the Azure Arc issuer as its service account issuer, replacing the placeholder with the value from the previous step. Running Azure IoT Operations with secure settings requires workload identity.
oc patch authentication cluster --type=merge \
-p '{"spec":{"serviceAccountIssuer":""}}'
Changing the service account issuer causes the kube-apiserver and authentication cluster operators to roll out a new revision across the control plane. Wait for both to finish before you continue.
oc wait --for=condition=Progressing=False --timeout=30m clusteroperator/kube-apiserver
oc wait --for=condition=Progressing=False --timeout=30m clusteroperator/authentication
Prepare for enabling the Azure Arc service, custom location, on your Azure Arc cluster by getting the custom location object ID and saving it as the environment variable, OBJECT_ID. You must sign in to Azure CLI with a Microsoft Entra user account, not a service principal, to run the command successfully. Run the following command exactly as written, without changing the GUID value.
export OBJECT_ID=$(az ad sp show --id bc313c14-388c-4e7d-a58e-70017303ee3b --query id -o tsv)
Note
If you receive the error: "Unable to fetch oid of 'custom-locations' app. Proceeding without enabling the feature. Insufficient privileges to complete the operation," then your service principal might lack the necessary permissions to retrieve the object ID of the custom location. Sign in to Azure CLI with a Microsoft Entra user account that meets the prerequisites. For more information, see Create and manage custom locations.
Important
Run this lookup while signed in to the same Microsoft Entra tenant that contains your Azure Arc resources. The object ID of the Custom Locations application is different in each tenant. Using an object ID from another tenant appears to succeed, but Azure IoT Operations deployment later fails with "Microsoft.ExtendedLocation" resource provider does not have the required permissions to create a namespace on the cluster.
Use the az connectedk8s enable-features command to enable the custom location feature on your Azure Arc cluster. This command uses the OBJECT_ID environment variable that you saved in the previous step to set the value for the custom-locations-oid parameter.
az connectedk8s enable-features -n $CLUSTER_NAME -g $RESOURCE_GROUP --custom-locations-oid $OBJECT_ID --features cluster-connect custom-locations
Deployment options required on OpenShift
When you deploy Azure IoT Operations to this cluster, include the following options.
Disable cert-manager telemetry:
az iot ops init --cluster $CLUSTER_NAME --resource-group $RESOURCE_GROUP --cm-config global.telemetry.enabled=false
The cert-manager extension otherwise adds a diagnostics sidecar whose image is referenced by digest. The CRI-O container runtime that OpenShift uses can't pull an image referenced by a digest that resolves to a multi-architecture manifest list, so the sidecar fails with ImagePullBackOff and cert-manager never becomes healthy.
Disable the connector security context:
az iot ops create --cluster $CLUSTER_NAME --resource-group $RESOURCE_GROUP --name --sr-resource-id --ns-resource-id --ops-config connectors.values.setSecurityContext=false
The connector supervisor otherwise runs under an arbitrary UID assigned by OpenShift and can't read its own application files, so the connectors Helm release times out and the deployment is rolled back.
Note
This option makes the connector pods run under the anyuid security context constraint rather than the OpenShift default. It's required today because the connector image isn't readable by an arbitrary UID. All other Azure IoT Operations pods run under a more restrictive constraint.
Features such as data flow local storage endpoints and the media connector optionally use Azure Container Storage enabled by Azure Arc (ACSA) to synchronize local data to the cloud. ACSA isn't installed as part of Azure IoT Operations, so you must install it separately.
To learn how to install ACSA on your Kubernetes cluster:
Next steps
Now that you have an Azure Arc-enabled Kubernetes cluster, you can deploy Azure IoT Operations.