Skip to content

Commit a13b0a9

Browse files
committed
oc-mirror deployment on container app
1 parent b3ae29e commit a13b0a9

File tree

25 files changed

+208
-309
lines changed

25 files changed

+208
-309
lines changed

.github/workflows/services-cd.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@
9696
run: |
9797
make maestro.server.deploy maestro.registration.deploy
9898
99-
- name: 'Deploy Image Sync'
100-
run: |
101-
make imagesync.deploy
102-
10399
- name: 'Deploy Prometheus Config'
104100
run: |
105101
make metrics.deploy

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,18 @@ infra.svc:
4141
@cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make svc.init
4242
.PHONY: infra.svc
4343

44+
infra.svc.aks.kubeconfigfile:
45+
@cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make svc.aks.kubeconfigfile
46+
.PHONY: infra.svc.aks.kubeconfigfile
47+
4448
infra.mgmt:
4549
@cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make mgmt.init
4650
.PHONY: infra.mgmt
4751

52+
infra.mgmt.aks.kubeconfigfile:
53+
@cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make mgmt.aks.kubeconfigfile
54+
.PHONY: infra.mgmt.aks.kubeconfigfile
55+
4856
infra.imagesync:
4957
@cd dev-infrastructure && DEPLOY_ENV=$(DEPLOY_ENV) make imagesync
5058
.PHONY: infra.imagesync
@@ -152,14 +160,6 @@ hypershift.deploy:
152160
@./svc-deploy.sh $(DEPLOY_ENV) hypershiftoperator mgmt
153161
.PHONY: hypershift.deploy
154162

155-
#
156-
# Image Sync
157-
#
158-
159-
imagesync.deploy:
160-
@./svc-deploy.sh $(DEPLOY_ENV) image-sync/deployment svc
161-
.PHONY: imagesync.deploy
162-
163163
#
164164
# Deploy ALL components
165165
#

config/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ defaults:
5656
imageSyncRepositories: registry.k8s.io/external-dns/external-dns,quay.io/acm-d/rhtap-hypershift-operator,quay.io/app-sre/uhc-clusters-service
5757
imageSyncImageRepo: image-sync/component-sync
5858
imageSyncImageTag: latest
59+
ocMirrorImageRepo: image-sync/oc-mirror
60+
ocMirrorImageTag: 7abc8af
5961

6062
# Service KeyVault
6163
serviceKeyVaultName: {{ azureKeyVaultName "svc-kv" 5 .ctx.region .ctx.regionStamp }}

dev-infrastructure/configurations/image-sync.tmpl.bicepparam

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ param keyVaultName = '{{ .serviceKeyVaultName}}'
77
param keyVaultResourceGroup = '{{ .serviceKeyVaultRG }}'
88

99
param bearerSecretName = 'bearer-secret'
10-
param pullSecretName = 'component-sync-pull-secret'
11-
10+
param componentSyncPullSecretName = 'component-sync-pull-secret'
1211
param componentSyncImage = '{{ .svcAcrName }}.azurecr.io/{{ .imageSyncImageRepo }}:{{ .imageSyncImageTag }}'
1312
param svcAcrName = '{{ .svcAcrName }}'
13+
14+
param ocpAcrName = '{{ .ocpAcrName }}'
15+
param ocpPullSecretName = 'pull-secret'
1416
param repositoriesToSync = '{{ .imageSyncRepositories }}'
17+
param ocMirrorImage = '{{ .svcAcrName }}.azurecr.io/{{ .ocMirrorImageRepo }}:{{ .ocMirrorImageTag }}'
1518
param numberOfTags = 10

dev-infrastructure/docs/development-setup.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,12 @@ To create the service cluster, management cluster and supporting infrastructure
117117
SKIP_CONFIRM=1 make infra.all
118118
```
119119

120-
Running this the first time takes around 60 minutes.
120+
Running this the first time takes around 60 minutes. Afterwards you can access your clusters with
121+
122+
```bash
123+
export KUBECONFIG=$(make infra.svc.aks.kubeconfigfile)
124+
export KUBECONFIG=$(make infra.mgmt.aks.kubeconfigfile)
125+
```
121126

122127
If you only need a management cluster or service cluster for development work, consider using one of the following commands. They take less time and the resulting infrastructure costs less money
123128

dev-infrastructure/templates/image-sync.bicep

Lines changed: 155 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@ param acrResourceGroup string
1616
@description('Name of the service component ACR registry')
1717
param 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')
2023
param keyVaultName string
2124

2225
@description('Name of the KeyVault RG')
2326
param 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')
2932
param bearerSecretName string
@@ -37,6 +40,12 @@ param repositoriesToSync string
3740
@description('The number of tags to sync per image in the repo list')
3841
param 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

96105
module 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'
114123
var pullSecretFile = 'quayio-auth.json'
115124

116125
resource 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+
}

image-sync/configuration/mvp-oc-mirror.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

image-sync/deployment/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

image-sync/deployment/Makefile

Lines changed: 0 additions & 45 deletions
This file was deleted.

image-sync/deployment/config.tmpl.mk

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)