-
Notifications
You must be signed in to change notification settings - Fork 20
/
deployBaseResources.bicep
280 lines (227 loc) · 6.86 KB
/
deployBaseResources.bicep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
metadata description = 'This template deploys IoT Operations components, Event Hubs and sets RBAC'
/*****************************************************************************/
/* Deployment Parameters */
/*****************************************************************************/
param clusterName string
@allowed([
'eastus'
'eastus2'
'westus'
'westus2'
'westus3'
'westeurope'
'northeurope'
'eastus2euap'
])
param clusterLocation string = location
@allowed([
'eastus'
'eastus2'
'westus'
'westus2'
'westus3'
'westeurope'
'northeurope'
'eastus2euap'
])
param location string = any(resourceGroup().location)
//param customLocationName string = '${clusterName}-cl'
param customLocationName string = '${any(resourceGroup().name)}-cl'
param mqInstanceName string = 'mq-instance'
param mqFrontendServer string = 'mq-dmqtt-frontend'
param mqListenerName string = 'listener'
param mqBrokerName string = 'broker'
param mqAuthnName string = 'authn'
param mqFrontendReplicas int = 1
param mqFrontendWorkers int = 1
param mqBackendRedundancyFactor int = 1
param mqBackendWorkers int = 1
param mqBackendPartitions int = 1
@allowed([
'auto'
'distributed'
])
param mqMode string = 'distributed'
@allowed([
'tiny'
'low'
'medium'
'high'
])
param mqMemoryProfile string = 'medium'
@allowed([
'clusterIp'
'loadBalancer'
'nodePort'
])
param mqServiceType string = 'clusterIp'
/*****************************************************************************/
/* Constants */
/*****************************************************************************/
var AIO_CLUSTER_RELEASE_NAMESPACE = 'azure-iot-operations'
var AIO_EXTENSION_SCOPE = {
cluster: {
releaseNamespace: AIO_CLUSTER_RELEASE_NAMESPACE
}
}
var MQ_PROPERTIES = {
domain: 'aio-mq-dmqtt-frontend.${AIO_CLUSTER_RELEASE_NAMESPACE}'
port: 1883
localUrl: 'mqtts://aio-mq-dmqtt-frontend.${AIO_CLUSTER_RELEASE_NAMESPACE}:1883'
name: 'aio-mq-dmqtt-frontend'
satAudience: 'aio-mq'
}
var repo = 'mcr.microsoft.com/azureiotoperations'
var __VERSION__ = '0.1.0-preview'
var __TRAIN__ = 'preview'
/*****************************************************************************/
/* Existing Arc-enabled cluster where AIO will be deployed. */
/*****************************************************************************/
resource cluster 'Microsoft.Kubernetes/connectedClusters@2021-03-01' existing = {
name: clusterName
}
/*****************************************************************************/
/* MQ Extension */
/*****************************************************************************/
resource mqExtension 'Microsoft.KubernetesConfiguration/extensions@2022-03-01' = {
scope: cluster
name: 'mq-${any(resourceGroup().name)}'
identity: {
type: 'SystemAssigned'
}
properties: {
extensionType: 'microsoft.iotoperations.mq'
version: __VERSION__
releaseTrain: __TRAIN__
autoUpgradeMinorVersion: false
scope: AIO_EXTENSION_SCOPE
}
}
/*****************************************************************************/
/* Azure Arc custom location and resource sync rules. */
/*****************************************************************************/
resource customLocation 'Microsoft.ExtendedLocation/customLocations@2021-08-31-preview' = {
name: customLocationName
location: clusterLocation
properties: {
hostResourceId: cluster.id
namespace: AIO_CLUSTER_RELEASE_NAMESPACE
displayName: customLocationName
clusterExtensionIds: [
mqExtension.id
]
}
}
resource mq_syncRule 'Microsoft.ExtendedLocation/customLocations/resourceSyncRules@2021-08-31-preview' = {
parent: customLocation
name: '${customLocationName}-mq-sync'
location: clusterLocation
properties: {
priority: 400
selector: {
matchLabels: {
#disable-next-line no-hardcoded-env-urls
'management.azure.com/provider-name': 'microsoft.iotoperationsmq'
}
}
targetResourceGroup: resourceGroup().id
}
}
/*****************************************************************************/
/* MQ resources. */
/*****************************************************************************/
resource mq 'Microsoft.IoTOperationsMQ/mq@2023-10-04-preview' = {
name: mqInstanceName
location: location
extendedLocation: {
name: customLocation.id
type: 'CustomLocation'
}
properties: {}
}
resource broker 'Microsoft.IoTOperationsMQ/mq/broker@2023-10-04-preview' = {
parent: mq
name: mqBrokerName
location: location
extendedLocation: {
name: customLocation.id
type: 'CustomLocation'
}
properties: {
authImage: {
pullPolicy: 'Always'
repository: '${repo}/dmqtt-authentication'
tag: __VERSION__
}
brokerImage: {
pullPolicy: 'Always'
repository: '${repo}/dmqtt-pod'
tag: __VERSION__
}
healthManagerImage: {
pullPolicy: 'Always'
repository: '${repo}/dmqtt-operator'
tag: __VERSION__
}
diagnostics: {
probeImage: '${repo}/diagnostics-probe:${__VERSION__}'
enableSelfCheck: true
}
mode: mqMode
encryptInternalTraffic: false
memoryProfile: mqMemoryProfile
diskBackedMessageBufferSettings: {
maxSize: '2Gi'
}
cardinality: {
backendChain: {
partitions: mqBackendPartitions
workers: mqBackendWorkers
redundancyFactor: mqBackendRedundancyFactor
}
frontend: {
replicas: mqFrontendReplicas
workers: mqFrontendWorkers
}
}
}
}
resource brokerDiagnostics 'Microsoft.IoTOperationsMQ/mq/diagnosticService@2023-10-04-preview' = {
parent: mq
name: 'diagnostics'
location: location
extendedLocation: {
name: customLocation.id
type: 'CustomLocation'
}
properties: {
image: {
repository: '${repo}/diagnostics-service'
tag: __VERSION__
}
logLevel: 'info'
logFormat: 'text'
}
}
resource nonTlsListener 'Microsoft.IoTOperationsMQ/mq/broker/listener@2023-10-04-preview' = {
parent: broker
name: mqListenerName
location: location
extendedLocation: {
name: customLocation.id
type: 'CustomLocation'
}
properties: {
serviceType: mqServiceType
authenticationEnabled: false
authorizationEnabled: false
brokerRef: broker.name
port: 1883
}
}
/*****************************************************************************/
/* Outputs. */
/*****************************************************************************/
output mqExtensionName string = mqExtension.name
output customLocationName string = customLocationName
output mqInstanceName string = mqInstanceName