# Kubernetes Workspace Server Configuration
# This template demonstrates Kubernetes cluster setup with loaded taskservs

import provisioning.settings as settings
import provisioning.server as server
import provisioning.defaults as defaults

# Import loaded taskservs (auto-generated by module-loader)
# Uncomment these after loading taskservs with:
# module-loader load taskservs . [kubernetes, cilium, containerd]

# import .taskservs.kubernetes.kubernetes as k8s
# import .taskservs.cilium.cilium as cilium
# import .taskservs.containerd.containerd as containerd

# Kubernetes workspace settings
k8s_settings: settings.Settings = {
    main_name = "kubernetes-cluster"
    main_title = "Kubernetes Infrastructure Cluster"

    # Configure paths
    settings_path = "./data/settings.yaml"
    defaults_provs_dirpath = "./defs"
    prov_data_dirpath = "./data"
    created_taskservs_dirpath = "./tmp/k8s-deployment"
    prov_resources_path = "./resources"
    created_clusters_dirpath = "./tmp/k8s-clusters"
    prov_clusters_path = "./clusters"

    # Kubernetes cluster settings
    cluster_admin_host = ""  # Set by provider (usually first master node)
    cluster_admin_port = 22
    cluster_admin_user = "admin"
    servers_wait_started = 45  # K8s nodes need more time

    runset = {
        wait = True
        output_format = "human"
        output_path = "tmp/k8s-deployment"
        inventory_file = "./k8s-inventory.yaml"
        use_time = True
    }
}

# Kubernetes cluster servers
k8s_servers: [server.Server] = [
    # Control plane nodes
    {
        hostname = "k8s-master-01"
        title = "Kubernetes Master Node 01"

        # Control plane requirements
        time_zone = "UTC"
        running_wait = 15
        running_timeout = 300
        storage_os_find = "name: debian-12 | arch: x86_64"

        # Network configuration
        network_utility_ipv4 = True
        network_public_ipv4 = True

        # User settings
        user = "admin"
        user_ssh_port = 22
        fix_local_hosts = True
        labels = "env: production, role: control-plane, tier: master"

        # Taskservs configuration (uncomment after loading modules)
        # taskservs = [
        #     { name = "containerd", profile = "default" },
        #     { name = "kubernetes", profile = "master" },
        #     { name = "cilium", profile = "default" }
        # ]
    },

    # Worker nodes
    {
        hostname = "k8s-worker-01"
        title = "Kubernetes Worker Node 01"

        # Worker node configuration
        time_zone = "UTC"
        running_wait = 15
        running_timeout = 300
        storage_os_find = "name: debian-12 | arch: x86_64"

        # Network configuration
        network_utility_ipv4 = True
        network_public_ipv4 = True

        # User settings
        user = "admin"
        user_ssh_port = 22
        fix_local_hosts = True
        labels = "env: production, role: worker, tier: compute"

        # Taskservs configuration (uncomment after loading modules)
        # taskservs = [
        #     { name = "containerd", profile = "default" },
        #     { name = "kubernetes", profile = "worker" },
        #     { name = "cilium", profile = "worker" }
        # ]
    },

    {
        hostname = "k8s-worker-02"
        title = "Kubernetes Worker Node 02"

        # Worker node configuration
        time_zone = "UTC"
        running_wait = 15
        running_timeout = 300
        storage_os_find = "name: debian-12 | arch: x86_64"

        # Network configuration
        network_utility_ipv4 = True
        network_public_ipv4 = True

        # User settings
        user = "admin"
        user_ssh_port = 22
        fix_local_hosts = True
        labels = "env: production, role: worker, tier: compute"

        # Taskservs configuration (uncomment after loading modules)
        # taskservs = [
        #     { name = "containerd", profile = "default" },
        #     { name = "kubernetes", profile = "worker" },
        #     { name = "cilium", profile = "worker" }
        # ]
    }
]

# Export for provisioning system
{
    settings = k8s_settings
    servers = k8s_servers
}
