# KCL Dependency configuration for rook-ceph taskserv
# Defines comprehensive dependency, resource, and health requirements

import provisioning.dependencies as schema

# Rook-Ceph taskserv dependency configuration
_dependencies = schema.TaskservDependencies {
    name = "rook-ceph"

    # Critical dependencies - must be installed first
    requires = ["kubernetes", "containerd"]

    # Optional enhancements - install if available
    optional = ["cilium", "coredns"]

    # Cannot coexist with other storage solutions
    conflicts = ["external-nfs", "mayastor"]

    # Services provided by this taskserv
    provides = ["ceph-storage", "block-storage", "file-storage", "object-storage", "storage-class"]

    # Resource requirements for Rook-Ceph installation
    resources = schema.ResourceRequirement {
        cpu = "1000m"           # 1 CPU core for Ceph daemons
        memory = "2Gi"          # 2GB RAM minimum for Ceph operations
        disk = "50Gi"          # 50GB minimum for Ceph storage
        network = True          # Requires network for cluster replication
        privileged = True       # Needs privileged access for storage operations
    }

    # Health checks for Rook-Ceph components
    health_checks = [
        schema.HealthCheck {
            command = "kubectl get cephcluster -n rook-ceph -o jsonpath='{.items[0].status.phase}' | grep -q Ready"
            interval = 120
            timeout = 30
            retries = 5
            success_threshold = 2
            failure_threshold = 3
        },
        schema.HealthCheck {
            command = "kubectl get pods -n rook-ceph | grep -E 'rook-ceph-mon|rook-ceph-mgr|rook-ceph-osd' | grep -v Running | wc -l | grep -q '^0$'"
            interval = 60
            timeout = 15
            retries = 3
        },
        schema.HealthCheck {
            command = "kubectl exec -n rook-ceph deployment/rook-ceph-tools -- ceph status | grep -q 'HEALTH_OK'"
            interval = 180
            timeout = 30
            retries = 3
        }
    ]

    # Readiness probe for installation completion
    readiness_probe = schema.HealthCheck {
        command = "kubectl get storageclass rook-ceph-block -o jsonpath='{.metadata.name}' | grep -q rook-ceph-block"
        interval = 60
        timeout = 15
        retries = 10
        success_threshold = 3
    }

    # Installation phases for ordered deployment
    phases = [
        schema.InstallationPhase {
            name = "pre-install"
            order = 1
            parallel = False
            required = True
        },
        schema.InstallationPhase {
            name = "install"
            order = 2
            parallel = False
            required = True
        },
        schema.InstallationPhase {
            name = "post-install"
            order = 3
            parallel = True
            required = True
        },
        schema.InstallationPhase {
            name = "validate"
            order = 4
            parallel = False
            required = True
        }
    ]

    # Installation control - Ceph deployment takes longer
    timeout = 1800              # 30 minutes for full Ceph cluster setup
    retry_count = 2             # Fewer retries due to complexity

    # Platform compatibility
    os_support = ["linux"]
    arch_support = ["amd64", "arm64"]
    k8s_versions = ["1.31.x", "1.30.x", "1.29.x", "1.28.x"]
}

# Output for dynamic dependency resolution
_dependencies