Skip to content

Commit 9e3058e

Browse files
committed
updating code with claude's latest changes
1 parent 3240f87 commit 9e3058e

9 files changed

+391
-1094
lines changed

docs/notebooks/azure_cloud_tutorial.ipynb

Lines changed: 14 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -642,87 +642,16 @@
642642
},
643643
{
644644
"cell_type": "code",
645-
"execution_count": null,
646645
"id": "azure-security-setup",
647646
"metadata": {},
648647
"outputs": [],
649-
"source": [
650-
"def setup_azure_security():\n",
651-
" \"\"\"\n",
652-
" Security configuration templates for Azure resources.\n",
653-
" \"\"\"\n",
654-
" \n",
655-
" security_commands = \"\"\"\n",
656-
"# Create Network Security Group with restrictive rules\n",
657-
"az network nsg create \\\n",
658-
" --name clustrix-nsg \\\n",
659-
" --resource-group clustrix-tutorial-rg\n",
660-
"\n",
661-
"# Allow SSH only from your IP\n",
662-
"az network nsg rule create \\\n",
663-
" --name SSH \\\n",
664-
" --nsg-name clustrix-nsg \\\n",
665-
" --resource-group clustrix-tutorial-rg \\\n",
666-
" --priority 1000 \\\n",
667-
" --source-address-prefixes YOUR_IP/32 \\\n",
668-
" --source-port-ranges '*' \\\n",
669-
" --destination-address-prefixes '*' \\\n",
670-
" --destination-port-ranges 22 \\\n",
671-
" --access Allow \\\n",
672-
" --protocol Tcp\n",
673-
"\n",
674-
"# Create Key Vault for secrets\n",
675-
"az keyvault create \\\n",
676-
" --name clustrix-keyvault-$(date +%s) \\\n",
677-
" --resource-group clustrix-tutorial-rg \\\n",
678-
" --location eastus \\\n",
679-
" --enable-disk-encryption\n",
680-
"\n",
681-
"# Enable managed identity for VMs\n",
682-
"az vm identity assign \\\n",
683-
" --name clustrix-vm-01 \\\n",
684-
" --resource-group clustrix-tutorial-rg\n",
685-
"\n",
686-
"# Setup private endpoint for storage\n",
687-
"az storage account update \\\n",
688-
" --name clustrixstorage \\\n",
689-
" --resource-group clustrix-tutorial-rg \\\n",
690-
" --default-action Deny\n",
691-
"\"\"\"\n",
692-
" \n",
693-
" security_checklist = \"\"\"\n",
694-
"Azure Security Checklist for Clustrix:\n",
695-
"\n",
696-
"✓ Use Azure Active Directory for authentication\n",
697-
"✓ Enable managed identities instead of service principals when possible\n",
698-
"✓ Restrict Network Security Groups to your IP address only\n",
699-
"✓ Use private endpoints for storage accounts\n",
700-
"✓ Enable disk encryption for all VMs\n",
701-
"✓ Use Azure Key Vault for secrets and certificates\n",
702-
"✓ Enable Azure Security Center recommendations\n",
703-
"✓ Use Azure Private Link for service connectivity\n",
704-
"✓ Enable diagnostic logging and monitoring\n",
705-
"✓ Implement Azure Policy for compliance\n",
706-
"✓ Use Azure Defender for cloud workload protection\n",
707-
"✓ Regularly rotate access keys and certificates\n",
708-
"✓ Set up cost alerts and spending limits\n",
709-
"✓ Tag all resources for governance and cost tracking\n",
710-
"\"\"\"\n",
711-
" \n",
712-
" print(\"Azure Security Setup Commands:\")\n",
713-
" print(security_commands)\n",
714-
" print(\"\\nSecurity Checklist:\")\n",
715-
" print(security_checklist)\n",
716-
" \n",
717-
" return {\n",
718-
" 'nsg_name': 'clustrix-nsg',\n",
719-
" 'keyvault_name': 'clustrix-keyvault',\n",
720-
" 'security_commands': security_commands\n",
721-
" }\n",
722-
"\n",
723-
"security_config = setup_azure_security()\n",
724-
"print(\"Security configuration templates generated.\")"
725-
]
648+
"source": "def setup_azure_security_for_clustrix(project_id):\n \"\"\"\n Security configuration for Azure + Clustrix deployment.\n \"\"\"\n \n security_commands = f\"\"\"\n# Create VPC with private subnets\ngcloud compute networks create clustrix-vpc \\\n --project {project_id} \\\n --subnet-mode custom\n\ngcloud compute networks subnets create clustrix-subnet \\\n --project {project_id} \\\n --network clustrix-vpc \\\n --range 10.1.0.0/24 \\\n --region us-central1 \\\n --enable-private-ip-google-access\n\n# Create firewall rules (restrictive)\ngcloud compute firewall-rules create clustrix-allow-ssh \\\n --project {project_id} \\\n --network clustrix-vpc \\\n --allow tcp:22 \\\n --source-ranges YOUR_IP/32 \\\n --target-tags clustrix\n\ngcloud compute firewall-rules create clustrix-internal \\\n --project {project_id} \\\n --network clustrix-vpc \\\n --allow tcp,udp,icmp \\\n --source-ranges 10.1.0.0/24 \\\n --target-tags clustrix\n\n# Create service account with minimal permissions\ngcloud iam service-accounts create clustrix-compute \\\n --project {project_id} \\\n --description=\"Service account for Clustrix compute instances\" \\\n --display-name=\"Clustrix Compute Service Account\"\n\n# Grant only necessary permissions\ngcloud projects add-iam-policy-binding {project_id} \\\n --member=\"serviceAccount:clustrix-compute@{project_id}.iam.gserviceaccount.com\" \\\n --role=\"roles/storage.objectAdmin\"\n\ngcloud projects add-iam-policy-binding {project_id} \\\n --member=\"serviceAccount:clustrix-compute@{project_id}.iam.gserviceaccount.com\" \\\n --role=\"roles/logging.logWriter\"\n\n# Enable OS Login for better SSH key management\ngcloud compute project-info add-metadata \\\n --project {project_id} \\\n --metadata enable-oslogin=TRUE\n\n# Create Cloud KMS key for encryption\ngcloud kms keyrings create clustrix-keyring \\\n --project {project_id} \\\n --location global\n\ngcloud kms keys create clustrix-key \\\n --project {project_id} \\\n --keyring clustrix-keyring \\\n --location global \\\n --purpose encryption\n\"\"\"\n \n print(\"Azure Security Setup Commands:\")\n print(security_commands)\n \n return {\n 'project_id': project_id,\n 'vpc_name': 'clustrix-vpc',\n 'subnet_name': 'clustrix-subnet',\n 'service_account': f'clustrix-compute@{project_id}.iam.gserviceaccount.com',\n 'security_commands': security_commands\n }\n\nsecurity_config = setup_azure_security_for_clustrix('your-project-id')\nprint(\"Security configuration templates generated.\")"
649+
},
650+
{
651+
"cell_type": "markdown",
652+
"id": "8jwgahv9skt",
653+
"source": "### Azure Security Checklist for Clustrix\n\n✓ **Authentication and Access**\n- Use Azure Active Directory for authentication\n- Enable managed identities instead of service principals when possible\n- Restrict Network Security Groups to your IP address only\n- Use private endpoints for storage accounts\n\n✓ **Infrastructure Security**\n- Enable disk encryption for all VMs\n- Use Azure Key Vault for secrets and certificates\n- Enable Azure Security Center recommendations\n- Use Azure Private Link for service connectivity\n\n✓ **Monitoring and Compliance**\n- Enable diagnostic logging and monitoring\n- Implement Azure Policy for compliance\n- Use Azure Defender for cloud workload protection\n- Regularly rotate access keys and certificates\n\n✓ **Cost and Resource Management**\n- Set up cost alerts and spending limits\n- Tag all resources for governance and cost tracking",
654+
"metadata": {}
726655
},
727656
{
728657
"cell_type": "markdown",
@@ -734,103 +663,16 @@
734663
},
735664
{
736665
"cell_type": "code",
737-
"execution_count": null,
738666
"id": "azure-cost-optimization",
739667
"metadata": {},
740668
"outputs": [],
741-
"source": [
742-
"def azure_cost_optimization_guide():\n",
743-
" \"\"\"\n",
744-
" Cost optimization strategies for Azure + Clustrix.\n",
745-
" \"\"\"\n",
746-
" \n",
747-
" cost_tips = \"\"\"\n",
748-
"Azure Cost Optimization for Clustrix:\n",
749-
"\n",
750-
"1. Compute Optimization:\n",
751-
" - Use Azure Spot VMs for non-critical workloads (up to 90% savings)\n",
752-
" - Choose B-series burstable VMs for variable workloads\n",
753-
" - Use reserved instances for predictable workloads (1-3 year terms)\n",
754-
" - Enable auto-shutdown for dev/test VMs\n",
755-
" - Right-size VMs based on actual usage\n",
756-
"\n",
757-
"2. Storage Optimization:\n",
758-
" - Use appropriate storage tiers (Hot, Cool, Archive)\n",
759-
" - Enable lifecycle management for blob storage\n",
760-
" - Use managed disks with appropriate performance tiers\n",
761-
" - Implement data deduplication and compression\n",
762-
"\n",
763-
"3. Network Optimization:\n",
764-
" - Minimize data transfer between regions\n",
765-
" - Use Azure CDN for static content\n",
766-
" - Optimize data transfer patterns\n",
767-
"\n",
768-
"4. Monitoring and Management:\n",
769-
" - Set up budget alerts and spending limits\n",
770-
" - Use Azure Cost Management + Billing\n",
771-
" - Implement proper resource tagging\n",
772-
" - Regular cost reviews and optimizations\n",
773-
"\n",
774-
"5. Service-Specific:\n",
775-
" - Use Azure Functions for small, event-driven tasks\n",
776-
" - Consider Azure Container Instances for short-running jobs\n",
777-
" - Use Azure Batch for large-scale parallel processing\n",
778-
"\"\"\"\n",
779-
" \n",
780-
" cost_monitoring_commands = \"\"\"\n",
781-
"# Set up budget alerts\n",
782-
"az consumption budget create \\\n",
783-
" --budget-name clustrix-monthly-budget \\\n",
784-
" --amount 100 \\\n",
785-
" --time-grain Monthly \\\n",
786-
" --time-period-start 2025-01-01 \\\n",
787-
" --time-period-end 2025-12-31\n",
788-
"\n",
789-
"# Get current costs\n",
790-
"az consumption usage list \\\n",
791-
" --start-date 2025-01-01 \\\n",
792-
" --end-date 2025-01-31\n",
793-
"\n",
794-
"# List resource costs\n",
795-
"az costmanagement query \\\n",
796-
" --type Usage \\\n",
797-
" --dataset-aggregation '{\"totalCost\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"}}' \\\n",
798-
" --dataset-grouping name=ResourceGroup type=Dimension\n",
799-
"\"\"\"\n",
800-
" \n",
801-
" print(cost_tips)\n",
802-
" print(\"\\nCost Monitoring Commands:\")\n",
803-
" print(cost_monitoring_commands)\n",
804-
" \n",
805-
" return {\n",
806-
" 'recommendations': [\n",
807-
" 'Use Spot VMs for batch processing',\n",
808-
" 'Enable auto-shutdown for dev resources',\n",
809-
" 'Implement lifecycle policies for storage',\n",
810-
" 'Set up budget alerts',\n",
811-
" 'Regular cost reviews'\n",
812-
" ]\n",
813-
" }\n",
814-
"\n",
815-
"# Example Spot VM configuration for cost savings\n",
816-
"def configure_spot_vm():\n",
817-
" \"\"\"Example configuration for using Azure Spot VMs.\"\"\"\n",
818-
" configure(\n",
819-
" cluster_type=\"ssh\",\n",
820-
" cluster_host=\"your-spot-vm-ip\",\n",
821-
" username=\"azureuser\",\n",
822-
" key_file=\"~/.ssh/id_rsa\",\n",
823-
" remote_work_dir=\"/tmp/clustrix\",\n",
824-
" # Spot VMs can be evicted, so use shorter timeouts\n",
825-
" default_time=\"00:30:00\",\n",
826-
" job_poll_interval=60, # Check more frequently\n",
827-
" cleanup_on_success=True # Clean up quickly\n",
828-
" )\n",
829-
" print(\"Configured for Azure Spot VMs with appropriate timeouts.\")\n",
830-
"\n",
831-
"cost_guide = azure_cost_optimization_guide()\n",
832-
"print(\"\\nCost optimization guide generated.\")"
833-
]
669+
"source": "def azure_cost_optimization_guide():\n \"\"\"\n Cost optimization strategies for Azure + Clustrix.\n \"\"\"\n \n cost_monitoring_commands = \"\"\"\n# Set up budget alerts\naz consumption budget create \\\n --budget-name clustrix-monthly-budget \\\n --amount 100 \\\n --time-grain Monthly \\\n --time-period-start 2025-01-01 \\\n --time-period-end 2025-12-31\n\n# Get current costs\naz consumption usage list \\\n --start-date 2025-01-01 \\\n --end-date 2025-01-31\n\n# List resource costs\naz costmanagement query \\\n --type Usage \\\n --dataset-aggregation '{\"totalCost\":{\"name\":\"PreTaxCost\",\"function\":\"Sum\"}}' \\\n --dataset-grouping name=ResourceGroup type=Dimension\n\"\"\"\n \n print(\"Cost Monitoring Commands:\")\n print(cost_monitoring_commands)\n \n return {\n 'recommendations': [\n 'Use Spot VMs for batch processing',\n 'Enable auto-shutdown for dev resources',\n 'Implement lifecycle policies for storage',\n 'Set up budget alerts',\n 'Regular cost reviews'\n ]\n }\n\n# Example Spot VM configuration for cost savings\ndef configure_spot_vm():\n \"\"\"Example configuration for using Azure Spot VMs.\"\"\"\n configure(\n cluster_type=\"ssh\",\n cluster_host=\"your-spot-vm-ip\",\n username=\"azureuser\",\n key_file=\"~/.ssh/id_rsa\",\n remote_work_dir=\"/tmp/clustrix\",\n # Spot VMs can be evicted, so use shorter timeouts\n default_time=\"00:30:00\",\n job_poll_interval=60, # Check more frequently\n cleanup_on_success=True # Clean up quickly\n )\n print(\"Configured for Azure Spot VMs with appropriate timeouts.\")\n\ncost_guide = azure_cost_optimization_guide()\nprint(\"\\nCost optimization guide generated.\")"
670+
},
671+
{
672+
"cell_type": "markdown",
673+
"id": "scseti9hu",
674+
"source": "### Azure Cost Optimization for Clustrix\n\n#### 1. Compute Optimization\n- **Use Azure Spot VMs** for non-critical workloads (up to 90% savings)\n- **Choose B-series burstable VMs** for variable workloads\n- **Use reserved instances** for predictable workloads (1-3 year terms)\n- **Enable auto-shutdown** for dev/test VMs\n- **Right-size VMs** based on actual usage\n\n#### 2. Storage Optimization\n- **Use appropriate storage tiers** (Hot, Cool, Archive)\n- **Enable lifecycle management** for blob storage\n- **Use managed disks** with appropriate performance tiers\n- **Implement data deduplication** and compression\n\n#### 3. Network Optimization\n- **Minimize data transfer** between regions\n- **Use Azure CDN** for static content\n- **Optimize data transfer** patterns\n\n#### 4. Monitoring and Management\n- **Set up budget alerts** and spending limits\n- **Use Azure Cost Management + Billing**\n- **Implement proper resource tagging**\n- **Regular cost reviews** and optimizations\n\n#### 5. Service-Specific\n- **Use Azure Functions** for small, event-driven tasks\n- **Consider Azure Container Instances** for short-running jobs\n- **Use Azure Batch** for large-scale parallel processing",
675+
"metadata": {}
834676
},
835677
{
836678
"cell_type": "markdown",

0 commit comments

Comments
 (0)