title | description | author | ms.author | ms.subservice | ms.topic | ms.custom | ms.date | |
---|---|---|---|---|---|---|---|---|
Deploy K8s workloads with IoT Orchestrator |
Use K8s to deploy custom workloads to Azure IoT Operations clusters with the Azure IoT Orchestrator |
kgremban |
kgremban |
orchestrator |
how-to |
|
11/01/2023 |
[!INCLUDE public-preview-note]
Once you have Azure IoT Operations Preview deployed to a connected cluster, you can use Azure IoT Orchestrator Preview to deploy custom workloads including K8s custom resources.
- An Arc-enabled Kubernetes cluster with Azure IoT Orchestrator deployed to it. For more information, see Deploy Azure IoT Operations Preview extensions to a Kubernetes cluster.
This article shows you how to deploy a K8s custom resource using Azure IoT Orchestrator through Bicep.
The following example is a Bicep template that deploys a K8s ConfigMap:
@description('The location of the existing Arc-enabled cluster resource in Azure.')
@allowed(['eastus2', 'westus3'])
param clusterLocation string
@description('The namespace on the K8s cluster where the resources are installed.')
param clusterNamespace string
@description('The extended location resource name.')
param customLocationName string
var k8sConfigMap = loadYamlContent('config-map.yml')
resource k8sResource 'Microsoft.iotoperationsorchestrator/targets@2023-10-04-preview' = {
name: 'k8s-resource'
location: clusterLocation
extendedLocation: {
type: 'CustomLocation'
name: resourceId('Microsoft.ExtendedLocation/customLocations', customLocationName)
}
properties: {
scope: clusterNamespace
components: [
{
name: 'config-map-1'
type: 'yaml.k8s'
properties: {
resource: k8sConfigMap
}
}
]
topologies: [
{
bindings: [
{
role: 'instance'
provider: 'providers.target.k8s'
config: {
inCluster: 'true'
}
}
{
role: 'yaml.k8s'
provider: 'providers.target.kubectl'
config: {
inCluster: 'true'
}
}
]
}
]
}
}
You can use the Azure CLI to deploy the Bicep file.
-
Save the Bicep file as main.bicep to your local computer.
-
Save the following ConfigMap YAML as config-map.yml to your local computer.
apiVersion: v1 kind: ConfigMap metadata: name: config-demo data: # property-like keys; each key maps to a simple value player_initial_lives: "3" ui_properties_file_name: "user-interface.properties" # file-like keys game.properties: | enemy.types=aliens,monsters player.maximum-lives=5 user-interface.properties: | color.good=purple color.bad=yellow allow.textmode=true
-
Deploy the Bicep file using the Azure CLI.
az deployment group create --resource-group exampleRG --template-file ./main.bicep --parameters clusterLocation=<existing-cluster-location> clusterNamespace=<namespace-on-cluster> customLocationName=<existing-custom-location-name>
Replace <existing-cluster-location> with the existing Arc-enabled cluster resource's location. Replace <namespace-on-cluster> with the namespace where you want resources deployed on the Arc-enabled cluster. Replace <existing-custom-location-name> with the name of the existing custom location resource that is linked to your Arc-enabled cluster.
When the deployment finishes, you should see a message indicating the deployment succeeded.
Use the Azure portal or Azure CLI to list the deployed resources in the resource group.
az resource list --resource-group exampleRG