# yaml-language-server: $schema=https://raw.githubusercontent.com/confluentinc/kcp/main/internal/manifest/gatewaymigration.schema.json
#
# A DYNAMIC-TO-STATIC route conversion (d2s): once a topic-based migration has
# migrated every topic on its cluster link, convert the dynamic route to a static
# route bound to the destination, carrying the consumer groups' committed offsets
# across. Topics stay the same; the route's mode changes.
#
#   kcp migration cutover execute --migration-yaml gateway-route-conversion.yaml --dry-run
#   kcp migration cutover execute --migration-yaml gateway-route-conversion.yaml
#
# The topology, auth and credentials files are the topic-based migration's own;
# gateway-static-migration.yaml documents every shared field. Paths in this file
# resolve relative to the PROCESS working directory.

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

metadata:
  name: msk-prod-to-cc-convert

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
    # Must be able to list every consumer group and describe every topic.
    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
      # Must also be able to list every consumer group, describe every topic and
      # write consumer-group offsets (READ on the groups and the topics): the
      # conversion copies the source's committed offsets here.
      clusterCredentials: /etc/kcp/dest-kafka-creds.yaml

  clusterLink:
    # The link the topic-based migration used. Every mirror topic on it is in
    # scope, and every one must be promoted.
    name: msk-to-cc
    linkCredentials: /etc/kcp/link-creds.yaml

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

  dynamicToStaticConversion:
    route:
      name: migration-route # the dynamic route the topic-based migration used
      # One of the two domains the dynamic route binds. Its binding's
      # bootstrapServerId is what the static route binds to.
      targetStreamingDomain: confluent-cloud
    # No topicGroup: a conversion covers every mirror on the link.

    policies:
      # The wait between the two committed-offset snapshots taken after the
      # fence, to catch a consumer committing to the source directly. Every topic
      # on the route is blocked for at least this long. 0s = skip the check;
      # min 10s when set.
      detectUnroutedCommitsDuration: 30s
      offsetSyncConcurrency: 0 # workers reading and writing offsets; 0 = built-in 8
      rolloutTimeout: 10m # 0 = no deadline
      hotReloadTimeout: 90s # 0 = built-in 90s budget; never unbounded
