/migrate-fly-to-k8s:migrate-fly-to-k8sfrom migrate-fly-to-k8s
Migrate an existing Fly.io application to the oort or kuiper k3s clusters (~/src/oort, dvcrn/k8s) with Cloudflare Tunnels, 1Password secrets, kuiper GHCR release builds, and OpenTelemetry via Grafana Alloy. Use when moving an app off Fly.io onto Kubernetes or oort, staging ${cluster}.<domain> ahead of DNS cutover, or retiring fly-deploy.yml. Don't use for hosting a new greenfield app with no Fly.io deployment to migrate; use ~/src/oort/.agents/skills/host-app/SKILL.md.
Ships in migrate-fly-to-k8s. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Move a live Fly.io service onto ~/src/oort (github.com/dvcrn/k8s) by staging on ${cluster}.<domain> before cutting the app's hostname over.
Read ~/src/oort/.agents/skills/host-app/SKILL.md for manifest shapes (overriding its kuiper and ghcr.io/dvcrn/<app> defaults: live Fly migrations target oort directly with Flux image automation on ghcr.io/digitalvibeshq/<app>) and references/examples.md before editing probes, release workflows, or DNS cutover commits. For Elixir/Phoenix apps, load migrate-to-otel-elixir if :new_relic_agent is present, otherwise install-otel-elixir.
fly.toml config before provisioning storage.
fly.toml ([env], [[mounts]]), Dockerfile, priv/repo/migrations/, and rg "Repo\." lib/. Carry required non-secret [env] entries (such as DATABASE_PATH) into deployment.yaml.Repo queries exist (unused phx.new SQLite scaffolding), delete Repo, ecto_sql, ecto_sqlite3, DATABASE_PATH, rel/overlays/bin/migrate, and Dockerfile VOLUME entries; keep {:ecto, "~> 3.13"} if embedded schemas or changesets remain, and deploy stateless with no pvc.yaml (zero-downtime cutover).pvc.yaml + strategy: {type: Recreate} + initContainers migrations per host-app, stage with an empty or test DB in Step 4, and agree on a brief write-freeze window during Step 6 to copy a clean snapshot (sqlite3 <db> ".backup /tmp/backup.db" on Fly -> fly ssh sftp get -> kubectl cp into the oort PVC). If the app uses Litestream, follow Database - SQLite & Litestream instead of initContainers migrations and kubectl cp.fly ssh console -C "sqlite3 <db> '.backup /tmp/backup.db'", fly ssh sftp get /tmp/backup.db /tmp/backup.db, test -s /tmp/backup.db, then PRAGMA integrity_check and row counts. Run fly status first and wake a stopped auto_stop_machines app with an HTTP request, or sftp prints fly status and sqlite3 silently creates an empty local DB.storageClassName: local-path-retain. Check it exists (mise -C ~/src/oort x -- kubectl --context <cluster>-ts get storageclass); if missing, wire the manifest from ~/src/oort/infrastructure/storage/ in via a storage Flux Kustomization in clusters/<cluster>/infrastructure.yaml plus dependsOn: [storage] on apps in clusters/<cluster>/apps.yaml. If no retain class can be enabled, stop the migration.DNSCluster (FLY_APP_NAME.internal), Fly IPv6 node naming in rel/env.sh.eex (RELEASE_NODE, ECTO_IPV6), and FLY_* / NEW_RELIC_* runtime config and fnox.toml keys. Treat "" as unset when reading ENV RELEASE_VERSION="" in config/runtime.exs.fly.toml and .github/workflows/fly-deploy.yml intact until Step 6 so main stays deployable on Fly while staging./health). Because kubelet hits the pod IP over plain HTTP without X-Forwarded-Proto: https, exclude the health path in config/prod.exs (force_ssl: [rewrite_on: [:x_forwarded_proto], exclude: [paths: ["/health"], hosts: ["localhost", "127.0.0.1"]]]); use httpHeaders: [{name: X-Forwarded-Proto, value: https}] on probes only when app code cannot be modified, or Phoenix returns 301 (ProbeWarning).301 when Host != PHX_HOST (kubelet sends Host: <pod-ip>); mount /health in a router scope outside those pipelines, or exclude /health in the plug itself when it sits in endpoint.ex.initialDelaySeconds: 5 on readinessProbe (and initialDelaySeconds: 15 if adding livenessProbe) so BEAM/Bandit startup (~3-4s) does not emit Unhealthy: connection refused on rollout.digitalvibeshq and publish 0.1.0 before deploying apps/<app>.
dvcrn/<app> to digitalvibeshq/<app> (gh api repos/dvcrn/<app>/transfer -f new_owner=digitalvibeshq and git remote set-url origin ...) so workflows can use the kuiper ARC runner scale set..github/workflows/release.yml triggered on tags: ["[0-9]+.[0-9]+.[0-9]+"] using runs-on: kuiper, docker/setup-buildx-action@v4 (driver: remote, endpoint: tcp://buildkitd.buildkit.svc.cluster.local:1234, no cache-from/cache-to), and platforms: linux/arm64 pushing ghcr.io/digitalvibeshq/<app>:{{version}}.0.1.0 on main, and wait for release.yml to push ghcr.io/digitalvibeshq/<app>:0.1.0 before deploying apps/<app> in dvcrn/k8s (avoids ImagePullBackOff and Flux ImageRepository NAME_UNKNOWN).~/src/oort/apps/<app>/ staged on ${cluster}.<domain>.
env -u OP_SERVICE_ACCOUNT_TOKEN op ... when checking or creating vaults/k8s-oort/items/<app> so a stale ambient service-account token does not return 403. Follow host-app placeholder rules (never pass plaintext secrets on CLI arguments) and pause until the user fills real values, preserving Fly's existing SECRET_KEY_BASE / signing / encryption keys so cookies and data survive cutover.rg each name from fly secrets list and drop the dead ones. Pipe values from fly ssh console -C env through jq -R into an op item create template on stdin without printing them; secrets copied this way need no placeholder pause.apps/<app>/ per host-app with image: ghcr.io/digitalvibeshq/<app>:0.1.0 # {"$imagepolicy": "<app>:<app>"} and spec.image: ghcr.io/digitalvibeshq/<app> in image.yaml.OTEL_SERVICE_NAME=<app>, OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf, OTEL_EXPORTER_OTLP_ENDPOINT=http://alloy.alloy.svc.cluster.local:4318) with zero Axiom tokens in app pods.fqdn: ${cluster}.<domain> in tunnelbinding.yaml and PHX_HOST: ${cluster}.<domain> in deployment.yaml while <domain> remains on Fly.<sub>.<zone>), stage on ${cluster}-<sub>.<zone>, because Universal SSL does not cover the two-level ${cluster}.<sub>.<zone>. When several apps share a zone, add ~/src/oort/infrastructure/cloudflare/clustertunnel-<zone>.yaml (listed in that directory's kustomization.yaml) instead of an app-local clustertunnel.yaml (reuse it if it exists), and point tunnelbinding.yaml at it with tunnelRef: {kind: ClusterTunnel, name: ${cluster}-<zone-with-dashes>}.oort.
dvcrn/k8s change once confirmed, run mise -C ~/src/oort x -- flux --context oort-ts reconcile kustomization apps -n flux-system --with-source, and verify 0 Unhealthy or ProbeWarning events (kubectl --context oort-ts -n <app> get events), HTTP/2 200 on https://<staging-host>/health, working WebSockets, and trace_id/span_id logs in Axiom.~/src/oort, change fqdn and PHX_HOST from the staging host to <domain>; (b) in the app repo, git rm .github/workflows/fly-deploy.yml. For stateful apps without Litestream, freeze writes on Fly and copy the .backup SQLite snapshot into the oort PVC now.A/AAAA (or CNAME) records for <domain> in Cloudflare; for a subdomain like esim.d.sh these are the subdomain's own records, not the zone apex. Do not remove Fly's TLS certificate (flyctl certs remove) before those records are deleted, or Cloudflare Full (Strict) TLS serves 525 errors during cutover.apps, and verify https://<domain>/health hits the oort pod (x-request-id in kubectl logs).CNAME and _managed.<staging-host> TXT records (left behind by in-place TunnelBinding fqdn edits) plus Fly's _acme-challenge / _fly-ownership records in Cloudflare. Leave fly.toml and the Fly app intact for rollback until the user asks to destroy it.Applies only when the app replicates SQLite with Litestream. Read example 5 in references/examples.md before editing the start script or seeding R2.
COPY --from=litestream/litestream:<ver>), never :latest: 0.3 and 0.5 replica formats are incompatible, and a typical start script boots an empty DB when restore fails. Check Fly's version (fly ssh console -C "litestream version") and pin the latest patch of that minor line (Fly on 0.5.x -> latest 0.5.x, never across 0.3/0.5).<app>-litestream in account 02c07a2514d9a25f58c78a180bb8c6f3 (endpoint https://<account>.r2.cloudflarestorage.com, region auto), never to the replica Fly still writes (two writers corrupt it). R2 over Tigris: 1M free Class A ops/month vs 10k, and no Fly account dependency.k8s-oort 1Password item as AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY; bucket, endpoint, and region are plain env in deployment.yaml.litestream.yml under /tmp, not /etc. The deployment needs strategy: {type: Recreate}, fsGroup: 65534, the PVC on local-path-retain, and livenessProbe.initialDelaySeconds: 30 because restore runs before boot.initContainers migrations: a migrate step on an empty PVC creates the DB file, so restore -if-db-not-exists skips R2. Run migrations in the app after restore (Ecto.Migrator in the supervision tree).replicate, wait for snapshot complete, stop it, then restore -if-db-not-exists into an empty dir and compare row counts. Pass credentials as -e NAME from env (op read), never as literal values. The first pod on an empty PVC restores from R2.apps/<app> is applied, scale the deployment to 0, purge <bucket>/<db>, delete .<db>-litestream on the PVC (or the PVC itself), seed, then scale to 1. Purge with rclone purge (S3 env config); aws may be an unconfigured mise shim.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub dvcrn/skills --plugin migrate-fly-to-k8s