{
  "namespace": "observability",
  "region": "prod-aws-us-east-1",
  "sourceReplicaCount": 5,
  "targetReplicaCount": 3,
  "shardStepInterval": "6h",
  "vmselects": {
    "image": "557537366020.dkr.ecr.us-west-2.amazonaws.com/victoriametrics/vmselect:v1.122.2-cluster",
    "migration": {
      "replicas": 1,
      "resources": {
        "requests": {
          "cpu": "0.5",
          "memory": "2Gi"
        },
        "limits": {
          "cpu": "1",
          "memory": "4Gi"
        }
      }
    },
    "candidate": {
      "replicas": 1,
      "resources": {
        "requests": {
          "cpu": "0.5",
          "memory": "2Gi"
        },
        "limits": {
          "cpu": "1",
          "memory": "4Gi"
        }
      }
    }
  },
  "retentionWindow": {
    "start": "2026-04-23T00:00:00Z",
    "end": "2026-07-09T00:00:00Z"
  },
  "vmctl": {
    "rateLimitBytes": 100000000,
    "concurrency": 24,
    "stepInterval": "day"
  },
  "steps": {
    "prepare": {
      "items": [
        {
          "name": "preflight",
          "desc": "Describe the VMCluster; manually confirm Ready status, frozen vmagent split rules, and target cluster readiness",
          "command": [
            "kubectl -n {{.namespace}} describe vmcluster {{.vmcluster}}"
          ]
        },
        {
          "name": "generate-tenants",
          "desc": "Generate the tenant lists, flatten them with `vm-migration tenants merge`, then pass the flat list to `plan compile` via --tenants (example commands — adjust flags per environment)",
          "command": [
            "# Example commands — adjust flags per environment (see vm-migration tenants --help).",
            "vm-migration tenants dedicated k8s --output tenants-dedicated-k8s.json",
            "vm-migration tenants dedicated s3 --s3-bucket <bucket> --output tenants-dedicated-s3.json",
            "vm-migration tenants essential mgmt --addr <addr> --region <region> --provider <provider> --output essential-mgmt.json",
            "vm-migration tenants essential rds --clusters-in essential-mgmt.json --secret-file <secret-file> --db-host <db-host> --output essential-rds.json",
            "vm-migration tenants essential s3 --clusters-in essential-rds.json --s3-bucket <bucket> --output tenants-essential.json",
            "vm-migration tenants merge --input tenants-dedicated-k8s.json --input tenants-dedicated-s3.json --input tenants-essential.json --output tenants.json"
          ]
        },
        {
          "name": "enable-dedup",
          "desc": "Patch VMCluster vmselect.extraArgs dedup.minScrapeInterval=1ms; idempotent",
          "command": [
            "yq -i 'with(select(.kind == \"VMCluster\"); .spec.vmselect.extraArgs.\"dedup.minScrapeInterval\" = \"1ms\")' <repo-path>/deployments/dataplane/vmcluster/envs/<region>/vmcluster.yaml",
            "git -C <repo-path> diff -- deployments/dataplane/vmcluster/envs/{{.region}}/vmcluster.yaml",
            "# Review the diff above; commit and push when ready (not done by this tool). Wait for ArgoCD sync before proceeding to the next stage."
          ]
        },
        {
          "name": "drain-insert",
          "desc": "Patch maintenanceInsertNodeIDs=[{{.drainStart}}..{{.drainEnd}}]; new writes hash only to vmstorage-{{.retainStart}}..{{.retainEnd}}",
          "command": [
            "yq -i 'with(select(.kind == \"VMCluster\"); .spec.vmstorage.maintenanceInsertNodeIDs = [{{.drainOrdinalsYaml}}])' <repo-path>/deployments/dataplane/vmcluster/envs/<region>/vmcluster.yaml",
            "git -C <repo-path> diff -- deployments/dataplane/vmcluster/envs/{{.region}}/vmcluster.yaml",
            "# Review the diff above; commit and push when ready (not done by this tool). Wait for ArgoCD sync before proceeding to the next stage."
          ]
        },
        {
          "name": "deploy-vmselects",
          "desc": "Deploy both temporary vmselects via the serve API: vmselect-migration on {{.drainStart}}..{{.drainEnd}} (vmctl export source) and vmselect-candidate on {{.retainStart}}..{{.retainEnd}} (verification query path)",
          "command": [
            "# The migration must exist on serve first: curl -X POST <serve>/migrations/<name> --data-binary @<compiled-plan.json>",
            "curl -X POST <serve>/migrations/<name>/deploy",
            "curl -N <serve>/migrations/<name>/logs"
          ]
        }
      ]
    },
    "migration": {
      "items": [
        {
          "name": "run",
          "desc": "run",
          "command": [
            "curl -X POST <serve>/migrations/<name>/run -d '{\"retries\":0}'",
            "curl -N <serve>/migrations/<name>/logs",
            "curl '<serve>/migrations/<name>/summary?format=text'"
          ]
        }
      ]
    },
    "decommission": {
      "items": [
        {
          "name": "drain-select",
          "desc": "Patch maintenanceSelectNodeIDs=[{{.drainStart}}..{{.drainEnd}}]; production queries no longer touch vmstorage-{{.drainStart}}..{{.drainEnd}}",
          "command": [
            "yq -i 'with(select(.kind == \"VMCluster\"); .spec.vmstorage.maintenanceSelectNodeIDs = [{{.drainOrdinalsYaml}}])' <repo-path>/deployments/dataplane/vmcluster/envs/<region>/vmcluster.yaml",
            "git -C <repo-path> diff -- deployments/dataplane/vmcluster/envs/{{.region}}/vmcluster.yaml",
            "# Review the diff above; commit and push when ready (not done by this tool). Wait for ArgoCD sync before proceeding to the next stage."
          ]
        },
        {
          "name": "scale-down",
          "desc": "Patch vmstorage.replicaCount={{.target}}; StatefulSet removes pods {{.drainStart}}..{{.drainEnd}} in reverse order while PVCs are retained",
          "command": [
            "yq -i 'with(select(.kind == \"VMCluster\"); .spec.vmstorage.replicaCount = {{.target}})' <repo-path>/deployments/dataplane/vmcluster/envs/<region>/vmcluster.yaml",
            "git -C <repo-path> diff -- deployments/dataplane/vmcluster/envs/{{.region}}/vmcluster.yaml",
            "# Review the diff above; commit and push when ready (not done by this tool). Wait for ArgoCD sync before proceeding to the next stage."
          ]
        },
        {
          "name": "cleanup",
          "desc": "Undeploy vmselect-migration and vmselect-candidate after the rollback window closes",
          "command": [
            "curl -X POST <serve>/migrations/<name>/undeploy",
            "curl -N <serve>/migrations/<name>/logs"
          ]
        }
      ]
    }
  }
}
