# yaml-language-server: $schema=https://raw.githubusercontent.com/confluentinc/kcp/main/internal/manifest/gatewaymigration.schema.json
#
# A DYNAMIC migration (topic-based, TBM): topics cut over incrementally across a
# DYNAMIC Gateway route, promoting mirror topics at zero lag. Run one manifest
# per batch of topics; each batch's topicGroup selects only that batch.
#
#   kcp migration cutover execute --migration-yaml gateway-dynamic-migration.yaml
#
# Everything outside spec.dynamicMigration is identical to
# gateway-static-migration.yaml, which documents every shared field. The
# migration type is the section declared; kcp refuses to run if the live route
# is not dynamic. There is no consumerOffsetSync block: it is static-only.

apiVersion: kcp.confluent.io/v1alpha1
kind: GatewayMigration

metadata:
  name: msk-prod-to-cc-tbm-batch-1

spec:
  source:
    type: msk
    bootstrapServers:
      - b-1.msk-prod.abc123.c2.kafka.us-east-1.amazonaws.com:9096
      - b-2.msk-prod.abc123.c2.kafka.us-east-1.amazonaws.com:9096
    credentials: /etc/kcp/source-creds.yaml

  target:
    type: confluent-cloud
    clusterId: lkc-abc123
    kafka:
      bootstrapServers:
        - pkc-xxxxx.us-east-1.aws.confluent.cloud:9092
      restEndpoint: https://pkc-xxxxx.us-east-1.aws.confluent.cloud:443
      clusterCredentials: /etc/kcp/dest-kafka-creds.yaml

  clusterLink:
    name: msk-to-cc
    bootstrapServers:
      - pkc-xxxxx.us-east-1.aws.confluent.cloud:9092
    linkCredentials: /etc/kcp/link-creds.yaml

  gateway:
    namespace: confluent
    cr-name: gateway-initial

  dynamicMigration:
    route:
      name: migration-route # a pre-existing DYNAMIC route in the initial CR
      targetStreamingDomain: confluent-cloud

    # This batch only. Later batches are separate manifests with disjoint topics.
    topicGroup:
      - topics: ['t1.order', 't1.inventory']

    policies:
      lagThreshold: 0
      promoteBatchSize: 100 # 0 = promote all at once
      rolloutTimeout: 10m # 0 = no deadline
      detectUnroutedProducersDuration: 30s # 0 = CHECK SKIPPED; min 10s when set
      hotReloadTimeout: 90s
      gatewayConfigPort: 0
