# First Deployment\n\nThis guide walks you through deploying your first infrastructure using the Provisioning Platform.\n\n## Overview\n\nIn this chapter, you'll:\n\n1. Configure a simple infrastructure\n2. Create your first server\n3. Install a task service (Kubernetes)\n4. Verify the deployment\n\nEstimated time: 10-15 minutes\n\n## Step 1: Configure Infrastructure\n\nCreate a basic infrastructure configuration:\n\n```\n# Generate infrastructure template\nprovisioning generate infra --new my-infra\n\n# This creates: workspace/infra/my-infra/\n# - config.toml (infrastructure settings)\n# - settings.ncl (Nickel configuration)\n```\n\n## Step 2: Edit Configuration\n\nEdit the generated configuration:\n\n```\n# Edit with your preferred editor\n$EDITOR workspace/infra/my-infra/settings.ncl\n```\n\nExample configuration:\n\n```\nimport provisioning.settings as cfg\n\n# Infrastructure settings\ninfra_settings = cfg.InfraSettings {\n    name = "my-infra"\n    provider = "local"  # Start with local provider\n    environment = "development"\n}\n\n# Server configuration\nservers = [\n    {\n        hostname = "dev-server-01"\n        cores = 2\n        memory = 4096  # MB\n        disk = 50  # GB\n    }\n]\n```\n\n## Step 3: Create Server (Check Mode)\n\nFirst, run in check mode to see what would happen:\n\n```\n# Check mode - no actual changes\nprovisioning server create --infra my-infra --check\n\n# Expected output:\n# ✓ Validation passed\n# ⚠ Check mode: No changes will be made\n# \n# Would create:\n# - Server: dev-server-01 (2 cores, 4 GB RAM, 50 GB disk)\n```\n\n## Step 4: Create Server (Real)\n\nIf check mode looks good, create the server:\n\n```\n# Create server\nprovisioning server create --infra my-infra\n\n# Expected output:\n# ✓ Creating server: dev-server-01\n# ✓ Server created successfully\n# ✓ IP Address: 192.168.1.100\n# ✓ SSH access: ssh user@192.168.1.100\n```\n\n## Step 5: Verify Server\n\nCheck server status:\n\n```\n# List all servers\nprovisioning server list\n\n# Get detailed server info\nprovisioning server info dev-server-01\n\n# SSH to server (optional)\nprovisioning server ssh dev-server-01\n```\n\n## Step 6: Install Kubernetes (Check Mode)\n\nInstall a task service on the server:\n\n```\n# Check mode first\nprovisioning taskserv create kubernetes --infra my-infra --check\n\n# Expected output:\n# ✓ Validation passed\n# ⚠ Check mode: No changes will be made\n#\n# Would install:\n# - Kubernetes v1.28.0\n# - Required dependencies: containerd, etcd\n# - On servers: dev-server-01\n```\n\n## Step 7: Install Kubernetes (Real)\n\nProceed with installation:\n\n```\n# Install Kubernetes\nprovisioning taskserv create kubernetes --infra my-infra --wait\n\n# This will:\n# 1. Check dependencies\n# 2. Install containerd\n# 3. Install etcd\n# 4. Install Kubernetes\n# 5. Configure and start services\n\n# Monitor progress\nprovisioning workflow monitor <task-id>\n```\n\n## Step 8: Verify Installation\n\nCheck that Kubernetes is running:\n\n```\n# List installed task services\nprovisioning taskserv list --infra my-infra\n\n# Check Kubernetes status\nprovisioning server ssh dev-server-01\nkubectl get nodes  # On the server\nexit\n\n# Or remotely\nprovisioning server exec dev-server-01 -- kubectl get nodes\n```\n\n## Common Deployment Patterns\n\n### Pattern 1: Multiple Servers\n\nCreate multiple servers at once:\n\n```\nservers = [\n    {hostname = "web-01", cores = 2, memory = 4096},\n    {hostname = "web-02", cores = 2, memory = 4096},\n    {hostname = "db-01", cores = 4, memory = 8192}\n]\n```\n\n```\nprovisioning server create --infra my-infra --servers web-01,web-02,db-01\n```\n\n### Pattern 2: Server with Multiple Task Services\n\nInstall multiple services on one server:\n\n```\nprovisioning taskserv create kubernetes,cilium,postgres --infra my-infra --servers web-01\n```\n\n### Pattern 3: Complete Cluster\n\nDeploy a complete cluster configuration:\n\n```\nprovisioning cluster create buildkit --infra my-infra\n```\n\n## Deployment Workflow\n\nThe typical deployment workflow:\n\n```\n# 1. Initialize workspace\nprovisioning workspace init production\n\n# 2. Generate infrastructure\nprovisioning generate infra --new prod-infra\n\n# 3. Configure (edit settings.ncl)\n$EDITOR workspace/infra/prod-infra/settings.ncl\n\n# 4. Validate configuration\nprovisioning validate config --infra prod-infra\n\n# 5. Create servers (check mode)\nprovisioning server create --infra prod-infra --check\n\n# 6. Create servers (real)\nprovisioning server create --infra prod-infra\n\n# 7. Install task services\nprovisioning taskserv create kubernetes --infra prod-infra --wait\n\n# 8. Deploy cluster (if needed)\nprovisioning cluster create my-cluster --infra prod-infra\n\n# 9. Verify\nprovisioning server list\nprovisioning taskserv list\n```\n\n## Troubleshooting\n\n### Server Creation Fails\n\n```\n# Check logs\nprovisioning server logs dev-server-01\n\n# Try with debug mode\nprovisioning --debug server create --infra my-infra\n```\n\n### Task Service Installation Fails\n\n```\n# Check task service logs\nprovisioning taskserv logs kubernetes\n\n# Retry installation\nprovisioning taskserv create kubernetes --infra my-infra --force\n```\n\n### SSH Connection Issues\n\n```\n# Verify SSH key\nls -la ~/.ssh/\n\n# Test SSH manually\nssh -v user@<server-ip>\n\n# Use provisioning SSH helper\nprovisioning server ssh dev-server-01 --debug\n```\n\n## Next Steps\n\nNow that you've completed your first deployment:\n→ **[Verification](04-verification.md)** - Verify your deployment is working correctly\n\n## Additional Resources\n\n- [Complete Deployment Guide](../guides/from-scratch.md)\n- [Infrastructure Management](../user/infrastructure-management.md)\n- [Troubleshooting Guide](../user/troubleshooting-guide.md)
