# KCL Dependency configuration for kubernetes taskserv
# Defines comprehensive dependency, resource, and health requirements

import provisioning.dependencies as schema

# Kubernetes taskserv dependency configuration
_dependencies = schema.TaskservDependencies {
    name = "kubernetes"

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

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

    # Cannot coexist with alternative container runtimes
    conflicts = ["docker", "podman", "crio"]

    # Services provided by this taskserv
    provides = ["k8s-api", "kubelet", "kubectl", "kube-scheduler", "kube-controller-manager"]

    # Resource requirements for Kubernetes installation
    resources = schema.ResourceRequirement {
        cpu = "2000m"           # 2 CPU cores minimum
        memory = "2Gi"          # 2GB RAM minimum
        disk = "20Gi"           # 20GB for etcd, logs, images
        network = True          # Requires network for cluster communication
        privileged = True       # Needs privileged access for system integration
    }

    # Health checks for Kubernetes components
    health_checks = [
        schema.HealthCheck {
            command = "kubectl cluster-info"
            interval = 60
            timeout = 15
            retries = 3
            success_threshold = 2
            failure_threshold = 3
        },
        schema.HealthCheck {
            command = "systemctl is-active kubelet"
            interval = 30
            timeout = 5
            retries = 2
        }
    ]

    # Readiness probe for installation completion
    readiness_probe = schema.HealthCheck {
        command = "kubectl get nodes --no-headers | grep -q Ready"
        interval = 30
        timeout = 10
        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
    timeout = 1200              # 20 minutes for full cluster setup
    retry_count = 3

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

# Output for dynamic dependency resolution
_dependencies