@@ -16,14 +16,17 @@ param acrResourceGroup string
1616@description ('Name of the service component ACR registry' )
1717param svcAcrName string
1818
19+ @description ('Name of the OCP ACR registry' )
20+ param ocpAcrName string
21+
1922@description ('Name of the keyvault where the pull secret is stored' )
2023param keyVaultName string
2124
2225@description ('Name of the KeyVault RG' )
2326param keyVaultResourceGroup string
2427
25- @description ('The name of the pull secret' )
26- param pullSecretName string
28+ @description ('The name of the pull secret for the component sync job ' )
29+ param componentSyncPullSecretName string
2730
2831@description ('The name of the Quay API bearer token secret' )
2932param bearerSecretName string
@@ -37,6 +40,12 @@ param repositoriesToSync string
3740@description ('The number of tags to sync per image in the repo list' )
3841param numberOfTags int = 10
3942
43+ @description ('The image to use for the oc-mirror job' )
44+ param ocMirrorImage string
45+
46+ @description ('The name of the pull secret for the oc-mirror job' )
47+ param ocpPullSecretName string
48+
4049//
4150// Container App Infra
4251//
@@ -94,7 +103,7 @@ module acrPullRole '../modules/acr-permissions.bicep' = {
94103}
95104
96105module pullSecretPermission '../modules/keyvault/keyvault-secret-access.bicep' = [
97- for secretName in [pullSecretName , bearerSecretName ]: {
106+ for secretName in [componentSyncPullSecretName , bearerSecretName , ocpPullSecretName ]: {
98107 name : guid (imageSyncManagedIdentity , location , keyVaultName , secretName , 'secret-user' )
99108 scope : resourceGroup (keyVaultResourceGroup )
100109 params : {
@@ -110,11 +119,11 @@ module pullSecretPermission '../modules/keyvault/keyvault-secret-access.bicep' =
110119// Component sync job
111120//
112121
113- var jobName = 'component-sync'
122+ var componentSyncJobName = 'component-sync'
114123var pullSecretFile = 'quayio-auth.json'
115124
116125resource componentSyncJob 'Microsoft.App/jobs@2024-03-01' = {
117- name : jobName
126+ name : componentSyncJobName
118127 location : location
119128
120129 identity : {
@@ -143,7 +152,7 @@ resource componentSyncJob 'Microsoft.App/jobs@2024-03-01' = {
143152 secrets : [
144153 {
145154 name : 'pull-secrets'
146- keyVaultUrl : 'https://${keyVaultName }${environment ().suffixes .keyvaultDns }/secrets/${pullSecretName }'
155+ keyVaultUrl : 'https://${keyVaultName }${environment ().suffixes .keyvaultDns }/secrets/${componentSyncPullSecretName }'
147156 identity : uami .id
148157 }
149158 {
@@ -156,7 +165,7 @@ resource componentSyncJob 'Microsoft.App/jobs@2024-03-01' = {
156165 template : {
157166 containers : [
158167 {
159- name : jobName
168+ name : componentSyncJobName
160169 image : componentSyncImage
161170 volumeMounts : [
162171 { volumeName : 'pull-secrets-updated' , mountPath : '/auth' }
@@ -213,3 +222,142 @@ resource componentSyncJob 'Microsoft.App/jobs@2024-03-01' = {
213222 }
214223 }
215224}
225+
226+ // oc-mirror job
227+
228+ var ocMirrorJobName = 'oc-mirror'
229+
230+ var ocMirrorConfig = {
231+ kind : 'ImageSetConfiguration'
232+ apiVersion : 'mirror.openshift.io/v1alpha2'
233+ storageConfig : {
234+ registry : {
235+ imageURL : '${ocpAcrName }${environment ().suffixes .acrLoginServer }/mirror/oc-mirror-metadata'
236+ skipTLS : false
237+ }
238+ }
239+ mirror : {
240+ platform : {
241+ architectures : ['multi' ]
242+ channels : [
243+ {
244+ name : 'stable-4.16'
245+ type : 'ocp'
246+ full : true
247+ }
248+ {
249+ name : 'stable-4.17'
250+ type : 'ocp'
251+ full : true
252+ }
253+ ]
254+ graph : true
255+ }
256+ additionalImages : [
257+ { name : 'registry.redhat.io/redhat/redhat-operator-index:v4.16' }
258+ { name : 'registry.redhat.io/redhat/certified-operator-index:v4.16' }
259+ { name : 'registry.redhat.io/redhat/community-operator-index:v4.16' }
260+ { name : 'registry.redhat.io/redhat/redhat-marketplace-index:v4.16' }
261+ { name : 'registry.redhat.io/redhat/redhat-operator-index:v4.17' }
262+ { name : 'registry.redhat.io/redhat/certified-operator-index:v4.17' }
263+ { name : 'registry.redhat.io/redhat/community-operator-index:v4.17' }
264+ { name : 'registry.redhat.io/redhat/redhat-marketplace-index:v4.17' }
265+ ]
266+ }
267+ }
268+
269+ resource ocMirrorJob 'Microsoft.App/jobs@2024-03-01' = {
270+ name : ocMirrorJobName
271+ location : location
272+ identity : {
273+ type : 'UserAssigned'
274+ userAssignedIdentities : {
275+ '${uami .id }' : {}
276+ }
277+ }
278+
279+ properties : {
280+ environmentId : containerAppEnvironment .id
281+ configuration : {
282+ eventTriggerConfig : {}
283+ triggerType : 'Schedule'
284+ manualTriggerConfig : {
285+ parallelism : 1
286+ }
287+ scheduleTriggerConfig : {
288+ cronExpression : '0 * * * *'
289+ parallelism : 1
290+ }
291+ replicaTimeout : 4 * 60 * 60
292+ registries : [
293+ {
294+ identity : uami .id
295+ server : '${svcAcrName }${environment ().suffixes .acrLoginServer }'
296+ }
297+ ]
298+ secrets : [
299+ {
300+ name : 'pull-secrets'
301+ keyVaultUrl : 'https://${keyVaultName }${environment ().suffixes .keyvaultDns }/secrets/${ocpPullSecretName }'
302+ identity : uami .id
303+ }
304+ ]
305+ }
306+ template : {
307+ containers : [
308+ {
309+ name : ocMirrorJobName
310+ image : ocMirrorImage
311+ volumeMounts : [
312+ { volumeName : 'pull-secrets-updated' , mountPath : '/etc/containers' }
313+ ]
314+ env : [
315+ { name : 'IMAGE_SET_CONFIG' , value : base64 (string (ocMirrorConfig )) }
316+ { name : 'REGISTRY' , value : ocpAcrName }
317+ { name : 'REGISTRY_URL' , value : '${ocpAcrName }${environment ().suffixes .acrLoginServer }' }
318+ { name : 'XDG_RUNTIME_DIR' , value : '/etc' }
319+ { name : 'AZURE_CLIENT_ID' , value : uami .properties .clientId }
320+ {
321+ name : 'APPSETTING_WEBSITE_SITE_NAME'
322+ value : 'workaround - https://github.com/microsoft/azure-container-apps/issues/502'
323+ }
324+ ]
325+ resources : {
326+ cpu : 2
327+ memory : '4Gi'
328+ }
329+ }
330+ ]
331+ initContainers : [
332+ {
333+ name : 'decodesecrets'
334+ image : 'mcr.microsoft.com/azure-cli:cbl-mariner2.0'
335+ command : [
336+ '/bin/sh'
337+ ]
338+ args : [
339+ '-c'
340+ 'cat /tmp/secret-orig/pull-secrets | base64 -d > /etc/containers/auth.json'
341+ ]
342+ volumeMounts : [
343+ { volumeName : 'pull-secrets-updated' , mountPath : '/etc/containers' }
344+ { volumeName : 'pull-secrets' , mountPath : '/tmp/secret-orig' }
345+ ]
346+ }
347+ ]
348+ volumes : [
349+ {
350+ name : 'pull-secrets-updated'
351+ storageType : 'EmptyDir'
352+ }
353+ {
354+ name : 'pull-secrets'
355+ storageType : 'Secret'
356+ secrets : [
357+ { secretRef : 'pull-secrets' }
358+ ]
359+ }
360+ ]
361+ }
362+ }
363+ }
0 commit comments