|
| 1 | +# In-sandbox caching mirror for the Talos Image Factory worker OS disk image. |
| 2 | +# |
| 3 | +# Why this exists: tenant Kubernetes worker VMs boot from a Talos raw disk image |
| 4 | +# that CDI streams over HTTP from the PUBLIC Talos Image Factory |
| 5 | +# (https://factory.talos.dev/image/<schematicID>/<version>/openstack-amd64.raw.xz). |
| 6 | +# That endpoint does not support byte-range requests (so CDI falls back to a full |
| 7 | +# sequential copy-to-scratch) and its egress is intermittently flaky from the CI |
| 8 | +# runner — a mid-transfer HTTP/2 stream reset or a stalled download makes the |
| 9 | +# worker DataVolume import never finish, the worker VM never boots, no tenant |
| 10 | +# node joins within the chart's 12-minute node-join deadline, and the |
| 11 | +# `kubernetes-*` e2e tests fail (and, even when they pass, take 18-22 minutes |
| 12 | +# each dominated by these downloads). See cozystack/cozystack#3231. |
| 13 | +# |
| 14 | +# This Deployment fetches the image ONCE at e2e-install time with an aggressive |
| 15 | +# curl retry loop (decoupling the one flaky external fetch from the many |
| 16 | +# per-worker imports), then serves it locally over plain HTTP with range support. |
| 17 | +# Tenant `Kubernetes` CRs point `spec.talos.imageFactoryURL` at this Service |
| 18 | +# (see hack/e2e-apps/run-kubernetes.sh) so every worker imports from the warm |
| 19 | +# local copy instead of the public internet. If this Deployment never becomes |
| 20 | +# Available the e2e harness falls back to the public factory (status quo), so the |
| 21 | +# mirror can only help, never make CI worse. |
| 22 | +# |
| 23 | +# The __SCHEMATIC_ID__ / __TALOS_VERSION__ placeholders are substituted at apply |
| 24 | +# time by hack/e2e-install-cozystack.bats from packages/apps/kubernetes/values.yaml. |
| 25 | +# |
| 26 | +# CI band-aid, not a product artifact. The durable fix is the overridable |
| 27 | +# `talos.imageFactoryURL` chart value this manifest exercises; a self-hosted |
| 28 | +# Talos Image Factory or an operator's own mirror is the production path. |
| 29 | +apiVersion: v1 |
| 30 | +kind: Service |
| 31 | +metadata: |
| 32 | + name: talos-image-cache |
| 33 | + namespace: kube-system |
| 34 | + labels: |
| 35 | + app.kubernetes.io/name: talos-image-cache |
| 36 | +spec: |
| 37 | + selector: |
| 38 | + app.kubernetes.io/name: talos-image-cache |
| 39 | + ports: |
| 40 | + - name: http |
| 41 | + port: 80 |
| 42 | + targetPort: http |
| 43 | +--- |
| 44 | +apiVersion: apps/v1 |
| 45 | +kind: Deployment |
| 46 | +metadata: |
| 47 | + name: talos-image-cache |
| 48 | + namespace: kube-system |
| 49 | + labels: |
| 50 | + app.kubernetes.io/name: talos-image-cache |
| 51 | +spec: |
| 52 | + replicas: 1 |
| 53 | + selector: |
| 54 | + matchLabels: |
| 55 | + app.kubernetes.io/name: talos-image-cache |
| 56 | + strategy: |
| 57 | + type: Recreate |
| 58 | + template: |
| 59 | + metadata: |
| 60 | + labels: |
| 61 | + app.kubernetes.io/name: talos-image-cache |
| 62 | + spec: |
| 63 | + # The seed fetch and static serving use ordinary pod networking — the same |
| 64 | + # egress path the CDI importer pods already use to reach factory.talos.dev. |
| 65 | + initContainers: |
| 66 | + # Fetch the compressed raw disk image ONCE, retrying hard against the |
| 67 | + # flaky upstream. The Deployment only becomes Available after this |
| 68 | + # succeeds, so "Available" is the e2e harness's signal that the mirror is |
| 69 | + # warm and safe to point tenants at. |
| 70 | + - name: seed |
| 71 | + # Reuse the in-tree, digest-pinned image already shipped by the |
| 72 | + # installer and pre-pulled for the cilium-leak-healer watchdog, so this |
| 73 | + # pod does not add a fresh external image pull of its own. |
| 74 | + image: docker.io/alpine/k8s:1.36.2@sha256:44ef4942e171939b9c665a4a84beb80e2dcdb9a24330d4651cfdfd2e9deecc47 |
| 75 | + command: [/bin/sh, -ec] |
| 76 | + args: |
| 77 | + - | |
| 78 | + dest="/data/image/__SCHEMATIC_ID__/__TALOS_VERSION__/openstack-amd64.raw.xz" |
| 79 | + url="https://factory.talos.dev/image/__SCHEMATIC_ID__/__TALOS_VERSION__/openstack-amd64.raw.xz" |
| 80 | + mkdir -p "$(dirname "$dest")" |
| 81 | + echo "seeding $dest from $url" |
| 82 | + # --retry-all-errors + a long retry budget rides out the mid-transfer |
| 83 | + # stream resets / stalls that break the CDI importer's single attempt. |
| 84 | + curl --fail --location --show-error \ |
| 85 | + --retry 30 --retry-all-errors --retry-delay 15 \ |
| 86 | + --connect-timeout 30 \ |
| 87 | + --output "$dest" \ |
| 88 | + "$url" |
| 89 | + ls -la "$dest" |
| 90 | + volumeMounts: |
| 91 | + - name: data |
| 92 | + mountPath: /data |
| 93 | + containers: |
| 94 | + - name: serve |
| 95 | + image: docker.io/alpine/k8s:1.36.2@sha256:44ef4942e171939b9c665a4a84beb80e2dcdb9a24330d4651cfdfd2e9deecc47 |
| 96 | + # busybox httpd serves static files with HTTP range support, so a warm |
| 97 | + # mirror also lets CDI use its faster range path instead of the |
| 98 | + # copy-to-scratch fallback the range-less public factory forces. |
| 99 | + command: [/bin/sh, -ec] |
| 100 | + args: |
| 101 | + - exec busybox httpd -f -v -p 8080 -h /data |
| 102 | + ports: |
| 103 | + - name: http |
| 104 | + containerPort: 8080 |
| 105 | + readinessProbe: |
| 106 | + tcpSocket: |
| 107 | + port: http |
| 108 | + initialDelaySeconds: 2 |
| 109 | + periodSeconds: 5 |
| 110 | + resources: |
| 111 | + requests: |
| 112 | + cpu: 20m |
| 113 | + memory: 32Mi |
| 114 | + limits: |
| 115 | + memory: 128Mi |
| 116 | + volumeMounts: |
| 117 | + - name: data |
| 118 | + mountPath: /data |
| 119 | + volumes: |
| 120 | + - name: data |
| 121 | + emptyDir: {} |
0 commit comments