620 lines
27 KiB
HTML
620 lines
27 KiB
HTML
|
|
<!DOCTYPE HTML>
|
||
|
|
<html lang="en" class="ayu sidebar-visible" dir="ltr">
|
||
|
|
<head>
|
||
|
|
<!-- Book generated using mdBook -->
|
||
|
|
<meta charset="UTF-8">
|
||
|
|
<title>Taskserv Developer Guide - Provisioning Platform Documentation</title>
|
||
|
|
|
||
|
|
|
||
|
|
<!-- Custom HTML head -->
|
||
|
|
|
||
|
|
<meta name="description" content="Complete documentation for the Provisioning Platform - Infrastructure automation with Nushell, KCL, and Rust">
|
||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
|
|
<meta name="theme-color" content="#ffffff">
|
||
|
|
|
||
|
|
<link rel="icon" href="../favicon.svg">
|
||
|
|
<link rel="shortcut icon" href="../favicon.png">
|
||
|
|
<link rel="stylesheet" href="../css/variables.css">
|
||
|
|
<link rel="stylesheet" href="../css/general.css">
|
||
|
|
<link rel="stylesheet" href="../css/chrome.css">
|
||
|
|
<link rel="stylesheet" href="../css/print.css" media="print">
|
||
|
|
|
||
|
|
<!-- Fonts -->
|
||
|
|
<link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
|
||
|
|
<link rel="stylesheet" href="../fonts/fonts.css">
|
||
|
|
|
||
|
|
<!-- Highlight.js Stylesheets -->
|
||
|
|
<link rel="stylesheet" id="highlight-css" href="../highlight.css">
|
||
|
|
<link rel="stylesheet" id="tomorrow-night-css" href="../tomorrow-night.css">
|
||
|
|
<link rel="stylesheet" id="ayu-highlight-css" href="../ayu-highlight.css">
|
||
|
|
|
||
|
|
<!-- Custom theme stylesheets -->
|
||
|
|
|
||
|
|
|
||
|
|
<!-- Provide site root and default themes to javascript -->
|
||
|
|
<script>
|
||
|
|
const path_to_root = "../";
|
||
|
|
const default_light_theme = "ayu";
|
||
|
|
const default_dark_theme = "navy";
|
||
|
|
</script>
|
||
|
|
<!-- Start loading toc.js asap -->
|
||
|
|
<script src="../toc.js"></script>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<div id="mdbook-help-container">
|
||
|
|
<div id="mdbook-help-popup">
|
||
|
|
<h2 class="mdbook-help-title">Keyboard shortcuts</h2>
|
||
|
|
<div>
|
||
|
|
<p>Press <kbd>←</kbd> or <kbd>→</kbd> to navigate between chapters</p>
|
||
|
|
<p>Press <kbd>S</kbd> or <kbd>/</kbd> to search in the book</p>
|
||
|
|
<p>Press <kbd>?</kbd> to show this help</p>
|
||
|
|
<p>Press <kbd>Esc</kbd> to hide this help</p>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div id="body-container">
|
||
|
|
<!-- Work around some values being stored in localStorage wrapped in quotes -->
|
||
|
|
<script>
|
||
|
|
try {
|
||
|
|
let theme = localStorage.getItem('mdbook-theme');
|
||
|
|
let sidebar = localStorage.getItem('mdbook-sidebar');
|
||
|
|
|
||
|
|
if (theme.startsWith('"') && theme.endsWith('"')) {
|
||
|
|
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
|
||
|
|
}
|
||
|
|
|
||
|
|
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
|
||
|
|
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
|
||
|
|
}
|
||
|
|
} catch (e) { }
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<!-- Set the theme before any content is loaded, prevents flash -->
|
||
|
|
<script>
|
||
|
|
const default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? default_dark_theme : default_light_theme;
|
||
|
|
let theme;
|
||
|
|
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
|
||
|
|
if (theme === null || theme === undefined) { theme = default_theme; }
|
||
|
|
const html = document.documentElement;
|
||
|
|
html.classList.remove('ayu')
|
||
|
|
html.classList.add(theme);
|
||
|
|
html.classList.add("js");
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
|
||
|
|
|
||
|
|
<!-- Hide / unhide sidebar before it is displayed -->
|
||
|
|
<script>
|
||
|
|
let sidebar = null;
|
||
|
|
const sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
|
||
|
|
if (document.body.clientWidth >= 1080) {
|
||
|
|
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
|
||
|
|
sidebar = sidebar || 'visible';
|
||
|
|
} else {
|
||
|
|
sidebar = 'hidden';
|
||
|
|
}
|
||
|
|
sidebar_toggle.checked = sidebar === 'visible';
|
||
|
|
html.classList.remove('sidebar-visible');
|
||
|
|
html.classList.add("sidebar-" + sidebar);
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
|
||
|
|
<!-- populated by js -->
|
||
|
|
<mdbook-sidebar-scrollbox class="sidebar-scrollbox"></mdbook-sidebar-scrollbox>
|
||
|
|
<noscript>
|
||
|
|
<iframe class="sidebar-iframe-outer" src="../toc.html"></iframe>
|
||
|
|
</noscript>
|
||
|
|
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
|
||
|
|
<div class="sidebar-resize-indicator"></div>
|
||
|
|
</div>
|
||
|
|
</nav>
|
||
|
|
|
||
|
|
<div id="page-wrapper" class="page-wrapper">
|
||
|
|
|
||
|
|
<div class="page">
|
||
|
|
<div id="menu-bar-hover-placeholder"></div>
|
||
|
|
<div id="menu-bar" class="menu-bar sticky">
|
||
|
|
<div class="left-buttons">
|
||
|
|
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
|
||
|
|
<i class="fa fa-bars"></i>
|
||
|
|
</label>
|
||
|
|
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
|
||
|
|
<i class="fa fa-paint-brush"></i>
|
||
|
|
</button>
|
||
|
|
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
|
||
|
|
<li role="none"><button role="menuitem" class="theme" id="default_theme">Auto</button></li>
|
||
|
|
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
|
||
|
|
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
|
||
|
|
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
|
||
|
|
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
|
||
|
|
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
|
||
|
|
</ul>
|
||
|
|
<button id="search-toggle" class="icon-button" type="button" title="Search (`/`)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="/ s" aria-controls="searchbar">
|
||
|
|
<i class="fa fa-search"></i>
|
||
|
|
</button>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<h1 class="menu-title">Provisioning Platform Documentation</h1>
|
||
|
|
|
||
|
|
<div class="right-buttons">
|
||
|
|
<a href="../print.html" title="Print this book" aria-label="Print this book">
|
||
|
|
<i id="print-button" class="fa fa-print"></i>
|
||
|
|
</a>
|
||
|
|
<a href="https://github.com/provisioning/provisioning-platform" title="Git repository" aria-label="Git repository">
|
||
|
|
<i id="git-repository-button" class="fa fa-github"></i>
|
||
|
|
</a>
|
||
|
|
<a href="https://github.com/provisioning/provisioning-platform/edit/main/provisioning/docs/src/development/TASKSERV_DEVELOPER_GUIDE.md" title="Suggest an edit" aria-label="Suggest an edit">
|
||
|
|
<i id="git-edit-button" class="fa fa-edit"></i>
|
||
|
|
</a>
|
||
|
|
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div id="search-wrapper" class="hidden">
|
||
|
|
<form id="searchbar-outer" class="searchbar-outer">
|
||
|
|
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
|
||
|
|
</form>
|
||
|
|
<div id="searchresults-outer" class="searchresults-outer hidden">
|
||
|
|
<div id="searchresults-header" class="searchresults-header"></div>
|
||
|
|
<ul id="searchresults">
|
||
|
|
</ul>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
|
||
|
|
<script>
|
||
|
|
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
|
||
|
|
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
|
||
|
|
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
|
||
|
|
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
|
||
|
|
});
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<div id="content" class="content">
|
||
|
|
<main>
|
||
|
|
<h1 id="taskserv-developer-guide"><a class="header" href="#taskserv-developer-guide">Taskserv Developer Guide</a></h1>
|
||
|
|
<h2 id="overview"><a class="header" href="#overview">Overview</a></h2>
|
||
|
|
<p>This guide covers how to develop, create, and maintain taskservs in the provisioning system. Taskservs are reusable infrastructure components that can be deployed across different cloud providers and environments.</p>
|
||
|
|
<h2 id="architecture-overview"><a class="header" href="#architecture-overview">Architecture Overview</a></h2>
|
||
|
|
<h3 id="layered-system"><a class="header" href="#layered-system">Layered System</a></h3>
|
||
|
|
<p>The provisioning system uses a <strong>3-layer architecture</strong> for taskservs:</p>
|
||
|
|
<ol>
|
||
|
|
<li><strong>Layer 1 (Core)</strong>: <code>provisioning/extensions/taskservs/{category}/{name}</code> - Base taskserv definitions</li>
|
||
|
|
<li><strong>Layer 2 (Workspace)</strong>: <code>provisioning/workspace/templates/taskservs/{category}/{name}.k</code> - Template configurations</li>
|
||
|
|
<li><strong>Layer 3 (Infrastructure)</strong>: <code>workspace/infra/{infra}/task-servs/{name}.k</code> - Infrastructure-specific overrides</li>
|
||
|
|
</ol>
|
||
|
|
<h3 id="resolution-order"><a class="header" href="#resolution-order">Resolution Order</a></h3>
|
||
|
|
<p>The system resolves taskservs in this priority order:</p>
|
||
|
|
<ul>
|
||
|
|
<li><strong>Infrastructure layer</strong> (highest priority) - specific to your infrastructure</li>
|
||
|
|
<li><strong>Workspace layer</strong> (medium priority) - templates and patterns</li>
|
||
|
|
<li><strong>Core layer</strong> (lowest priority) - base extensions</li>
|
||
|
|
</ul>
|
||
|
|
<h2 id="taskserv-structure"><a class="header" href="#taskserv-structure">Taskserv Structure</a></h2>
|
||
|
|
<h3 id="standard-directory-layout"><a class="header" href="#standard-directory-layout">Standard Directory Layout</a></h3>
|
||
|
|
<pre><code>provisioning/extensions/taskservs/{category}/{name}/
|
||
|
|
├── kcl/ # KCL configuration
|
||
|
|
│ ├── kcl.mod # Module definition
|
||
|
|
│ ├── {name}.k # Main schema
|
||
|
|
│ ├── version.k # Version information
|
||
|
|
│ └── dependencies.k # Dependencies (optional)
|
||
|
|
├── default/ # Default configurations
|
||
|
|
│ ├── defs.toml # Default values
|
||
|
|
│ └── install-{name}.sh # Installation script
|
||
|
|
├── README.md # Documentation
|
||
|
|
└── info.md # Metadata
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="categories"><a class="header" href="#categories">Categories</a></h3>
|
||
|
|
<p>Taskservs are organized into these categories:</p>
|
||
|
|
<ul>
|
||
|
|
<li><strong>container-runtime</strong>: containerd, crio, crun, podman, runc, youki</li>
|
||
|
|
<li><strong>databases</strong>: postgres, redis</li>
|
||
|
|
<li><strong>development</strong>: coder, desktop, gitea, nushell, oras, radicle</li>
|
||
|
|
<li><strong>infrastructure</strong>: kms, os, provisioning, webhook, kubectl, polkadot</li>
|
||
|
|
<li><strong>kubernetes</strong>: kubernetes (main orchestration)</li>
|
||
|
|
<li><strong>networking</strong>: cilium, coredns, etcd, ip-aliases, proxy, resolv</li>
|
||
|
|
<li><strong>storage</strong>: external-nfs, mayastor, oci-reg, rook-ceph</li>
|
||
|
|
</ul>
|
||
|
|
<h2 id="creating-new-taskservs"><a class="header" href="#creating-new-taskservs">Creating New Taskservs</a></h2>
|
||
|
|
<h3 id="method-1-using-the-extension-creation-tool"><a class="header" href="#method-1-using-the-extension-creation-tool">Method 1: Using the Extension Creation Tool</a></h3>
|
||
|
|
<pre><code class="language-bash"># Create a new taskserv interactively
|
||
|
|
nu provisioning/tools/create-extension.nu interactive
|
||
|
|
|
||
|
|
# Create directly with parameters
|
||
|
|
nu provisioning/tools/create-extension.nu taskserv my-service \
|
||
|
|
--template basic \
|
||
|
|
--author "Your Name" \
|
||
|
|
--description "My service description" \
|
||
|
|
--output provisioning/extensions
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="method-2-manual-creation"><a class="header" href="#method-2-manual-creation">Method 2: Manual Creation</a></h3>
|
||
|
|
<ol>
|
||
|
|
<li><strong>Choose a category</strong> and create the directory structure:</li>
|
||
|
|
</ol>
|
||
|
|
<pre><code class="language-bash">mkdir -p provisioning/extensions/taskservs/{category}/{name}/kcl
|
||
|
|
mkdir -p provisioning/extensions/taskservs/{category}/{name}/default
|
||
|
|
</code></pre>
|
||
|
|
<ol start="2">
|
||
|
|
<li><strong>Create the KCL module definition</strong> (<code>kcl/kcl.mod</code>):</li>
|
||
|
|
</ol>
|
||
|
|
<pre><code class="language-toml">[package]
|
||
|
|
name = "my-service"
|
||
|
|
version = "1.0.0"
|
||
|
|
description = "Service description"
|
||
|
|
|
||
|
|
[dependencies]
|
||
|
|
k8s = { oci = "oci://ghcr.io/kcl-lang/k8s", tag = "1.30" }
|
||
|
|
</code></pre>
|
||
|
|
<ol start="3">
|
||
|
|
<li><strong>Create the main KCL schema</strong> (<code>kcl/my-service.k</code>):</li>
|
||
|
|
</ol>
|
||
|
|
<pre><code class="language-kcl"># My Service Configuration
|
||
|
|
schema MyService {
|
||
|
|
# Service metadata
|
||
|
|
name: str = "my-service"
|
||
|
|
version: str = "latest"
|
||
|
|
namespace: str = "default"
|
||
|
|
|
||
|
|
# Service configuration
|
||
|
|
replicas: int = 1
|
||
|
|
port: int = 8080
|
||
|
|
|
||
|
|
# Resource requirements
|
||
|
|
cpu: str = "100m"
|
||
|
|
memory: str = "128Mi"
|
||
|
|
|
||
|
|
# Additional configuration
|
||
|
|
config?: {str: any} = {}
|
||
|
|
}
|
||
|
|
|
||
|
|
# Default configuration
|
||
|
|
my_service_config: MyService = MyService {
|
||
|
|
name = "my-service"
|
||
|
|
version = "latest"
|
||
|
|
replicas = 1
|
||
|
|
port = 8080
|
||
|
|
}
|
||
|
|
</code></pre>
|
||
|
|
<ol start="4">
|
||
|
|
<li><strong>Create version information</strong> (<code>kcl/version.k</code>):</li>
|
||
|
|
</ol>
|
||
|
|
<pre><code class="language-kcl"># Version information for my-service taskserv
|
||
|
|
schema MyServiceVersion {
|
||
|
|
current: str = "1.0.0"
|
||
|
|
compatible: [str] = ["1.0.0"]
|
||
|
|
deprecated?: [str] = []
|
||
|
|
}
|
||
|
|
|
||
|
|
my_service_version: MyServiceVersion = MyServiceVersion {}
|
||
|
|
</code></pre>
|
||
|
|
<ol start="5">
|
||
|
|
<li><strong>Create default configuration</strong> (<code>default/defs.toml</code>):</li>
|
||
|
|
</ol>
|
||
|
|
<pre><code class="language-toml">[service]
|
||
|
|
name = "my-service"
|
||
|
|
version = "latest"
|
||
|
|
port = 8080
|
||
|
|
|
||
|
|
[deployment]
|
||
|
|
replicas = 1
|
||
|
|
strategy = "RollingUpdate"
|
||
|
|
|
||
|
|
[resources]
|
||
|
|
cpu_request = "100m"
|
||
|
|
cpu_limit = "500m"
|
||
|
|
memory_request = "128Mi"
|
||
|
|
memory_limit = "512Mi"
|
||
|
|
</code></pre>
|
||
|
|
<ol start="6">
|
||
|
|
<li><strong>Create installation script</strong> (<code>default/install-my-service.sh</code>):</li>
|
||
|
|
</ol>
|
||
|
|
<pre><code class="language-bash">#!/bin/bash
|
||
|
|
set -euo pipefail
|
||
|
|
|
||
|
|
# My Service Installation Script
|
||
|
|
echo "Installing my-service..."
|
||
|
|
|
||
|
|
# Configuration
|
||
|
|
SERVICE_NAME="${SERVICE_NAME:-my-service}"
|
||
|
|
SERVICE_VERSION="${SERVICE_VERSION:-latest}"
|
||
|
|
NAMESPACE="${NAMESPACE:-default}"
|
||
|
|
|
||
|
|
# Install service
|
||
|
|
kubectl create namespace "${NAMESPACE}" --dry-run=client -o yaml | kubectl apply -f -
|
||
|
|
|
||
|
|
# Apply configuration
|
||
|
|
envsubst < my-service-deployment.yaml | kubectl apply -f -
|
||
|
|
|
||
|
|
echo "✅ my-service installed successfully"
|
||
|
|
</code></pre>
|
||
|
|
<h2 id="working-with-templates"><a class="header" href="#working-with-templates">Working with Templates</a></h2>
|
||
|
|
<h3 id="creating-workspace-templates"><a class="header" href="#creating-workspace-templates">Creating Workspace Templates</a></h3>
|
||
|
|
<p>Templates provide reusable configurations that can be customized per infrastructure:</p>
|
||
|
|
<pre><code class="language-bash"># Create template directory
|
||
|
|
mkdir -p provisioning/workspace/templates/taskservs/{category}
|
||
|
|
|
||
|
|
# Create template file
|
||
|
|
cat > provisioning/workspace/templates/taskservs/{category}/{name}.k << 'EOF'
|
||
|
|
# Template for {name} taskserv
|
||
|
|
import taskservs.{category}.{name}.kcl.{name} as base
|
||
|
|
|
||
|
|
# Template configuration extending base
|
||
|
|
{name}_template: base.{Name} = base.{name}_config {
|
||
|
|
# Template customizations
|
||
|
|
version = "stable"
|
||
|
|
replicas = 2 # Production default
|
||
|
|
|
||
|
|
# Environment-specific overrides will be applied at infrastructure layer
|
||
|
|
}
|
||
|
|
EOF
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="infrastructure-overrides"><a class="header" href="#infrastructure-overrides">Infrastructure Overrides</a></h3>
|
||
|
|
<p>Create infrastructure-specific configurations:</p>
|
||
|
|
<pre><code class="language-bash"># Create infrastructure override
|
||
|
|
mkdir -p workspace/infra/{your-infra}/task-servs
|
||
|
|
|
||
|
|
cat > workspace/infra/{your-infra}/task-servs/{name}.k << 'EOF'
|
||
|
|
# Infrastructure-specific configuration for {name}
|
||
|
|
import provisioning.workspace.templates.taskservs.{category}.{name} as template
|
||
|
|
|
||
|
|
# Infrastructure customizations
|
||
|
|
{name}_config: template.{name}_template {
|
||
|
|
# Override for this specific infrastructure
|
||
|
|
version = "1.2.3" # Pin to specific version
|
||
|
|
replicas = 3 # Scale for this environment
|
||
|
|
|
||
|
|
# Infrastructure-specific settings
|
||
|
|
resources = {
|
||
|
|
cpu = "200m"
|
||
|
|
memory = "256Mi"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
EOF
|
||
|
|
</code></pre>
|
||
|
|
<h2 id="cli-commands"><a class="header" href="#cli-commands">CLI Commands</a></h2>
|
||
|
|
<h3 id="taskserv-management"><a class="header" href="#taskserv-management">Taskserv Management</a></h3>
|
||
|
|
<pre><code class="language-bash"># Create taskserv (deploy to infrastructure)
|
||
|
|
provisioning/core/cli/provisioning taskserv create {name} --infra {infra-name} --check
|
||
|
|
|
||
|
|
# Generate taskserv configuration
|
||
|
|
provisioning/core/cli/provisioning taskserv generate {name} --infra {infra-name}
|
||
|
|
|
||
|
|
# Delete taskserv
|
||
|
|
provisioning/core/cli/provisioning taskserv delete {name} --infra {infra-name} --check
|
||
|
|
|
||
|
|
# List available taskservs
|
||
|
|
nu -c "use provisioning/core/nulib/taskservs/discover.nu *; discover-taskservs"
|
||
|
|
|
||
|
|
# Check taskserv versions
|
||
|
|
provisioning/core/cli/provisioning taskserv versions {name}
|
||
|
|
provisioning/core/cli/provisioning taskserv check-updates {name}
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="discovery-and-testing"><a class="header" href="#discovery-and-testing">Discovery and Testing</a></h3>
|
||
|
|
<pre><code class="language-bash"># Test layer resolution for a taskserv
|
||
|
|
nu -c "use provisioning/workspace/tools/layer-utils.nu *; test_layer_resolution {name} {infra} {provider}"
|
||
|
|
|
||
|
|
# Show layer statistics
|
||
|
|
nu -c "use provisioning/workspace/tools/layer-utils.nu *; show_layer_stats"
|
||
|
|
|
||
|
|
# Get taskserv information
|
||
|
|
nu -c "use provisioning/core/nulib/taskservs/discover.nu *; get-taskserv-info {name}"
|
||
|
|
|
||
|
|
# Search taskservs
|
||
|
|
nu -c "use provisioning/core/nulib/taskservs/discover.nu *; search-taskservs {query}"
|
||
|
|
</code></pre>
|
||
|
|
<h2 id="best-practices"><a class="header" href="#best-practices">Best Practices</a></h2>
|
||
|
|
<h3 id="1-naming-conventions"><a class="header" href="#1-naming-conventions">1. Naming Conventions</a></h3>
|
||
|
|
<ul>
|
||
|
|
<li>Use <strong>kebab-case</strong> for taskserv names: <code>my-service</code>, <code>data-processor</code></li>
|
||
|
|
<li>Use descriptive names that indicate the service purpose</li>
|
||
|
|
<li>Avoid generic names like <code>service</code>, <code>app</code>, <code>tool</code></li>
|
||
|
|
</ul>
|
||
|
|
<h3 id="2-configuration-design"><a class="header" href="#2-configuration-design">2. Configuration Design</a></h3>
|
||
|
|
<ul>
|
||
|
|
<li>Define sensible <strong>defaults</strong> in the base schema</li>
|
||
|
|
<li>Make configurations <strong>parameterizable</strong> through variables</li>
|
||
|
|
<li>Support <strong>multi-environment</strong> deployment (dev, test, prod)</li>
|
||
|
|
<li>Include <strong>resource limits</strong> and requests</li>
|
||
|
|
</ul>
|
||
|
|
<h3 id="3-dependencies"><a class="header" href="#3-dependencies">3. Dependencies</a></h3>
|
||
|
|
<ul>
|
||
|
|
<li>Declare all <strong>dependencies</strong> explicitly in <code>kcl.mod</code></li>
|
||
|
|
<li>Use <strong>version constraints</strong> to ensure compatibility</li>
|
||
|
|
<li>Consider <strong>dependency order</strong> for installation</li>
|
||
|
|
</ul>
|
||
|
|
<h3 id="4-documentation"><a class="header" href="#4-documentation">4. Documentation</a></h3>
|
||
|
|
<ul>
|
||
|
|
<li>Provide comprehensive <strong>README.md</strong> with usage examples</li>
|
||
|
|
<li>Document all <strong>configuration options</strong></li>
|
||
|
|
<li>Include <strong>troubleshooting</strong> sections</li>
|
||
|
|
<li>Add <strong>version compatibility</strong> information</li>
|
||
|
|
</ul>
|
||
|
|
<h3 id="5-testing"><a class="header" href="#5-testing">5. Testing</a></h3>
|
||
|
|
<ul>
|
||
|
|
<li>Test taskservs across different <strong>providers</strong> (AWS, UpCloud, local)</li>
|
||
|
|
<li>Validate with <code>--check</code> flag before deployment</li>
|
||
|
|
<li>Test <strong>layer resolution</strong> to ensure proper override behavior</li>
|
||
|
|
<li>Verify <strong>dependency resolution</strong> works correctly</li>
|
||
|
|
</ul>
|
||
|
|
<h2 id="troubleshooting"><a class="header" href="#troubleshooting">Troubleshooting</a></h2>
|
||
|
|
<h3 id="common-issues"><a class="header" href="#common-issues">Common Issues</a></h3>
|
||
|
|
<ol>
|
||
|
|
<li>
|
||
|
|
<p><strong>Taskserv not discovered</strong></p>
|
||
|
|
<ul>
|
||
|
|
<li>Ensure <code>kcl/kcl.mod</code> exists and is valid TOML</li>
|
||
|
|
<li>Check directory structure matches expected layout</li>
|
||
|
|
<li>Verify taskserv is in correct category folder</li>
|
||
|
|
</ul>
|
||
|
|
</li>
|
||
|
|
<li>
|
||
|
|
<p><strong>Layer resolution not working</strong></p>
|
||
|
|
<ul>
|
||
|
|
<li>Use <code>test_layer_resolution</code> tool to debug</li>
|
||
|
|
<li>Check file paths and naming conventions</li>
|
||
|
|
<li>Verify import statements in KCL files</li>
|
||
|
|
</ul>
|
||
|
|
</li>
|
||
|
|
<li>
|
||
|
|
<p><strong>Dependency resolution errors</strong></p>
|
||
|
|
<ul>
|
||
|
|
<li>Check <code>kcl.mod</code> dependencies section</li>
|
||
|
|
<li>Ensure dependency versions are compatible</li>
|
||
|
|
<li>Verify dependency taskservs exist and are discoverable</li>
|
||
|
|
</ul>
|
||
|
|
</li>
|
||
|
|
<li>
|
||
|
|
<p><strong>Configuration validation failures</strong></p>
|
||
|
|
<ul>
|
||
|
|
<li>Use <code>kcl check</code> to validate KCL syntax</li>
|
||
|
|
<li>Check for missing required fields</li>
|
||
|
|
<li>Verify data types match schema definitions</li>
|
||
|
|
</ul>
|
||
|
|
</li>
|
||
|
|
</ol>
|
||
|
|
<h3 id="debug-commands"><a class="header" href="#debug-commands">Debug Commands</a></h3>
|
||
|
|
<pre><code class="language-bash"># Enable debug mode for taskserv operations
|
||
|
|
provisioning/core/cli/provisioning taskserv create {name} --debug --check
|
||
|
|
|
||
|
|
# Check KCL syntax
|
||
|
|
kcl check provisioning/extensions/taskservs/{category}/{name}/kcl/{name}.k
|
||
|
|
|
||
|
|
# Validate taskserv structure
|
||
|
|
nu provisioning/tools/create-extension.nu validate provisioning/extensions/taskservs/{category}/{name}
|
||
|
|
|
||
|
|
# Show detailed discovery information
|
||
|
|
nu -c "use provisioning/core/nulib/taskservs/discover.nu *; discover-taskservs | where name == '{name}'"
|
||
|
|
</code></pre>
|
||
|
|
<h2 id="contributing"><a class="header" href="#contributing">Contributing</a></h2>
|
||
|
|
<h3 id="pull-request-guidelines"><a class="header" href="#pull-request-guidelines">Pull Request Guidelines</a></h3>
|
||
|
|
<ol>
|
||
|
|
<li>Follow the <strong>standard directory structure</strong></li>
|
||
|
|
<li>Include comprehensive <strong>documentation</strong></li>
|
||
|
|
<li>Add <strong>tests</strong> and validation</li>
|
||
|
|
<li>Update <strong>category documentation</strong> if adding new categories</li>
|
||
|
|
<li>Ensure <strong>backward compatibility</strong></li>
|
||
|
|
</ol>
|
||
|
|
<h3 id="review-checklist"><a class="header" href="#review-checklist">Review Checklist</a></h3>
|
||
|
|
<ul>
|
||
|
|
<li><input disabled="" type="checkbox"/>
|
||
|
|
Proper directory structure and naming</li>
|
||
|
|
<li><input disabled="" type="checkbox"/>
|
||
|
|
Valid KCL schemas with appropriate types</li>
|
||
|
|
<li><input disabled="" type="checkbox"/>
|
||
|
|
Comprehensive README documentation</li>
|
||
|
|
<li><input disabled="" type="checkbox"/>
|
||
|
|
Working installation scripts</li>
|
||
|
|
<li><input disabled="" type="checkbox"/>
|
||
|
|
Proper dependency declarations</li>
|
||
|
|
<li><input disabled="" type="checkbox"/>
|
||
|
|
Template configurations (if applicable)</li>
|
||
|
|
<li><input disabled="" type="checkbox"/>
|
||
|
|
Layer resolution testing</li>
|
||
|
|
</ul>
|
||
|
|
<h2 id="advanced-topics"><a class="header" href="#advanced-topics">Advanced Topics</a></h2>
|
||
|
|
<h3 id="custom-categories"><a class="header" href="#custom-categories">Custom Categories</a></h3>
|
||
|
|
<p>To add new taskserv categories:</p>
|
||
|
|
<ol>
|
||
|
|
<li>Create the category directory structure</li>
|
||
|
|
<li>Update the discovery system if needed</li>
|
||
|
|
<li>Add category documentation</li>
|
||
|
|
<li>Create initial taskservs for the category</li>
|
||
|
|
<li>Add category templates if applicable</li>
|
||
|
|
</ol>
|
||
|
|
<h3 id="cross-provider-compatibility"><a class="header" href="#cross-provider-compatibility">Cross-Provider Compatibility</a></h3>
|
||
|
|
<p>Design taskservs to work across multiple providers:</p>
|
||
|
|
<pre><code class="language-kcl">schema MyService {
|
||
|
|
# Provider-agnostic configuration
|
||
|
|
name: str
|
||
|
|
version: str
|
||
|
|
|
||
|
|
# Provider-specific sections
|
||
|
|
aws?: AWSConfig
|
||
|
|
upcloud?: UpCloudConfig
|
||
|
|
local?: LocalConfig
|
||
|
|
}
|
||
|
|
</code></pre>
|
||
|
|
<h3 id="advanced-dependencies"><a class="header" href="#advanced-dependencies">Advanced Dependencies</a></h3>
|
||
|
|
<p>Handle complex dependency scenarios:</p>
|
||
|
|
<pre><code class="language-kcl"># Conditional dependencies
|
||
|
|
schema MyService {
|
||
|
|
database_type: "postgres" | "mysql" | "redis"
|
||
|
|
|
||
|
|
# Dependencies based on configuration
|
||
|
|
if database_type == "postgres":
|
||
|
|
postgres_config: PostgresConfig
|
||
|
|
elif database_type == "redis":
|
||
|
|
redis_config: RedisConfig
|
||
|
|
}
|
||
|
|
</code></pre>
|
||
|
|
<hr />
|
||
|
|
<p>This guide provides comprehensive coverage of taskserv development. For specific examples, see the existing taskservs in <code>provisioning/extensions/taskservs/</code> and their corresponding templates in <code>provisioning/workspace/templates/taskservs/</code>.</p>
|
||
|
|
|
||
|
|
</main>
|
||
|
|
|
||
|
|
<nav class="nav-wrapper" aria-label="Page navigation">
|
||
|
|
<!-- Mobile navigation buttons -->
|
||
|
|
<a rel="prev" href="../development/QUICK_PROVIDER_GUIDE.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
||
|
|
<i class="fa fa-angle-left"></i>
|
||
|
|
</a>
|
||
|
|
|
||
|
|
<a rel="next prefetch" href="../development/TASKSERV_QUICK_GUIDE.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
||
|
|
<i class="fa fa-angle-right"></i>
|
||
|
|
</a>
|
||
|
|
|
||
|
|
<div style="clear: both"></div>
|
||
|
|
</nav>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<nav class="nav-wide-wrapper" aria-label="Page navigation">
|
||
|
|
<a rel="prev" href="../development/QUICK_PROVIDER_GUIDE.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
||
|
|
<i class="fa fa-angle-left"></i>
|
||
|
|
</a>
|
||
|
|
|
||
|
|
<a rel="next prefetch" href="../development/TASKSERV_QUICK_GUIDE.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
||
|
|
<i class="fa fa-angle-right"></i>
|
||
|
|
</a>
|
||
|
|
</nav>
|
||
|
|
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Livereload script (if served using the cli tool) -->
|
||
|
|
<script>
|
||
|
|
const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||
|
|
const wsAddress = wsProtocol + "//" + location.host + "/" + "__livereload";
|
||
|
|
const socket = new WebSocket(wsAddress);
|
||
|
|
socket.onmessage = function (event) {
|
||
|
|
if (event.data === "reload") {
|
||
|
|
socket.close();
|
||
|
|
location.reload();
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
window.onbeforeunload = function() {
|
||
|
|
socket.close();
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
<script>
|
||
|
|
window.playground_copyable = true;
|
||
|
|
</script>
|
||
|
|
|
||
|
|
|
||
|
|
<script src="../elasticlunr.min.js"></script>
|
||
|
|
<script src="../mark.min.js"></script>
|
||
|
|
<script src="../searcher.js"></script>
|
||
|
|
|
||
|
|
<script src="../clipboard.min.js"></script>
|
||
|
|
<script src="../highlight.js"></script>
|
||
|
|
<script src="../book.js"></script>
|
||
|
|
|
||
|
|
<!-- Custom JS scripts -->
|
||
|
|
|
||
|
|
|
||
|
|
</div>
|
||
|
|
</body>
|
||
|
|
</html>
|