3.0 KiB
3.0 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Overview
This is a Terraform module for managing vSphere resource pools (resource groups). It creates organized resource pools with CPU and memory resource allocation controls, along with proper tagging for management and organization. The module integrates with vSphere for virtualization and Vault for secrets management.
Commands
Terraform Operations
terraform init- Initialize the Terraform working directoryterraform plan- Create execution plan showing changesterraform apply- Apply the planned changesterraform destroy- Destroy the managed infrastructureterraform validate- Validate configuration syntaxterraform fmt- Format configuration files
Development Workflow
- Always run
terraform validateandterraform planbefore applying changes - Use
terraform.tfvarsfile for environment-specific variable values - Secrets are managed through Vault - never hardcode sensitive values
Architecture
Core Components
Resource Pool Management:
- Creates resource pools (
vsphere_resource_pool) under the compute cluster's default resource pool - Configurable CPU and memory reservations, limits, expandability, and shares
- Default resource groups: Kubernetes, Docker, and Infra
Tagging System:
- Creates tag categories for Environment and ResourceGroupType
- Applies environment and resource group type tags to each resource pool
- Enables proper organization and filtering in vSphere
Data Sources:
- Retrieves vSphere credentials from Vault
- Looks up vSphere datacenter information
- References compute cluster "Home" for resource pool parent
Variable Structure
Key Variables:
datacenter: vSphere datacenter nameenvironment: Environment name (dev, tst, acc, uat, prod, shared, tools)resource_groups: Map of resource groups with CPU/memory configurationrole_id/secret_id: Vault AppRole authentication (sensitive)
Resource Group Configuration: Each resource group supports:
name: Display name for the resource poolcpu_reservation: Guaranteed CPU in MHz (default: 0)cpu_expandable: Allow CPU expansion beyond reservation (default: true)cpu_limit: Maximum CPU in MHz (default: -1, unlimited)cpu_shares: CPU priority (normal, low, high) (default: normal)memory_reservation: Guaranteed memory in MB (default: 0)memory_expandable: Allow memory expansion beyond reservation (default: true)memory_limit: Maximum memory in MB (default: -1, unlimited)memory_shares: Memory priority (normal, low, high) (default: normal)
Resource Dependencies
Resources are created in the following order:
- Tag categories for Environment and ResourceGroupType
- Environment and resource group type tags
- Resource pools with proper tagging
Backend Configuration
Uses S3-compatible backend (MinIO) for state storage with custom endpoint configuration. State file: home/vsphere/network/vsphere-resourcegroup-config.tfstate