# Copyright (c) 2026 VirtRigaud Creators
# SPDX-License-Identifier: Apache-2.0

# Advanced VM Migration Example
# Demonstrates all available configuration options

apiVersion: infra.virtrigaud.io/v1beta1
kind: VMMigration
metadata:
  name: advanced-migration
  namespace: production
  labels:
    migration-batch: "2025-q1"
    priority: "high"
    team: "platform"
  annotations:
    migration.virtrigaud.io/requester: "ops-team@company.com"
    migration.virtrigaud.io/ticket: "INFRA-1234"
    migration.virtrigaud.io/estimated-duration: "2h"
spec:
  # Advanced source configuration
  source:
    vmRef:
      name: critical-app-vm
      namespace: production
    
    # Explicit provider reference (auto-detected if omitted)
    providerRef:
      name: vsphere-datacenter-1
      namespace: infrastructure
    
    # Use existing snapshot for migration
    snapshotRef:
      name: daily-backup-20250116
    createSnapshot: false
    
    # Power off VM before migration for data consistency
    powerOffBeforeMigration: true
    
    # Delete source VM after successful migration
    deleteAfterMigration: true
  
  # Advanced target configuration
  target:
    name: critical-app-vm-migrated
    namespace: production
    
    providerRef:
      name: proxmox-cluster-prod
      namespace: infrastructure
    
    # VM specifications
    classRef:
      name: high-performance-8cpu-16gb
    
    # Multiple network attachments
    networks:
      - name: production-frontend
        ipam:
          staticIP: "10.0.1.100"
      - name: production-backend
        ipam:
          staticIP: "10.0.2.100"
      - name: management
    
    # Specific disks configuration
    disks:
      - name: root
        size: 100Gi
        storageClass: fast-ssd
      - name: data
        size: 500Gi
        storageClass: standard-hdd
    
    # Placement on specific host/cluster
    placementRef:
      name: proxmox-node-prod-3
    
    # Labels and annotations for target VM
    labels:
      app: critical-app
      environment: production
      tier: frontend
      managed-by: virtrigaud
      migrated-from: vsphere
    
    annotations:
      backup.schedule: "0 2 * * *"
      monitoring.enabled: "true"
      compliance.level: "high"
  
  # Storage configuration — type: pvc is the only supported value in v0.3.6
  storage:
    type: pvc
    pvc:
      storageClassName: fast-nfs-rwx
      size: 600Gi
      accessMode: ReadWriteMany

  # Migration options
  options:
    # Disk format
    diskFormat: qcow2

    # Transfer options
    compress: true
    verifyChecksums: true

    # Timeout for very large VMs
    timeout: 8h

    # Retry policy with exponential backoff
    retryPolicy:
      maxRetries: 5
      retryDelay: 5m
      backoffMultiplier: 2

  # Migration metadata
  metadata:
    purpose: "provider-change"
    project: "Project Phoenix 2025"
    environment: "prod"

