|
| 1 | +# Create the destination registry pull secret with: |
| 2 | +# flux -n flux-system create secret oci ghcr-auth \ |
| 3 | +# --url=ghcr.io \ |
| 4 | +# --username=<github-user> \ |
| 5 | +# --password=<github-token-with-write:packages> |
| 6 | +# |
| 7 | +# Edit the ConfigMap below to set your own source and destination registries, |
| 8 | +# then apply the manifest with: |
| 9 | +# kubectl apply -f cronjob.yaml |
| 10 | +# |
| 11 | +# To trigger an out-of-band run instead of waiting for the schedule: |
| 12 | +# kubectl -n flux-system create job --from=cronjob/flux-mirror-podinfo flux-mirror-now |
| 13 | +--- |
| 14 | +apiVersion: v1 |
| 15 | +kind: ConfigMap |
| 16 | +metadata: |
| 17 | + name: flux-mirror-config |
| 18 | + namespace: flux-system |
| 19 | +data: |
| 20 | + mirror.yaml: | |
| 21 | + apiVersion: mirror.fluxcd.io/v1alpha1 |
| 22 | + kind: Config |
| 23 | + charts: |
| 24 | + - name: podinfo |
| 25 | + source: https://stefanprodan.github.io/podinfo |
| 26 | + destination: oci://ghcr.io/my-org/charts |
| 27 | + version: "*" |
| 28 | + limit: 1 |
| 29 | + artifacts: |
| 30 | + - source: ghcr.io/stefanprodan/podinfo |
| 31 | + destination: ghcr.io/my-org/podinfo |
| 32 | + selector: |
| 33 | + semver: "*" |
| 34 | + limit: 1 |
| 35 | + includeReferrers: true |
| 36 | +--- |
| 37 | +apiVersion: batch/v1 |
| 38 | +kind: CronJob |
| 39 | +metadata: |
| 40 | + name: flux-mirror-podinfo |
| 41 | + namespace: flux-system |
| 42 | +spec: |
| 43 | + schedule: "0 */6 * * *" |
| 44 | + concurrencyPolicy: Forbid |
| 45 | + successfulJobsHistoryLimit: 1 |
| 46 | + failedJobsHistoryLimit: 2 |
| 47 | + jobTemplate: |
| 48 | + spec: |
| 49 | + backoffLimit: 2 |
| 50 | + template: |
| 51 | + spec: |
| 52 | + restartPolicy: OnFailure |
| 53 | + securityContext: |
| 54 | + runAsNonRoot: true |
| 55 | + runAsUser: 65534 |
| 56 | + runAsGroup: 65534 |
| 57 | + fsGroup: 65534 |
| 58 | + seccompProfile: |
| 59 | + type: RuntimeDefault |
| 60 | + containers: |
| 61 | + - name: flux-mirror |
| 62 | + image: ghcr.io/fluxcd/flux-mirror:latest |
| 63 | + imagePullPolicy: IfNotPresent |
| 64 | + args: |
| 65 | + - sync |
| 66 | + - --config=/config/flux/mirror.yaml |
| 67 | + - --no-progress |
| 68 | + - --output=text |
| 69 | + env: |
| 70 | + - name: DOCKER_CONFIG |
| 71 | + value: /config/docker |
| 72 | + securityContext: |
| 73 | + allowPrivilegeEscalation: false |
| 74 | + readOnlyRootFilesystem: true |
| 75 | + capabilities: |
| 76 | + drop: ["ALL"] |
| 77 | + resources: |
| 78 | + requests: |
| 79 | + cpu: 100m |
| 80 | + memory: 64Mi |
| 81 | + limits: |
| 82 | + cpu: 2000m |
| 83 | + memory: 256Mi |
| 84 | + volumeMounts: |
| 85 | + - name: config |
| 86 | + mountPath: /config/flux |
| 87 | + readOnly: true |
| 88 | + - name: docker-config |
| 89 | + mountPath: /config/docker |
| 90 | + readOnly: true |
| 91 | + - name: tmp |
| 92 | + mountPath: /tmp |
| 93 | + volumes: |
| 94 | + - name: config |
| 95 | + configMap: |
| 96 | + name: flux-mirror-config |
| 97 | + - name: docker-config |
| 98 | + secret: |
| 99 | + secretName: ghcr-auth |
| 100 | + items: |
| 101 | + - key: .dockerconfigjson |
| 102 | + path: config.json |
| 103 | + - name: tmp |
| 104 | + emptyDir: {} |
0 commit comments