### Install Bundler Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/development.md Installs the Bundler gem. ```bash gem install bundler ``` -------------------------------- ### Start BOSH Azure Console Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/development.md Launch the interactive BOSH Azure console for testing CPI methods. Ensure you have cloned the repository and installed dependencies. ```bash cd ~/workspace/bosh-azure-cpi-release/src/bosh_azure_cpi bundle install # Please replace xxx with your credentials. cat > ~/workspace/cpi.cfg <> ~/.profile echo 'export GOPATH=$HOME/go' >> ~/.profile source ~/.profile ``` -------------------------------- ### Install System Dependencies Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/development.md Installs essential build tools and libraries required for the development environment. ```bash sudo apt-get update sudo apt-get install -y git gcc make libssl-dev libreadline-dev zlib1g-dev ``` -------------------------------- ### Install jq Package Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/additional-information/collect-deployment-err-logs.md Use this command to install the jq package, which is a prerequisite for the log collection script. ```bash sudo apt-get install jq ``` -------------------------------- ### Install Ruby Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/development.md Installs ruby-install and Ruby 3.2.3. ```bash cd ~/workspace wget -O ruby-install-0.6.1.tar.gz https://github.com/postmodern/ruby-install/archive/v0.6.1.tar.gz tar -xzvf ruby-install-0.6.1.tar.gz pushd ruby-install-0.6.1/ sudo make install popd ruby-install ruby 3.2.3 echo 'chruby 3.2.3' >> ~/.profile source ~/.profile ruby -v ``` -------------------------------- ### Sample Role Assignment Output Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/get-started/create-service-principal.md Example output returned when listing role assignments. ```text info: Executing command role assignment list + Searching for role assignments data: RoleAssignmentId : /subscriptions/87654321-1234-5678-1234-678912345678/providers/Microsoft.Authorization/roleAssignments/16645a17-3184-47c1-8e00-8eb1d0643d54 data: RoleDefinitionName : Network Contributor data: RoleDefinitionId : 4d97b98b-1d4f-4787-a291-c67834d212e7 data: Scope : /subscriptions/87654321-1234-5678-1234-678912345678 data: Display Name : CloudFoundry data: SignInName : data: ObjectId : 039ccb8a-5b34-4020-bff9-ba38bef98f61 data: ObjectType : ServicePrincipal data: data: RoleAssignmentId : /subscriptions/87654321-1234-5678-1234-678912345678/providers/Microsoft.Authorization/roleAssignments/8af758ad-1377-4aa4-ae12-3c084ab2271f data: RoleDefinitionName : Virtual Machine Contributor data: RoleDefinitionId : 9980e02c-c2be-4d73-94e8-173b1dc7cf3c data: Scope : /subscriptions/87654321-1234-5678-1234-678912345678 data: Display Name : CloudFoundry data: SignInName : data: ObjectId : 039ccb8a-5b34-4020-bff9-ba38bef98f61 data: ObjectType : ServicePrincipal data: info: role assignment list command OK ``` -------------------------------- ### Install direnv Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/development.md Installs direnv from source to manage environment variables. ```bash mkdir -p $GOPATH/src/github.com/direnv git clone https://github.com/direnv/direnv.git $GOPATH/src/github.com/direnv/direnv pushd $GOPATH/src/github.com/direnv/direnv make sudo make install popd echo 'eval "$(direnv hook bash)"' >> ~/.profile source ~/.profile ``` -------------------------------- ### Configure and Start BOSH Azure Console Source: https://context7.com/cloudfoundry/bosh-azure-cpi-release/llms.txt Creates a CPI configuration file and launches the interactive console for testing. ```bash # Create CPI configuration file cat > ~/cpi.cfg < storage_account_name: resource_group_name: tenant_id: client_id: client_secret: '' ssh_user: vcap ssh_public_key: ssh-rsa AAAAB3... default_security_group: nsg-bosh debug_mode: false use_managed_disks: true EOF # Start console cd ~/bosh-azure-cpi-release/src/bosh_azure_cpi/bin ./bosh_azure_console -c ~/cpi.cfg ``` -------------------------------- ### Configure VM Boot Diagnostics Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/additional-information/troubleshooting.md Configuration examples for enabling VM boot diagnostics in different CPI versions. ```yaml properties: azure: &azure environment: AzureCloud subscription_id: ... ... debug_mode: true ``` ```yaml properties: azure: &azure environment: AzureCloud subscription_id: ... ... enable_vm_boot_diagnostics: true ``` -------------------------------- ### Run Unit Tests and Linting Source: https://context7.com/cloudfoundry/bosh-azure-cpi-release/llms.txt Commands to clone the repository, install dependencies, and execute the test suite and RuboCop checks. ```bash # Clone repository git clone https://github.com/cloudfoundry/bosh-azure-cpi-release cd bosh-azure-cpi-release/src/bosh_azure_cpi # Install dependencies bundle install # Run unit tests ./bin/test-unit # Run rubocop checks bundle install --with=test ./bin/rubocop_check ``` -------------------------------- ### Configure Availability Zones Source: https://context7.com/cloudfoundry/bosh-azure-cpi-release/llms.txt Example configuration for Azure availability zones in cloud-config.yml. ```yaml # cloud-config.yml - Availability Zones azs: - name: z1 cloud_properties: availability_zone: "1" - name: z2 cloud_properties: availability_zone: "2" - name: z3 cloud_properties: availability_zone: "3" ``` -------------------------------- ### Test Create VM Method Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/development.md Example of testing the `create_vm` CPI method. Requires agent ID, a valid stemcell ID, resource pool, and network configuration. ```ruby # Test create_vm with a valid stemcell_id agent_id = "" stemcell_id = "" resource_pool = JSON('{"instance_type":"Standard_F1"}') networks = JSON('{"private":{"cloud_properties":{"subnet_name":"Bosh","virtual_network_name":"boshvnet-crp"},"default":["dns","gateway"],"dns":["168.63.129.16","8.8.8.8"],"gateway":"10.0.0.1","ip":"10.0.0.42","netmask":"255.255.255.0","type":"manual"}}') instance_id = cpi.create_vm(agent_id, stemcell_id, resource_pool, networks) ``` -------------------------------- ### Install chruby Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/development.md Installs chruby for Ruby version management. ```bash cd ~/workspace wget -O chruby-0.3.9.tar.gz https://github.com/postmodern/chruby/archive/v0.3.9.tar.gz tar -xzvf chruby-0.3.9.tar.gz pushd chruby-0.3.9/ sudo make install echo 'source /usr/local/share/chruby/chruby.sh' >> ~/.profile popd source ~/.profile ``` ```bash brew install chruby sudo ln -s '/opt/homebrew/opt/chruby/share/chruby' '/usr/local/share/chruby' echo 'source /usr/local/share/chruby/chruby.sh' >> ~/.profile source ~/.profile ``` -------------------------------- ### Login to Cloud Foundry Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/get-started/push-demo-app.md Use this script to log in to your Cloud Foundry instance. Ensure you have the cf CLI installed. ```bash ./login_cloud_foundry.sh ``` -------------------------------- ### Ephemeral Disk Size Calculation Example Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/advanced/calculate-vm-cloud-properties/README.md Illustrates how the Azure CPI calculates the ephemeral disk size, converting MiB to GiB and rounding up. For example, 1025 MiB results in a 2048 MiB (2 GiB) disk. ```json 'ephemeral_disk' => { 'size' => 2048 } ``` -------------------------------- ### Test Disk Manager Method Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/development.md Example of testing the `has_disk?` method from `disk_manager2.rb` within the BOSH Azure console. ```ruby # Test disk_manager2.rb cpi.disk_manager2.has_disk?('fake-resource-group-name', 'bosh-disk-a') ``` -------------------------------- ### Configure VM Types with Managed Disks Source: https://context7.com/cloudfoundry/bosh-azure-cpi-release/llms.txt Example configuration for VM types using managed disks in cloud-config.yml. ```yaml # cloud-config.yml - VM types vm_types: - name: small cloud_properties: instance_type: Standard_D2s_v3 ephemeral_disk: size: 30720 type: Premium_LRS - name: large cloud_properties: instance_type: Standard_D8s_v3 root_disk: size: 65536 ephemeral_disk: size: 102400 type: Premium_LRS - name: with-load-balancer cloud_properties: instance_type: Standard_D4s_v3 load_balancer: cf-router-lb application_gateway: cf-app-gateway # Optional Application Gateway ``` -------------------------------- ### Test Azure Client Method Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/development.md Example of testing the `get_resource_group` method from `azure_client2.rb` within the BOSH Azure console. ```ruby # Test the mehodes in azure_client2.rb cpi.azure_client2.get_resource_group('fake-resource-group-name') ``` -------------------------------- ### Test Create Stemcell Method Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/development.md Example of testing the `create_stemcell` CPI method. Requires a stemcell properties hash, including image details. ```ruby # Test the CPI method create_stemcell stemcell_properties = { "name" => "fake-name", "version" => "fake-version", "infrastructure" => "azure", "hypervisor" => "hyperv", "disk" => "30720", "disk_format" => "vhd", "container_format" => "bare", "os_type" => "linux", "os_distro" => "ubuntu", "architecture" => "x86_64", "image" => {"publisher"=>"Canonical", "offer"=>"UbuntuServer", "sku"=>"16.04-LTS", "version"=>"16.04.201611220"} } cpi.create_stemcell('', stemcell_properties) ``` -------------------------------- ### Download a Demo Application Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/get-started/push-demo-app.md Clone the '2048' demo application from GitHub to your local machine. This application will be deployed to Cloud Foundry. ```bash git clone https://github.com/bingosummer/2048 ``` -------------------------------- ### Get Disks Source: https://context7.com/cloudfoundry/bosh-azure-cpi-release/llms.txt Returns a list of persistent disk CIDs attached to a VM. ```ruby vm_cid = "vm-;my-resource-group" disks = cpi.get_disks(vm_cid) # Returns: ["caching:ReadWrite;bosh-disk-data-;...", "caching:None;bosh-disk-data-;..."] ``` -------------------------------- ### Create Workspace Directory Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/development.md Initializes the base directory for development projects. ```bash mkdir ~/workspace ``` -------------------------------- ### Create Standard Load Balancer Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/advanced/standard-load-balancers/README.md Deploy a Standard SKU Load Balancer using an ARM template. This command sets up the basic load balancer infrastructure. ```bash rg_name="" lb_name="" lb_ip_name="" az group deployment create -g ${rg_name} --template-file --parameters loadBalancerName=${lb_name} loadBalancerPublicIPAddressName=${lb_ip_name} ``` -------------------------------- ### Create Standard SKU Load Balancer Source: https://context7.com/cloudfoundry/bosh-azure-cpi-release/llms.txt Use Azure CLI to create a public IP address with Standard SKU and a Standard Load Balancer. ```bash # Set variables RG_NAME="cf-resource-group" LB_NAME="cf-standard-lb" LB_IP_NAME="cf-lb-public-ip" LOCATION="eastus" # Create public IP with Standard SKU az network public-ip create \ --resource-group ${RG_NAME} \ --name ${LB_IP_NAME} \ --sku Standard \ --allocation-method Static # Create Standard Load Balancer az network lb create \ --resource-group ${RG_NAME} \ --name ${LB_NAME} \ --sku Standard \ --public-ip-address ${LB_IP_NAME} \ --frontend-ip-name LoadBalancerFrontEnd \ --backend-pool-name BackendPool # Create health probe az network lb probe create \ --resource-group ${RG_NAME} \ --lb-name ${LB_NAME} \ --name healthProbe \ --protocol tcp \ --port 8080 ``` -------------------------------- ### DNS Lookup Error Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/additional-information/troubleshooting.md Example of a DNS resolution error when attempting to reach the Cloud Foundry API. ```text Error performing request: Get https://api./v2/info: dial tcp: lookup api.: no such host ``` -------------------------------- ### Get CPI Info Source: https://context7.com/cloudfoundry/bosh-azure-cpi-release/llms.txt Returns CPI information including supported stemcell formats and API version. ```ruby info = cpi.info # Returns: # { # "stemcell_formats" => ["azure-vhd", "azure-light"], # "api_version" => 2 # } ``` -------------------------------- ### Create Development Release Source: https://context7.com/cloudfoundry/bosh-azure-cpi-release/llms.txt Packages the BOSH Azure CPI into a release tarball for development purposes. ```bash cd ~/bosh-azure-cpi-release cpi_dev_version=53.2.0.dev bosh create-release \ --name=bosh-azure-cpi \ --version=${cpi_dev_version} \ --tarball=/tmp/bosh-azure-cpi-release-${cpi_dev_version}.tgz ``` -------------------------------- ### Deploy Cloud Foundry with Accelerated Networking Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/advanced/accelerated-networking/README.md Command to initiate a BOSH deployment after configuring accelerated networking in the cloud config. ```bash bosh -d cf deploy cf-deployment.yml \ ... ``` -------------------------------- ### Enable VM Resources Feature in Instance Group Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/advanced/calculate-vm-cloud-properties/README.md Shows how to replace `vm_type` with `vm_resources` in an instance group configuration for enabling the feature. Requires redeploying the BOSH director first. ```diff instance_groups: - name: log-api --- vm_type: minimal +++ vm_resources: +++ cpu: 2 +++ ram: 2048 +++ ephemeral_disk_size: 10240 ``` -------------------------------- ### Download and Run Log Collection Script Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/additional-information/collect-deployment-err-logs.md Download the script to your jumpbox and execute it to collect deployment error logs. The logs will be saved in a compressed TGZ file. ```bash wget https://raw.githubusercontent.com/cloudfoundry/bosh-azure-cpi-release/master/docs/additional-information/collect-deployment-err-logs.sh bash collect-deployment-err-logs.sh ``` -------------------------------- ### Run Vendoring Script Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/development.md Runs the vendoring script to prepare dependencies. ```bash cd ~/workspace/bosh-azure-cpi-release/src/bosh_azure_cpi ./bin/vendor_gems ``` -------------------------------- ### Identify Stemcell Version Mismatch Error Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/additional-information/known-issues.md Example of a deployment failure log indicating a connection refusal due to incompatible stemcell versions. ```text Command 'deploy' failed: Deploying: Creating instance 'bosh/0': Waiting until instance is ready: Sending ping to the agent: Performing request to agent endpoint 'https://mbus-user:mbus-password@10.0.0.4:6868/agent': Performing POST request: Post https://mbus-user:mbus-password@10.0.0.4:6868/agent: dial tcp 10.0.0.4:6868: getsockopt: connection refused ``` -------------------------------- ### Create Service Principal using Bash Script Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/get-started/create-service-principal.md This bash script automates the creation of a service principal. Run the downloaded script to generate your service principal credentials, including SUBSCRIPTION_ID, TENANT_ID, CLIEND_ID, and CLIENT_SECRET. ```bash ==============Created Serivce Principal============== SUBSCRIPTION_ID: 12345678-1234-5678-1234-678912345678 TENANT_ID: 11111111-1234-5678-1234-678912345678 CLIEND_ID: 87654321-1234-5678-1234-678912345678 CLIENT_SECRET: RANDOM-STRING ``` -------------------------------- ### Verify network interfaces with ifconfig Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/advanced/deploy-multiple-network-interfaces/README.md Use this command to execute ifconfig inside a specific BOSH VM instance to inspect network interface details. ```bash bosh -e azure -d cf ssh diego-cell/0 ifconfig ``` ```text Using environment '10.0.0.4' as client 'admin' Using deployment 'cf' Task 80. Done diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stderr | Unauthorized use is strictly prohibited. All access and activity diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stderr | is subject to logging and monitoring. diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | eth0 Link encap:Ethernet HWaddr 00:0d:3a:40:a9:3b diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | inet addr:10.0.16.16 Bcast:10.0.31.255 Mask:255.255.240.0 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | RX packets:317660 errors:0 dropped:0 overruns:0 frame:0 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | TX packets:135706 errors:0 dropped:0 overruns:0 carrier:0 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | collisions:0 txqueuelen:1000 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | RX bytes:435253140 (435.2 MB) TX bytes:12975351 (12.9 MB) diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | eth1 Link encap:Ethernet HWaddr 00:0d:3a:40:ab:d9 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | inet addr:10.0.40.4 Bcast:10.0.40.255 Mask:255.255.255.0 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | RX packets:2 errors:0 dropped:0 overruns:0 frame:0 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | TX packets:22 errors:0 dropped:0 overruns:0 carrier:0 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | collisions:0 txqueuelen:1000 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | RX bytes:762 (762.0 B) TX bytes:1524 (1.5 KB) diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | eth2 Link encap:Ethernet HWaddr 00:0d:3a:40:aa:58 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | inet addr:10.0.41.4 Bcast:10.0.41.255 Mask:255.255.255.0 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | RX packets:2 errors:0 dropped:0 overruns:0 frame:0 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | TX packets:22 errors:0 dropped:0 overruns:0 carrier:0 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | collisions:0 txqueuelen:1000 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | RX bytes:762 (762.0 B) TX bytes:1524 (1.5 KB) diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | lo Link encap:Local Loopback diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | inet addr:127.0.0.1 Mask:255.0.0.0 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | UP LOOPBACK RUNNING MTU:65536 Metric:1 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | RX packets:22050 errors:0 dropped:0 overruns:0 frame:0 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | TX packets:22050 errors:0 dropped:0 overruns:0 carrier:0 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | collisions:0 txqueuelen:1 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | RX bytes:2839828 (2.8 MB) TX bytes:2839828 (2.8 MB) diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | silk-vtep Link encap:Ethernet HWaddr ee:ee:0a:ff:24:00 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | inet addr:10.255.36.0 Bcast:0.0.0.0 Mask:255.255.0.0 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | UP BROADCAST RUNNING MULTICAST MTU:1450 Metric:1 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | RX packets:0 errors:0 dropped:0 overruns:0 frame:0 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | collisions:0 txqueuelen:0 diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stdout | diego-cell/54992d97-4056-4cb9-9278-7d7c5095bc95: stderr | Connection to 10.0.16.16 closed. Succeeded ``` -------------------------------- ### Collect More Error Logs Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/additional-information/collect-deployment-err-logs.md To collect more than the default 10 error logs, pass the desired count as a parameter to the script. For example, to collect 50 logs, use `--err-log-count 50`. ```bash bash collect-deployment-err-logs.sh --err-log-count 50 ``` -------------------------------- ### Deploy HAProxy Instance with Ops File Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/advanced/migrate-basic-lb-to-standard-lb/README.md Use this command to deploy Cloud Foundry with an HAProxy instance using the `use-haproxy.yml` ops file. Ensure your BOSH cloud-config includes the `cf-haproxy-network-properties` vm_extension. ```bash bosh -d cf deploy cf-deployment.yml \ ... \ -o use-haproxy.yml \ ... ``` -------------------------------- ### BOSH Persistent Disk Error Example Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/additional-information/known-issues.md This error message indicates a timeout when BOSH attempts to list disks, often occurring when 'use_root_disk' is true and the VM lacks a dedicated ephemeral disk. A workaround is available in Azure CPI v33. ```text Started updating instance mysql Started updating instance mysql > mysql/33e8e561-233c-4a26-9f7e-4a6fbf978ce4 (0) (canary). Failed: Timed out sending 'list_disk' to c4e6e2ff-8ee2-463b-a1d2-f1190b4e21e1 after 45 seconds (00:18:15) Error 450002: Timed out sending 'list_disk' to c4e6e2ff-8ee2-463b-a1d2-f1190b4e21e1 after 45 seconds ``` -------------------------------- ### Login to Azure CLI 1.0 Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/get-started/create-service-principal.md Log in to Azure CLI 1.0 using your work or school account credentials. Replace `$ENVIRONMENT` with your specific Azure environment, such as `AzureCloud`. ```bash #Enter your Microsoft account credentials when prompted. azure login --environment $ENVIRONMENT ``` -------------------------------- ### Deploy Cloud Foundry Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/advanced/deploy-cloudfoundry-with-availability-sets/README.md Execute the deployment script after applying the availability set configuration. ```bash ./deploy_cloud_foundry.sh ``` -------------------------------- ### Create Load Balancer for MySQL Proxy Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/advanced/standard-load-balancers/README.md Deploy the ARM template to configure the load balancer for the MySQL proxy service. ```bash az group deployment create -g ${rg_name} --template-file load-balancer-for-mysql-proxy.json --parameters loadBalancerName=${lb_name} loadBalancerPublicIPAddressName=${lb_ip_name} ``` -------------------------------- ### Clone Azure CPI Repository Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/development.md Clones the repository and initializes the environment with direnv. ```bash cd ~/workspace git clone https://github.com/cloudfoundry/bosh-azure-cpi-release cd bosh-azure-cpi-release/ direnv allow ``` -------------------------------- ### Login to Azure CLI Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/advanced/standard-load-balancers/README.md Authenticate to Azure using a service principal and set the active subscription. Ensure you replace placeholders with your actual Azure credentials. ```bash AZURE_SUBSCRIPTION_ID="" AZURE_TENANT_ID="" AZURE_CLIENT_ID="" AZURE_CLIENT_SECRET="" az login --service-principal --tenant ${AZURE_TENANT_ID} -u ${AZURE_CLIENT_ID} -p ${AZURE_CLIENT_SECRET} az account set -s ${AZURE_SUBSCRIPTION_ID} ``` -------------------------------- ### Push Application to Cloud Foundry Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/get-started/push-demo-app.md Navigate into the application directory and use the 'cf push' command to deploy the application. This command uploads your application code and dependencies to Cloud Foundry. ```bash cd 2048 cf push ``` -------------------------------- ### Add Standard SKU Load Balancer Configuration Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/advanced/migrate-basic-lb-to-standard-lb/README.md This diff illustrates how to add the Standard SKU load balancer configuration to `cf-router-network-properties`, `cf-tcp-router-network-properties`, and `diego-ssh-proxy-network-properties`. ```yaml vm_extensions: - name: cf-router-network-properties + cloud_properties: + load_balancer: - name: cf-tcp-router-network-properties + cloud_properties: + load_balancer: - name: diego-ssh-proxy-network-properties + cloud_properties: + load_balancer: ``` -------------------------------- ### Create Azure subnets for additional NICs Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/advanced/deploy-multiple-network-interfaces/README.md Use these commands to provision the subnets required for secondary and tertiary network interfaces. ```bash az network vnet subnet create --resource-group bosh-res-group --vnet-name boshvnet-crp --name CloudFoundry2 --address-prefix 10.0.40.0/24 az network vnet subnet create --resource-group bosh-res-group --vnet-name boshvnet-crp --name CloudFoundry3 --address-prefix 10.0.41.0/24 ``` -------------------------------- ### Create Load Balancer for Routers Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/advanced/standard-load-balancers/README.md Deploy a specific ARM template to configure the load balancer for Cloud Foundry routers. ```bash az group deployment create -g ${rg_name} --template-file load-balancer-for-routers.json --parameters loadBalancerName=${lb_name} loadBalancerPublicIPAddressName=${lb_ip_name} ``` -------------------------------- ### Run Manual Test Script Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/src/bosh_azure_cpi/spec/manual_tests/resource_group_name/README.md Execute the Ruby script to initiate the manual test for the multiple resource group feature. Ensure the BOSH environment and configuration files are set up correctly before running. ```bash ruby ./migrate_to_new_rg.rb ``` -------------------------------- ### Snapshot Disk Source: https://context7.com/cloudfoundry/bosh-azure-cpi-release/llms.txt Creates a snapshot of a disk. ```ruby disk_cid = "caching:ReadWrite;bosh-disk-data-;resource_group_name:my-rg" metadata = { "deployment" => "my-deployment", "instance_index" => "0" } snapshot_cid = cpi.snapshot_disk(disk_cid, metadata) # Returns: "caching:ReadWrite;bosh-disk-data-;resource_group_name:my-rg" ``` -------------------------------- ### Re-deploy BOSH director Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/advanced/managed-disks/README.md Execute the create-env command to apply configuration changes to the BOSH director. ```bash bosh create-env ~/bosh.yml ``` -------------------------------- ### Login to BOSH Director (v2) Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/additional-information/collect-deployment-err-logs.md Log in to your BOSH director using the BOSH CLI v2. Replace ${env} with your environment name. Ensure you have admin permissions. ```bash bosh -e ${env} login ``` -------------------------------- ### Login to BOSH Director (v1) Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/additional-information/collect-deployment-err-logs.md Log in to your BOSH director using the BOSH CLI v1. Ensure you have admin permissions. ```bash bosh login ``` -------------------------------- ### Create Service Principal with Azure CLI 2.0 Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/get-started/create-service-principal.md Use this command to create a service principal with Azure CLI 2.0. The output includes credentials like `appId`, `password`, and `tenant` which correspond to `CLIENT_ID`, `CLIENT_SECRET`, and `TENANT_ID`. ```bash az ad sp create-for-rbac ``` -------------------------------- ### Login with Azure CLI 1.0 Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/get-started/create-service-principal.md Authenticates using service principal credentials with Azure CLI 1.0. ```bash azure login --service-principal --username $CLIENT_ID --password $CLIENT_SECRET --tenant $TENANT_ID --environment $ENVIRONMENT ``` ```bash azure login --service-principal --username 246e4af7-75b5-494a-89b5-363addb9f0fa --password "password" --tenant 22222222-1234-5678-1234-678912345678 --environment AzureCloud ``` -------------------------------- ### Run Unit Tests Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/development.md Executes the unit test suite for the Azure CPI. ```bash cd ~/workspace/bosh-azure-cpi-release/src/bosh_azure_cpi ./bin/test-unit ``` ```bash cd ~/workspace/bosh-azure-cpi-release pushd src/bosh_azure_cpi ./bin/test-unit popd ``` ```bash cd ~/workspace/bosh-azure-cpi-release pushd 'src/bosh_azure_cpi' ; ./bin/test-unit ; popd ``` -------------------------------- ### Create VM with Azure Cloud Properties Source: https://context7.com/cloudfoundry/bosh-azure-cpi-release/llms.txt Creates a new VM with specified Azure resource pool settings, including instance type, disk configuration, availability zone, and managed identity. Network configuration with cloud properties for VNet and subnet is also included. ```ruby # VM creation with cloud properties agent_id = "agent-" stemcell_id = "bosh-stemcell-" # Resource pool / VM type cloud properties resource_pool = { "instance_type" => "Standard_D2s_v3", "ephemeral_disk" => { "size" => 30720, # Size in MB "type" => "Premium_LRS" # Storage account type }, "root_disk" => { "size" => 50 * 1024 # Size in MB (50 GB) }, "availability_zone" => "1", # Azure Availability Zone (1, 2, or 3) "load_balancer" => "my-standard-lb", # Azure Load Balancer name "managed_identity" => { "type" => "UserAssigned", "user_assigned_identity_name" => "my-identity" } } # Network configuration networks = { "private" => { "type" => "manual", "ip" => "10.0.0.42", "netmask" => "255.255.255.0", "gateway" => "10.0.0.1", "dns" => ["168.63.129.16", "8.8.8.8"], "default" => ["dns", "gateway"], "cloud_properties" => { "virtual_network_name" => "boshvnet-crp", "subnet_name" => "Bosh", "resource_group_name" => "network-rg" # Optional, for separate network RG } } } disk_cids = [] # Existing disk CIDs for placement optimization environment = { "bosh" => { "group" => "my-deployment" } } instance_id = cpi.create_vm(agent_id, stemcell_id, resource_pool, networks, disk_cids, environment) # Returns: "vm-;my-resource-group" ``` -------------------------------- ### Create and Target a Cloud Foundry Space Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/get-started/push-demo-app.md Create a new space named 'azure' and then target it for subsequent operations. This organizes your applications within Cloud Foundry. ```bash cf create-space azure cf target -s azure ``` -------------------------------- ### Create Disk Source: https://context7.com/cloudfoundry/bosh-azure-cpi-release/llms.txt Creates a persistent disk, supporting managed and unmanaged types. ```ruby size_mb = 50 * 1024 # 50 GB in MB cloud_properties = { "storage_account_type" => "Premium_LRS", # Standard_LRS, Premium_LRS, StandardSSD_LRS, PremiumV2_LRS, UltraSSD_LRS "caching" => "ReadWrite", # None, ReadOnly, ReadWrite "iops" => 3000, # For PremiumV2_LRS or UltraSSD_LRS "mbps" => 125, # For PremiumV2_LRS or UltraSSD_LRS "disk_encryption_set_name" => "my-des" # Optional disk encryption set } vm_cid = "vm-;my-resource-group" # Optional, for placement optimization disk_cid = cpi.create_disk(size_mb, cloud_properties, vm_cid) # Returns: "caching:ReadWrite;bosh-disk-data-;resource_group_name:my-rg" ``` -------------------------------- ### Create Azure Service Principal using CLI Source: https://context7.com/cloudfoundry/bosh-azure-cpi-release/llms.txt Use Azure CLI to create a service principal with the Contributor role and retrieve its credentials. ```bash # Create service principal with Contributor role (default) az ad sp create-for-rbac --name "ServicePrincipalForBOSH" # Output: # { # "appId": "246e4af7-75b5-494a-89b5-363addb9f0fa", <-"CLIENT_ID # "displayName": "ServicePrincipalForBOSH", # "password": "generated-password", <-"CLIENT_SECRET # "tenant": "22222222-1234-5678-1234-678912345678" <-"TENANT_ID # } # Get subscription ID az account show --query id --output tsv # Verify service principal login az login --service-principal \ --username 246e4af7-75b5-494a-89b5-363addb9f0fa \ --password "your-client-secret" \ --tenant 22222222-1234-5678-1234-678912345678 ``` -------------------------------- ### create_vm Source: https://context7.com/cloudfoundry/bosh-azure-cpi-release/llms.txt Creates a new VM based on a stemcell with specified cloud properties and network configuration. ```APIDOC ## create_vm Creates a new VM based on a stemcell with specified cloud properties and network configuration. ```ruby # VM creation with cloud properties agent_id = "agent-" stemcell_id = "bosh-stemcell-" # Resource pool / VM type cloud properties resource_pool = { "instance_type" => "Standard_D2s_v3", "ephemeral_disk" => { "size" => 30720, # Size in MB "type" => "Premium_LRS" # Storage account type }, "root_disk" => { "size" => 50 * 1024 # Size in MB (50 GB) }, "availability_zone" => "1", # Azure Availability Zone (1, 2, or 3) "load_balancer" => "my-standard-lb", # Azure Load Balancer name "managed_identity" => { "type" => "UserAssigned", "user_assigned_identity_name" => "my-identity" } } # Network configuration networks = { "private" => { "type" => "manual", "ip" => "10.0.0.42", "netmask" => "255.255.255.0", "gateway" => "10.0.0.1", "dns" => ["168.63.129.16", "8.8.8.8"], "default" => ["dns", "gateway"], "cloud_properties" => { "virtual_network_name" => "boshvnet-crp", "subnet_name" => "Bosh", "resource_group_name" => "network-rg" # Optional, for separate network RG } } } disk_cids = [] # Existing disk CIDs for placement optimization environment = { "bosh" => { "group" => "my-deployment" } } instance_id = cpi.create_vm(agent_id, stemcell_id, resource_pool, networks, disk_cids, environment) # Returns: "vm-;my-resource-group" ``` ``` -------------------------------- ### VM Type Display After Enabling Feature Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/advanced/calculate-vm-cloud-properties/README.md Demonstrates the output of `bosh vms` after enabling `vm_resources`, where the 'VM Type' column shows '-' indicating it's managed by `vm_resources`. ```text Instance Process State AZ IPs VM CID VM Type log-api/97d456cf-cf28-439d-b77d-25af8848fe9e running z1 10.0.16.18 - ``` -------------------------------- ### Test CPI Methods in Console Source: https://context7.com/cloudfoundry/bosh-azure-cpi-release/llms.txt Ruby commands to interact with the Azure client, disk manager, and stemcell creation within the console. ```ruby # In the console - test various CPI methods # Test Azure client cpi.azure_client2.get_resource_group('my-resource-group') # Test disk manager cpi.disk_manager2.has_disk?('my-resource-group', 'bosh-disk-data-xxx') # Create a light stemcell stemcell_props = { "name" => "test-stemcell", "version" => "1.0", "infrastructure" => "azure", "image" => { "publisher" => "Canonical", "offer" => "0001-com-ubuntu-server-jammy", "sku" => "22_04-lts", "version" => "latest" } } cpi.create_stemcell('', stemcell_props) ``` -------------------------------- ### Login with Azure CLI 2.0 Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/get-started/create-service-principal.md Authenticates using service principal credentials with Azure CLI 2.0. ```bash az cloud set --name $ENVIRONMENT az login --service-principal --username $CLIENT_ID --password $CLIENT_SECRET --tenant $TENANT_ID ``` ```bash az cloud set --name AzureCloud az login --service-principal --username 246e4af7-75b5-494a-89b5-363addb9f0fa --password "password" --tenant 22222222-1234-5678-1234-678912345678 ``` -------------------------------- ### Configure BOSH Azure CPI Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/development.md Create a configuration file for the BOSH Azure CPI. Replace placeholder values (xxx) with your actual Azure credentials and settings. ```yaml --- azure: environment: AzureCloud subscription_id: xxx storage_account_name: xxx resource_group_name: xxx tenant_id: xxx client_id: xxx client_secret: 'xxx' ssh_user: vcap ssh_public_key: ssh-rsa xxx default_security_group: nsg-bosh debug_mode: false use_managed_disks: false ``` -------------------------------- ### Calculate VM Cloud Properties Source: https://context7.com/cloudfoundry/bosh-azure-cpi-release/llms.txt Calculates cloud properties based on desired VM size requirements. ```ruby desired_instance_size = { "cpu" => 4, # Number of vCPUs "ram" => 8192, # RAM in MiB "ephemeral_disk_size" => 30720 # Ephemeral disk in MB } cloud_properties = cpi.calculate_vm_cloud_properties(desired_instance_size) # Returns: # { # "instance_types" => ["Standard_D4s_v3", "Standard_D4_v3", ...], # "ephemeral_disk" => { "size" => 31744 } # } ``` -------------------------------- ### Create BOSH Dev Release Source: https://github.com/cloudfoundry/bosh-azure-cpi-release/blob/master/docs/development.md Command to create a development release tarball for the BOSH Azure CPI. Requires BOSH CLI v2.0.36+ for `bosh vendor-package`. ```bash cd ~/workspace/bosh-azure-cpi-release cpi_dev_version=35.0.1.dev bosh create-release --name=bosh-azure-cpi --version=${cpi_dev_version} --tarball=/tmp/bosh-azure-cpi-release-${cpi_dev_version}.tgz ```