=============== LIBRARY RULES =============== From library maintainers: - Authenticate once, then reuse: run `virak-cli login` (or `virak-cli login --token `) to open the OAuth flow or provide a scoped API token and rely on the saved credential in `~/.virak-cli.yaml` so subsequent commands inherit the session without retyping tokens. - Set a default zone: store `default.zoneId`/`default.zoneName` in the config file or pass `--zoneId`, allowing `bucket`, `dns`, `instance`, `network`, and other commands to pick up the saved defaults and avoid repeated flags. - Use environment variables in automation: export `VIRAK_CLI_TOKEN`, `VIRAK_CLI_ZONE_ID`, and related secrets in CI/CD pipelines rather than committing credentials, matching the docs' guidance for secure automation and rotation. ### Create Object Storage Bucket with Go SDK Source: https://context7.com/virak-cloud/cli/llms.txt Uses Virak Go SDK to create an object storage bucket with specified zone, name, and policy. Requires authenticated HTTP client and handles errors via err return. Outputs response object or error; limited to create operation in this example, assumes SDK import and token setup. ```go // Go SDK example client := http.NewClient("your-token") response, err := client.CreateObjectStorageBucket( "01HXXX...", // zoneId "my-bucket", // name "Private", // policy (Private|Public) ) if err != nil { log.Fatal(err) } ``` -------------------------------- ### Deploy Infrastructure with GitHub Actions Source: https://github.com/virak-cloud/cli/blob/master/docs/overview.md This GitHub Actions workflow demonstrates how to set up and use the Virak CLI to deploy infrastructure. It checks out the code, downloads and installs the CLI, and then creates a new instance using secrets for authentication. ```yaml name: Deploy Infrastructureon: push jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup Virak CLI run: | wget https://github.com/virak-cloud/cli/releases/download/latest/virak-cli-linux-amd64 chmod +x virak-cli-linux-amd64 sudo mv virak-cli-linux-amd64 /usr/local/bin/virak-cli - name: Deploy Instance env: VIRAK_CLI_TOKEN: ${{ secrets.VIRAK_TOKEN }} run: | virak-cli instance create \ --name "app-${{ github.run_number }}" \ --service-offering-id "so-web" \ --vm-image-id "img-ubuntu-22" \ --network-ids '["net-prod"]' ``` -------------------------------- ### CI/CD Bootstrap with Virak CLI and kubectl Source: https://github.com/virak-cloud/cli/blob/master/docs/kubernetes.md This example demonstrates automating Kubernetes cluster creation for CI/CD pipelines using Virak CLI and applying manifests with kubectl. It creates a cluster, retrieves its kubeconfig, and then deploys resources defined in YAML manifests. ```shell virak-cli cluster create ... --name "ci-${GIT_SHA}" --size 3 virak-cli cluster show --clusterId "$CLUSTER_ID" --zoneId zone-xyz > cluster.json jq -r '.data.kubeconfig' cluster.json > kubeconfig kubectl --kubeconfig kubeconfig apply -f manifests/ ``` -------------------------------- ### List Instances (Shell) Source: https://github.com/virak-cloud/cli/blob/master/docs/instances.md Displays a list of all instances within the specified zone, including their full metadata such as service offering, VM image, and attached volumes. This command is useful for getting an overview of your deployed instances. ```sh virak-cli instance list --zoneId zone-xyz ``` -------------------------------- ### Manage Kubernetes Clusters (CLI) Source: https://context7.com/virak-cloud/cli/llms.txt CLI commands for common Kubernetes cluster operations including listing, showing details, starting, stopping, scaling, updating, and deleting clusters. ```bash # List clusters virak-cli cluster list --zoneId "01HXXX..." # Show cluster details virak-cli cluster show --zoneId "01HXXX..." --id "01HCCCC..." # Start cluster virak-cli cluster start --zoneId "01HXXX..." --id "01HCCCC..." # Stop cluster virak-cli cluster stop --zoneId "01HXXX..." --id "01HCCCC..." # Scale cluster virak-cli cluster scale \ --zoneId "01HXXX..." \ --id "01HCCCC..." \ --size 5 # Update cluster virak-cli cluster update \ --zoneId "01HXXX..." \ --id "01HCCCC..." \ --name "new-cluster-name" # Delete cluster virak-cli cluster delete --zoneId "01HXXX..." --id "01HCCCC..." ``` -------------------------------- ### Manage Finance Operations with Virak CLI Source: https://context7.com/virak-cloud/cli/llms.txt Commands for listing payment history, cost documents, and expenses. Requires virak-cli installation and API authentication. Supports filtering by date ranges, product types, and pagination. Outputs structured billing data for financial analysis. ```bash # List payment history virak-cli finance payments # List cost documents for a specific year virak-cli finance documents --year 2024 # List expenses for a specific product virak-cli finance expenses \ --product-type "Instance" \ --product-id "01HAAAA..." \ --start-date "2024-01-01" \ --end-date "2024-12-31" \ --type "usage" \ --page 1 ``` -------------------------------- ### Instance Lifecycle Operations (Shell) Source: https://github.com/virak-cloud/cli/blob/master/docs/instances.md Performs common lifecycle operations on an instance, including starting, stopping, rebooting, rebuilding, and deleting. These commands allow for programmatic control over the instance's operational state. Rebuild reinstalls the original VM image. ```sh virak-cli instance start --instanceId inst-abc123 --zoneId zone-xyz virak-cli instance stop --instanceId inst-abc123 --zoneId zone-xyz virak-cli instance reboot --instanceId inst-abc123 --zoneId zone-xyz virak-cli instance rebuild --instanceId inst-abc123 --zoneId zone-xyz virak-cli instance delete --instanceId inst-abc123 --zoneId zone-xyz ``` -------------------------------- ### Check Available Resources Source: https://github.com/virak-cloud/cli/blob/master/docs/zones.md Retrieves information about the available resources (memory, CPU, storage, VM limits) for the current customer within a specified zone. This command reflects the GET /api/external/zones/{id}/resources endpoint. ```APIDOC ## Check Available Resources ### Description Displays the collected versus total memory, CPU cores, data volume, and VM limits for the current customer in the specified zone. Mirrors Virak panel capacity widgets. ### Method GET ### Endpoint /api/external/zones/{id}/resources ### Parameters #### Path Parameters - **id** (string) - Required - The ULID of the zone to check resources for. #### Query Parameters None ### Request Example ```sh virak-cli zone resources \ --zoneId zone-xyz ``` ### Response #### Success Response (200) - **memory** (object) - Memory details. - **collected** (integer) - Memory currently in use. - **total** (integer) - Total available memory. - **cpu** (object) - CPU core details. - **collected** (integer) - CPU cores currently in use. - **total** (integer) - Total available CPU cores. - **dataVolume** (object) - Data volume details. - **collected** (integer) - Data volume currently in use. - **total** (integer) - Total available data volume. - **vmLimits** (integer) - The limit for virtual machines. #### Response Example ```json { "memory": { "collected": 2048, "total": 8192 }, "cpu": { "collected": 16, "total": 64 }, "dataVolume": { "collected": 10240, "total": 102400 }, "vmLimits": 50 } ``` ``` -------------------------------- ### View Finance Wallet with Virak CLI (Bash) Source: https://context7.com/virak-cloud/cli/llms.txt Simple command to retrieve wallet balance in Virak Cloud finance management. No additional inputs required beyond authentication. Outputs current balance details; limited to read-only operation, depends on account billing setup. ```bash # View wallet balance virak-cli finance wallet ``` -------------------------------- ### Initialize HTTP Client in Go Applications Source: https://context7.com/virak-cloud/cli/llms.txt Demonstrates initializing the Virak Cloud Go SDK client with API token and listing instances. Requires importing the http package from github.com/virak-cloud/cli/pkg/http. Returns instance data with name, ID, and status fields for programmatic infrastructure management. ```go package main import ( "fmt" "log" "github.com/virak-cloud/cli/pkg/http" ) func main() { // Initialize client with token client := http.NewClient("your-api-token") // Example: List instances instances, err := client.ListInstances("01HXXX...") if err != nil { log.Fatal(err) } for _, instance := range instances.Data { fmt.Printf("Instance: %s (ID: %s, Status: %s)\n", instance.Name, instance.ID, instance.Status) } } ``` -------------------------------- ### List and Select Zones Source: https://github.com/virak-cloud/cli/blob/master/docs/zones.md Lists all available zones and allows selection of a default zone for subsequent commands. This command interacts with the GET /api/external/zones endpoint. ```APIDOC ## List and Select Zones ### Description Lists all available zones and their ULIDs. Allows setting a default zone via an interactive prompt or by editing the configuration file. ### Method GET (Implicitly via CLI) ### Endpoint /api/external/zones ### Parameters None ### Request Example ```sh virak-cli zone list ``` ### Response #### Success Response (200) - **zoneName** (string) - The name of the zone. - **zoneId** (string) - The ULID (Universally Unique Lexicographically Sortable Identifier) of the zone. #### Response Example ```json [ { "zoneName": "Tehran-1", "zoneId": "zone-xyz" }, { "zoneName": "London-1", "zoneId": "zone-abc" } ] ``` ``` -------------------------------- ### Inspect Zone Networks Source: https://github.com/virak-cloud/cli/blob/master/docs/zones.md Fetches and displays all L2 and L3 network offerings within a specified zone. This command calls the GET /api/external/zones/{id}/networks endpoint. ```APIDOC ## Inspect Zone Networks ### Description Fetches all L2 and L3 network offerings within a specified zone. Useful for validating capacity and discovering shared networks. ### Method GET ### Endpoint /api/external/zones/{id}/networks ### Parameters #### Path Parameters - **id** (string) - Required - The ULID of the zone to inspect. #### Query Parameters None ### Request Example ```sh virak-cli zone networks \ --zoneId zone-xyz ``` ### Response #### Success Response (200) - **networks** (array) - A list of network offerings. - **type** (string) - The type of network (e.g., L2, L3). - **name** (string) - The name of the network. - **capacity** (integer) - The capacity of the network. #### Response Example ```json { "networks": [ { "type": "L2", "name": "private-net-1", "capacity": 1000 }, { "type": "L3", "name": "public-net-1", "capacity": 500 } ] } ``` ``` -------------------------------- ### Create Instance Interactively (Shell) Source: https://github.com/virak-cloud/cli/blob/master/docs/instances.md Launches an interactive wizard to create a new instance. The CLI prompts for necessary details like VM images, networks, and instance name, simplifying the creation process by mirroring the panel workflow and applying the same validation checks. ```sh virak-cli instance create --interactive --zoneId zone-xyz ``` -------------------------------- ### List Active Services Source: https://github.com/virak-cloud/cli/blob/master/docs/zones.md Lists the status of various service families (Instances, DataVolume, Network, ObjectStorage, Kubernetes) within a specified zone. This command relates to the GET /api/external/zones/{id}/services endpoint. ```APIDOC ## List Active Services ### Description Shows boolean values for each service family (Instances, DataVolume, Network, ObjectStorage, Kubernetes) indicating if they are enabled in the specified zone. ### Method GET ### Endpoint /api/external/zones/{id}/services ### Parameters #### Path Parameters - **id** (string) - Required - The ULID of the zone to list services for. #### Query Parameters None ### Request Example ```sh virak-cli zone services \ --zoneId zone-xyz ``` ### Response #### Success Response (200) - **instances** (boolean) - Whether the Instances service is enabled. - **dataVolume** (boolean) - Whether the DataVolume service is enabled. - **network** (boolean) - Whether the Network service is enabled. - **objectStorage** (boolean) - Whether the ObjectStorage service is enabled. - **kubernetes** (boolean) - Whether the Kubernetes service is enabled. #### Response Example ```json { "instances": true, "dataVolume": true, "network": true, "objectStorage": false, "kubernetes": true } ``` ``` -------------------------------- ### Create Kubernetes Cluster (Go SDK) Source: https://context7.com/virak-cloud/cli/llms.txt Go SDK function to create a Kubernetes cluster. It takes parameters for zone, name, version, offering, SSH key, network, HA settings, cluster size, and description. ```go // Go SDK example client := http.NewClient("your-token") response, err := client.CreateKubernetesCluster( "01HXXX...", // zoneId "prod-cluster", // name "01HKKKK...", // versionId "01HOOO...", // offeringId "01HSSS...", // sshKeyId "01HNNN...", // networkId true, // haEnabled 3, // clusterSize "Production cluster", // description "", // privateRegistryUsername "", // privateRegistryPassword "", // privateRegistryURL 3, // haControllerNodes "", // haExternalLBIP ) ``` -------------------------------- ### List Available Instance Service Offerings (Shell) Source: https://github.com/virak-cloud/cli/blob/master/docs/instances.md Retrieves a list of available service offerings for instances within a specified zone. Use `--columns` to filter output for specific metrics like ID, name, CPU, memory, and price. This command helps in selecting the appropriate resources for your workloads. ```sh virak-cli instance service-offering-list --available --zoneId zone-xyz ``` -------------------------------- ### Handle Non-Existent Resources with Bash Source: https://github.com/virak-cloud/cli/blob/master/docs/overview.md This bash script demonstrates error handling by checking if an instance exists before attempting to delete it. It uses the `virak-cli instance show` command and redirects output to `/dev/null` for a clean check, exiting with an error code if the instance is not found. ```bash #!/bin/bash INSTANCE_ID="inst-12345" # Check if instance exists if virak-cli instance show "$INSTANCE_ID" >/dev/null 2>&1; then echo "Instance exists, deleting..." virak-cli instance delete "$INSTANCE_ID" else echo "Instance $INSTANCE_ID does not exist" exit 1 fi ``` -------------------------------- ### Setting Default Zone in Virak CLI Configuration Source: https://github.com/virak-cloud/cli/blob/master/docs/zones.md Example configuration snippet showing how to set a default zone in the Virak CLI configuration file. This default zone is used by commands when the --zoneId flag is omitted. ```yaml default: zoneId: "zone-xyz" zoneName: "Tehran-1" ``` -------------------------------- ### Kubernetes Cluster Resources (CLI) Source: https://context7.com/virak-cloud/cli/llms.txt CLI commands to list available Kubernetes versions, service offerings, and view cluster service events. ```bash # List available Kubernetes versions virak-cli cluster versions list --zoneId "01HXXX..." # List service offerings for Kubernetes virak-cli cluster service-offering list --zoneId "01HXXX..." # View cluster service events virak-cli cluster service events --zoneId "01HXXX..." ``` -------------------------------- ### Build Virak CLI Binary with Go Source: https://github.com/virak-cloud/cli/blob/master/README.md This command compiles the Go source files into an executable binary named 'virak-cli'. It's a fundamental step for building the CLI application. ```sh go build -o virak-cli main.go ``` -------------------------------- ### Manage Cloud Zones with Virak CLI Source: https://context7.com/virak-cloud/cli/llms.txt Commands for listing zones and inspecting zone-specific resources including networks, resources, and services. Requires zoneId parameter for detailed queries. Provides visibility into multi-region deployments and available infrastructure. ```bash # List available zones virak-cli zone list # View zone networks virak-cli zone networks --zoneId "01HXXX..." # View zone resources virak-cli zone resources --zoneId "01HXXX..." # View zone services virak-cli zone services --zoneId "01HXXX..." ``` -------------------------------- ### Emptying a Stuck S3 Bucket Recursively Source: https://github.com/virak-cloud/cli/blob/master/docs/buckets.md Use the AWS CLI to recursively remove all objects from an S3 bucket. This is a common solution when a bucket deletion operation gets stuck. Ensure you replace 's3://bucket' with your actual bucket path and provide the correct '--endpoint-url'. ```bash aws s3 rm s3://bucket --recursive --endpoint-url ... ``` -------------------------------- ### List Volume Service Offerings with Virak CLI Source: https://github.com/virak-cloud/cli/blob/master/docs/instances.md Lists available volume service offerings, which is useful for understanding performance tiers and pricing. Requires a zone ID as input. ```bash virak-cli instance volume service-offering-list --zoneId zone-xyz ``` -------------------------------- ### Static Website Hosting Workflow with Virak CLI and AWS CLI Source: https://github.com/virak-cloud/cli/blob/master/docs/buckets.md Set up static website hosting on Virak Cloud. This involves creating a public bucket with Virak CLI, syncing website files using AWS CLI, and configuring website hosting properties. A subsequent DNS configuration is required to point a domain to the bucket. ```shell 1. virak-cli bucket create --policy Public --zoneId zone-xyz 2. aws s3 sync ./build s3://my-site/ --endpoint-url https://s3.virakcloud.com 3. aws s3 website s3://my-site/ --index-document index.html --error-document 404.html --endpoint-url https://s3.virakcloud.com 4. Use the DNS guide to point www.example.com at the bucket endpoint. ``` -------------------------------- ### Network Instance Connections (CLI) Source: https://context7.com/virak-cloud/cli/llms.txt CLI commands to manage instance connections to networks, including connecting, listing instances within a network, and disconnecting instances. ```bash # Connect instance to network virak-cli network instance connect \ --zoneId "01HXXX..." \ --network-id "01HNNN..." \ --instance-id "01HAAAA..." # List instances in network virak-cli network instance list \ --zoneId "01HXXX..." \ --network-id "01HNNN..." # Disconnect instance from network virak-cli network instance disconnect \ --zoneId "01HXXX..." \ --network-id "01HNNN..." \ --instance-id "01HAAAA..." ``` -------------------------------- ### Manage Kubernetes Cluster Lifecycle with Virak CLI Source: https://github.com/virak-cloud/cli/blob/master/docs/kubernetes.md Perform essential lifecycle operations on your Kubernetes clusters using the Virak CLI. This includes starting, stopping, deleting, updating metadata like name and description, and scaling clusters. Autoscaling can be enabled or disabled, with options to set minimum and maximum cluster sizes. ```shell virak-cli cluster start --zoneId zone-xyz --clusterId clu-01HF... virak-cli cluster stop --zoneId zone-xyz --clusterId clu-01HF... virak-cli cluster delete --zoneId zone-xyz --clusterId clu-01HF... virak-cli cluster update \ --zoneId zone-xyz \ --clusterId clu-01HF... \ --name "prod-gke-v2" \ --description "Renamed to match project" virak-cli cluster scale \ --zoneId zone-xyz \ --clusterId clu-01HF... \ --auto-scaling \ --min-cluster-size 3 \ --max-cluster-size 10 ``` -------------------------------- ### Show Instance Details (Shell) Source: https://github.com/virak-cloud/cli/blob/master/docs/instances.md Retrieves detailed metadata for a specific instance, identified by its instance ID and zone. This command provides comprehensive information about a single instance, useful for inspection and troubleshooting. ```sh virak-cli instance show --instanceId inst-abc123 --zoneId zone-xyz ``` -------------------------------- ### Deploy Infrastructure with Jenkins Pipeline Source: https://github.com/virak-cloud/cli/blob/master/docs/overview.md This Jenkins pipeline script shows how to deploy infrastructure using the Virak CLI. It configures the necessary environment variable using Jenkins credentials and then executes the CLI command to create an instance. ```groovy pipeline { agent any environment { VIRAK_CLI_TOKEN = credentials('virak-cli-token') } stages { stage('Deploy') { steps { sh ''' virak-cli instance create \ --name "jenkins-${BUILD_NUMBER}" \ --service-offering-id "so-app" \ --vm-image-id "img-centos" \ --network-ids '["net-dev"]' ''' } } } } ``` -------------------------------- ### Create Networks (CLI) Source: https://context7.com/virak-cloud/cli/llms.txt CLI commands to create L3 networks with VPC capabilities and L2 networks. Requires zone ID, name, and service offering ID for L3, and VLAN for L2. ```bash # Create L3 network with VPC capabilities virak-cli network create l3 \ --zoneId "01HXXX..." \ --name "production-vpc" \ --service-offering-id "01HNSO..." \ --gateway "10.0.0.1" \ --netmask "255.255.255.0" # Create L2 network virak-cli network create l2 \ --zoneId "01HXXX..." \ --name "isolated-network" \ --vlan 100 ``` -------------------------------- ### Manage Networks (CLI) Source: https://context7.com/virak-cloud/cli/llms.txt CLI commands for network operations: listing networks, showing details, deleting networks, and listing network service offerings. ```bash # List networks virak-cli network list --zoneId "01HXXX..." # Show network details virak-cli network show --zoneId "01HXXX..." --id "01HNNN..." # Delete network virak-cli network delete --zoneId "01HXXX..." --id "01HNNN..." # List network service offerings virak-cli network service-offering list --zoneId "01HXXX..." ``` -------------------------------- ### Code Quality Tools for Go Projects Source: https://github.com/virak-cloud/cli/blob/master/README.md These commands are used to maintain code quality in Go projects. They format the code, organize imports, check for style issues, and detect potential bugs. ```sh gofmt -w . goimports -w . golint ./... go vet ./... ``` -------------------------------- ### List VM Images (Shell) Source: https://github.com/virak-cloud/cli/blob/master/docs/instances.md Fetches a list of available virtual machine images within a specified zone. This command provides details such as OS name, version, category, and availability, allowing you to match the images available in the Virak Cloud panel. ```sh virak-cli instance vm-image-list --zoneId zone-xyz ``` -------------------------------- ### Perform DNS Domain Operations with Virak CLI (Bash) Source: https://context7.com/virak-cloud/cli/llms.txt Commands to create, list, show details, delete domains, and view events in Virak DNS. Inputs require domain names; outputs include domain info or event logs. No external dependencies beyond virak-cli; deletions are irreversible. ```bash # Create domain virak-cli dns domain create --domain "example.com" # List domains virak-cli dns domain list # Show domain details virak-cli dns domain show --domain "example.com" # Delete domain virak-cli dns domain delete --domain "example.com" # View DNS events virak-cli dns events ``` -------------------------------- ### Manage Object Storage Buckets with Virak CLI (Bash) Source: https://context7.com/virak-cloud/cli/llms.txt Commands for creating, listing, showing, updating policies, deleting buckets, and viewing events in Virak Object Storage. Inputs include zone ID, bucket name, and policy (Private/Public). Outputs bucket details or events; requires storage permissions, public policy enables web access. ```bash # Create bucket with private access virak-cli bucket create \ --zoneId "01HXXX..." \ --name "my-app-storage" \ --policy "Private" # Create bucket with public access virak-cli bucket create \ --zoneId "01HXXX..." \ --name "public-assets" \ --policy "Public" # List buckets virak-cli bucket list --zoneId "01HXXX..." # Show bucket details virak-cli bucket show \ --zoneId "01HXXX..." \ --name "my-app-storage" # Update bucket policy virak-cli bucket update \ --zoneId "01HXXX..." \ --name "my-app-storage" \ --policy "Public" # Delete bucket virak-cli bucket delete \ --zoneId "01HXXX..." \ --name "my-app-storage" # View bucket events virak-cli bucket events --zoneId "01HXXX..." ``` -------------------------------- ### Create Instance Non-interactively (Shell) Source: https://github.com/virak-cloud/cli/blob/master/docs/instances.md Creates a new instance using specified parameters such as name, service offering ID, VM image ID, and network IDs. This non-interactive workflow is suitable for scripting repeatable infrastructure deployments. Flags must correspond to the struct tags in `cmd/instance/instance_create.go`. ```sh virak-cli instance create \ --zoneId zone-xyz \ --name "app-01" \ --service-offering-id "so-highcpu" \ --vm-image-id "img-ubuntu-22" \ --network-ids '["net-public","net-private"]' ``` -------------------------------- ### Manage Network Inventory and Connections with Virak CLI Source: https://github.com/virak-cloud/cli/blob/master/docs/networks.md List, show, and manage network instances and their connections. Commands include listing all networks, showing a specific network, listing instances within a network, connecting instances to networks, and disconnecting them. Also includes deleting networks. ```shell virak-cli network list --zoneId zone-xyz virak-cli network show --zoneId zone-xyz --networkId net-abc123 virak-cli network instance list --zoneId zone-xyz --networkId net-abc123 virak-cli network instance connect \ --zoneId zone-xyz \ --networkId net-abc123 \ --instanceId inst-01HF... virak-cli network instance disconnect \ --zoneId zone-xyz \ --networkId net-abc123 \ --instanceId inst-01HF... virak-cli network delete --zoneId zone-xyz --networkId net-abc123 ``` -------------------------------- ### Implement Retry Logic for Instance Creation in Bash Source: https://github.com/virak-cloud/cli/blob/master/docs/overview.md This bash script implements a retry mechanism for creating a Virak CLI instance. The `create_instance_with_retry` function attempts creation multiple times with a delay between attempts, providing a fallback if the operation fails after the maximum retries. ```bash # Retry instance creation with backoff create_instance_with_retry() { local max_attempts=3 local attempt=1 while [ $attempt -le $max_attempts ]; do echo "Attempt $attempt of $max_attempts" if virak-cli instance create --name "test-instance" --service-offering-id "so-123" --vm-image-id "img-456" --network-ids '["net-789"]'; then echo "Instance created successfully" return 0 else echo "Creation failed, retrying in $((attempt * 10)) seconds..." sleep $((attempt * 10)) ((attempt++)) fi done echo "Failed to create instance after $max_attempts attempts" return 1 } ``` -------------------------------- ### Manage Volumes with Virak CLI Source: https://github.com/virak-cloud/cli/blob/master/docs/instances.md Provides commands to create, attach, detach, and delete volumes. These operations require specifying zone ID, service offering ID, size, name, volume ID, and instance ID as applicable. Interactive prompts can assist with ID retrieval. ```bash virak-cli instance volume create \ --zoneId zone-xyz \ --serviceOfferingId vol-tier1 \ --size 100 \ --name "db-data" ``` ```bash virak-cli instance volume attach \ --zoneId zone-xyz \ --volumeId vol-01HF... \ --instanceId inst-abc123 ``` ```bash virak-cli instance volume detach \ --zoneId zone-xyz \ --volumeId vol-01HF... \ --instanceId inst-abc123 ``` ```bash virak-cli instance volume delete \ --zoneId zone-xyz \ --volumeId vol-01HF... ``` -------------------------------- ### Configure VPN with Virak CLI (Bash) Source: https://context7.com/virak-cloud/cli/llms.txt Commands for viewing, enabling, updating, and disabling VPN configurations in Virak Cloud networks. Inputs include zone ID, network ID, and preshared key for updates. Outputs display configuration details or status; requires network admin access and may involve downtime during enable/disable. ```bash # Show VPN configuration virak-cli network vpn show \ --zoneId "01HXXX..." \ --network-id "01HNNN..." # Enable VPN virak-cli network vpn enable \ --zoneId "01HXXX..." \ --network-id "01HNNN..." # Update VPN settings virak-cli network vpn update \ --zoneId "01HXXX..." \ --network-id "01HNNN..." \ --preshared-key "your-psk" # Disable VPN virak-cli network vpn disable \ --zoneId "01HXXX..." \ --network-id "01HNNN..." ``` -------------------------------- ### Discover Kubernetes Cluster Versions and Offerings with Virak CLI Source: https://github.com/virak-cloud/cli/blob/master/docs/kubernetes.md Use these Virak CLI commands to discover available Kubernetes versions and node offerings within a specified zone. These commands are essential for gathering IDs required for cluster creation, scaling, and update operations. The output format aligns with the 'Kubernetes Versions' and 'Node Profiles' tables in the official Virak Cloud documentation. ```shell virak-cli cluster versions-list --zoneId zone-xyz virak-cli cluster offering --zoneId zone-xyz virak-cli user ssh-key list virak-cli network list --zoneId zone-xyz ``` -------------------------------- ### Firewall Rules Management (CLI) Source: https://context7.com/virak-cloud/cli/llms.txt CLI commands for managing IPv4 and IPv6 firewall rules, including creating, listing, and deleting rules. Requires zone, network, protocol, ports, and CIDR information. ```bash # Create IPv4 firewall rule virak-cli network firewall ipv4 create \ --zoneId "01HXXX..." \ --network-id "01HNNN..." \ --protocol "tcp" \ --start-port 443 \ --end-port 443 \ --cidr "0.0.0.0/0" # List IPv4 firewall rules virak-cli network firewall ipv4 list \ --zoneId "01HXXX..." \ --network-id "01HNNN..." # Delete IPv4 firewall rule virak-cli network firewall ipv4 delete \ --zoneId "01HXXX..." \ --network-id "01HNNN..." \ --rule-id "01HFFFF..." # Create IPv6 firewall rule virak-cli network firewall ipv6 create \ --zoneId "01HXXX..." \ --network-id "01HNNN..." \ --protocol "tcp" \ --start-port 443 \ --end-port 443 \ --cidr "::/0" # List IPv6 firewall rules virak-cli network firewall ipv6 list \ --zoneId "01HXXX..." \ --network-id "01HNNN..." # Delete IPv6 firewall rule virak-cli network firewall ipv6 delete \ --zoneId "01HXXX..." \ --network-id "01HNNN..." \ --rule-id "01HFFFF..." ``` -------------------------------- ### Create Kubernetes Cluster (CLI) Source: https://context7.com/virak-cloud/cli/llms.txt Command to create a new Kubernetes cluster using the Virak CLI. Requires zone, name, version, offering, SSH key, network IDs, size, and HA configuration. ```bash virak-cli cluster create \ --zoneId "01HXXX..." \ --name "production-cluster" \ --versionId "01HKKKK..." \ --offeringId "01HOOO..." \ --sshKeyId "01HSSS..." \ --networkId "01HNNN..." \ --size 3 \ --ha \ --haControllerNodes 3 \ --description "Production Kubernetes cluster" ``` -------------------------------- ### Discover Network Service Offerings with Virak CLI Source: https://github.com/virak-cloud/cli/blob/master/docs/networks.md Discover available network service offerings for a specific zone. This command retrieves details like bandwidth limits, transfer plans, and pricing. Requires an authenticated CLI session and a configured zone. ```shell virak-cli network service-offering \ --type all \ --zoneId zone-xyz ``` -------------------------------- ### Manage Load Balancers with Virak CLI (Bash) Source: https://context7.com/virak-cloud/cli/llms.txt Operations for listing, creating, assigning/deassigning instances, deleting rules, and viewing HAProxy stats/logs in Virak Cloud. Inputs include zone ID, network ID, rule details, ports, and instance IDs. Outputs resource lists or stats; supports TCP/UDP protocols but limited to round-robin algorithm. ```bash # List load balancer rules virak-cli network lb list \ --zoneId "01HXXX..." \ --network-id "01HNNN..." # Create load balancer rule virak-cli network lb create \ --zoneId "01HXXX..." \ --network-id "01HNNN..." \ --name "web-lb" \ --algorithm "roundrobin" \ --protocol "tcp" \ --public-port 80 \ --private-port 8080 # Assign instance to load balancer virak-cli network lb assign \ --zoneId "01HXXX..." \ --network-id "01HNNN..." \ --rule-id "01HLLL..." \ --instance-id "01HAAAA..." # Deassign instance from load balancer virak-cli network lb deassign \ --zoneId "01HXXX..." \ --network-id "01HNNN..." \ --rule-id "01HLLL..." \ --instance-id "01HAAAA..." # Delete load balancer rule virak-cli network lb delete \ --zoneId "01HXXX..." \ --network-id "01HNNN..." \ --rule-id "01HLLL..." # View live HAProxy statistics virak-cli network lb haproxy live \ --zoneId "01HXXX..." \ --network-id "01HNNN..." # View HAProxy logs virak-cli network lb haproxy log \ --zoneId "01HXXX..." \ --network-id "01HNNN..." ``` -------------------------------- ### List Active Services in a Zone with Virak CLI Source: https://github.com/virak-cloud/cli/blob/master/docs/zones.md Displays the availability of different service families (Instances, DataVolume, Network, ObjectStorage, Kubernetes) within a zone. This helps in determining if specific features are enabled before creating resources. ```shell virak-cli zone services \ --zoneId zone-xyz ``` -------------------------------- ### CLI Configuration File Structure Source: https://context7.com/virak-cloud/cli/llms.txt Defines the YAML configuration file format stored at ~/.virak-cli.yaml. Contains authentication tokens and default zone settings. This file is automatically generated during login and can be manually edited for advanced configuration. ```text ``` -------------------------------- ### Port Forwarding Management (CLI) Source: https://context7.com/virak-cloud/cli/llms.txt CLI commands for managing port forwarding rules, including creating, listing, and deleting rules. Requires zone, network, protocol, public/private ports, and private IP. ```bash # Create port forwarding rule virak-cli network port-forward create \ --zoneId "01HXXX..." \ --networkId "01HNNN..." \ --protocol "TCP" \ --publicPort 8080 \ --privatePort 80 \ --privateIp "10.0.0.5" # List port forwarding rules virak-cli network port-forward list \ --zoneId "01HXXX..." \ --networkId "01HNNN..." # Delete port forwarding rule virak-cli network port-forward delete \ --zoneId "01HXXX..." \ --networkId "01HNNN..." \ --id "01HPFPF..." ``` -------------------------------- ### Access Instance Console with Virak CLI Source: https://github.com/virak-cloud/cli/blob/master/docs/instances.md Generates a signed URL for the VNC viewer, which is useful when SSH access is unavailable. Requires the instance ID and zone ID. ```bash virak-cli instance console --instanceId inst-abc123 --zoneId zone-xyz ``` -------------------------------- ### Manage Load Balancers with Virak CLI Source: https://github.com/virak-cloud/cli/blob/master/docs/networks.md List, create, and manage load balancer rules for a network. Commands include listing existing LBs, creating new ones specifying public IP, ports, and algorithm, and assigning instances to load balancer rules. Also includes monitoring HAProxy stats and logs. ```shell virak-cli network lb list --zoneId zone-xyz virak-cli network lb create \ --zoneId zone-xyz \ --networkId net-abc123 \ --publicIpId pip-01HF... \ --name "frontend" \ --algorithm roundrobin \ --publicPort 80 \ --privatePort 8080 virak-cli network lb assign \ --zoneId zone-xyz \ --networkId net-abc123 \ --ruleId lbr-01HF... \ --instanceNetworkIds instnet-1,instnet-2 virak-cli network lb haproxy live \ --zoneId zone-xyz \ --networkId net-abc123 \ --ruleId lbr-01HF... virak-cli network lb haproxy log \ --zoneId zone-xyz \ --networkId net-abc123 \ --ruleId lbr-01HF... ``` -------------------------------- ### Manage DNS Records with Virak CLI (Bash) Source: https://context7.com/virak-cloud/cli/llms.txt Create, list, update, and delete A, CNAME, MX records with TTL and priority options in Virak DNS. Inputs specify domain, name, type, content; updates need old content for identification. Outputs record details; supports standard record types but limited propagation times. ```bash # Create A record virak-cli dns record create \ --domain "example.com" \ --name "www" \ --type "A" \ --content "192.0.2.1" \ --ttl 3600 # Create CNAME record virak-cli dns record create \ --domain "example.com" \ --name "blog" \ --type "CNAME" \ --content "www.example.com" \ --ttl 3600 # Create MX record virak-cli dns record create \ --domain "example.com" \ --name "@" \ --type "MX" \ --content "mail.example.com" \ --ttl 3600 \ --priority 10 # List DNS records virak-cli dns record list --domain "example.com" # Update DNS record virak-cli dns record update \ --domain "example.com" \ --name "www" \ --type "A" \ --old-content "192.0.2.1" \ --content "192.0.2.2" # Delete DNS record virak-cli dns record delete \ --domain "example.com" \ --name "www" \ --type "A" \ --content "192.0.2.1" ``` -------------------------------- ### Handle User Management with Virak CLI (Bash) Source: https://context7.com/virak-cloud/cli/llms.txt Commands for viewing user profiles, managing SSH keys (create/list/delete), and token operations (abilities/validate) in Virak Cloud. Inputs include key names and public keys. Outputs profile info, key lists, or validation status; requires user authentication, SSH keys must be valid RSA/ED25519. ```bash # View user profile information virak-cli user profile # Create SSH key virak-cli user ssh-key create \ --name "my-workstation" \ --public-key "ssh-rsa AAAAB3NzaC1yc2EA..." # List SSH keys virak-cli user ssh-key list # Delete SSH key virak-cli user ssh-key delete --name "my-workstation" # List token abilities and permissions virak-cli user token abilities # Validate current token virak-cli user token validate ``` -------------------------------- ### Cleanup Old Instances with Bash Scripting Source: https://github.com/virak-cloud/cli/blob/master/docs/overview.md This bash script provides a cleanup mechanism for old instances. It lists all instances, filters them based on their creation date (older than 7 days), and then deletes the identified instances using the Virak CLI. ```bash # Cleanup old instances virak-cli instance list --output json | jq -r '.data[] | select(.created_at < "'$(date -d '7 days ago' +%Y-%m-%d)'") | .id' | while read -r id; echo "Deleting old instance: $id" virak-cli instance delete "$id" done ``` -------------------------------- ### Instance Snapshot Management (Shell) Source: https://github.com/virak-cloud/cli/blob/master/docs/instances.md Manages snapshots for instances, including creating, listing, reverting, and deleting them. These operations are crucial for data backup and recovery. Interactive mode is available for `list`, `create`, and `revert`. The CLI prevents reverting a snapshot that is in `WAITING` state. ```sh virak-cli instance snapshot create \ --instanceId inst-abc123 \ --name "pre-release-2024-11" \ --zoneId zone-xyz virak-cli instance snapshot list --instanceId inst-abc123 --zoneId zone-xyz virak-cli instance snapshot revert \ --instanceId inst-abc123 \ --snapshotId snap-01HF... \ --zoneId zone-xyz virak-cli instance snapshot delete \ --instanceId inst-abc123 \ --snapshotId snap-01HF... \ --zoneId zone-xyz ``` -------------------------------- ### Check Available Resources in a Zone with Virak CLI Source: https://github.com/virak-cloud/cli/blob/master/docs/zones.md Retrieves metrics on memory, CPU cores, data volume, and VM limits for a customer within a specific zone. This mirrors Virak panel capacity widgets and aids in preflight automation checks. ```shell virak-cli zone resources \ --zoneId zone-xyz ``` -------------------------------- ### Create a Kubernetes Cluster with Virak CLI Source: https://github.com/virak-cloud/cli/blob/master/docs/kubernetes.md This command creates a new Kubernetes cluster with specified configurations, including zone, name, version, offering, SSH key, network, size, high availability, and an optional description. It also supports configuring private container registry credentials for pulling private images. ```shell virak-cli cluster create \ --zoneId zone-xyz \ --name "prod-gke" \ --versionId ver-1-29 \ --offeringId so-highcpu \ --sshKeyId ssh-01HF... \ --networkId net-l3-prod \ --size 5 \ --ha \ --description "Production workload" \ --privateRegistryUsername "ghcr-user" \ --privateRegistryPassword "token" \ --privateRegistryUrl "ghcr.io/org" ```