### Configure upctl installation with aqua Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Example aqua.yaml configuration to install upctl. Ensure aqua is installed and configured. ```yaml registries: - type: standard packages: - name: UpCloudLtd/upcloud-cli@{{ latest_release }} ``` -------------------------------- ### Install upctl using go install Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Install the latest version of upctl using the go install command. Ensure you have a recent enough Go version installed. ```shell go install github.com/UpCloudLtd/upcloud-cli/v3/...@latest ``` -------------------------------- ### Install mdtest Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/README.md Install the mdtest tool, which is used to validate the examples in this directory. This command uses go install to fetch the latest version. ```sh go install github.com/UpCloudLtd/mdtest@latest ``` -------------------------------- ### Run Chart-Testing Install Source: https://github.com/upcloudltd/upcloud-cli/blob/main/internal/commands/stack/supabase/charts/supabase/README.md Execute the `ct install` command using a Docker container to install Supabase charts. This requires Docker, a Kubernetes environment, and access to the kubeconfig. ```shell # Run chart-testing (install) docker run -it \ --network host \ --workdir=/data \ --volume ~/.kube/config:/root/.kube/config:ro \ --volume $(pwd)/charts/supabase:/data \ quay.io/helmpack/chart-testing:v3.7.1 \ ct install --chart-dirs . --charts . ``` -------------------------------- ### Install upctl on Debian/Ubuntu Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Download the .deb package from GitHub releases and install it using apt. ```shell curl -Lo upcloud-cli_{{ latest_release }}_amd64.deb https://github.com/UpCloudLtd/upcloud-cli/releases/download/v{{ latest_release }}/upcloud-cli_{{ latest_release }}_amd64.deb # Preferably verify the asset before proceeding with install, see "Verify assets" below sudo apt install ./upcloud-cli_{{ latest_release }}_amd64.deb ``` -------------------------------- ### Install upctl with mise Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Install upctl using the mise version manager. Use the -g flag for a global installation. ```shell mise use upctl # or with -g for global ``` -------------------------------- ### Install upctl on RHEL-based distributions Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Download the .rpm package from GitHub releases and install it using dnf. ```shell curl -Lo upcloud-cli-{{ latest_release }}-1.x86_64.rpm https://github.com/UpCloudLtd/upcloud-cli/releases/download/v{{ latest_release }}/upcloud-cli-{{ latest_release }}-1.x86_64.rpm # Preferably verify the asset before proceeding with install, see "Verify assets" below sudo dnf install ./upcloud-cli-{{ latest_release }}-1.x86_64.rpm ``` -------------------------------- ### Install upctl from AUR Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Install upctl from the Arch User Repository using yay. ```shell yay -S upcloud-cli ``` -------------------------------- ### Install Supabase Helm Chart Source: https://github.com/upcloudltd/upcloud-cli/blob/main/internal/commands/stack/supabase/charts/supabase/README.md Clone the repository, navigate to the charts directory, and install the Supabase Helm chart using a custom values file. ```bash # Clone Repository git clone https://github.com/supabase-community/supabase-kubernetes # Switch to charts directory cd supabase-kubernetes/charts/supabase/ # Install the chart helm install demo -f values.example.yaml . ``` -------------------------------- ### Install upctl on macOS using Homebrew Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Tap the UpCloudLtd repository and install upctl using brew. ```shell brew tap UpCloudLtd/tap brew install upcloud-cli ``` -------------------------------- ### Verify upctl installation Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Run the 'upctl version' command to confirm that the installation was successful. ```shell upctl version ``` -------------------------------- ### Create Source Server Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_a_custom_template.md Provision a server that will be used as the source for the custom template. It includes network configuration and SSH key setup. ```sh upctl server create \ --hostname ${prefix}source-server \ --zone ${zone} \ --ssh-keys ./id_ed25519.pub \ --network type=public \ --network type=utility \ --wait ``` -------------------------------- ### Clone Repository and Install Pre-commit Hooks Source: https://github.com/upcloudltd/upcloud-cli/blob/main/README.md Clone the UpCloud CLI repository and install pre-commit hooks to ensure code quality before committing. ```bash git clone git@github.com/username/upcloud-cli.git cd upcloud-cli pre-commit install ``` -------------------------------- ### Install Bash-Completion on Ubuntu/Debian Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Install the bash-completion package on Ubuntu or Debian-based systems using the apt package manager. ```sh sudo apt install bash-completion ``` -------------------------------- ### Piping Migration Scripts to Clipboard Source: https://github.com/upcloudltd/upcloud-cli/blob/main/internal/commands/stack/supabase/charts/supabase/README.md Example of how to use the bash script to pipe migration file content directly to the system clipboard using `xclip`. ```shell # Using xclip as an example ./script.sh supabase/migrations | xclip -sel clipboard ``` -------------------------------- ### Cleanup Resources Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/possible_exit_codes.md Deletes the created servers and their associated storages to clean up resources after the example. ```sh upctl server delete ${prefix}vm-1 ${prefix}vm-2 --delete-storages ``` -------------------------------- ### Install Bash-Completion on RHEL/Fedora Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Install the bash-completion package on RHEL or Fedora-based systems using the dnf package manager. ```sh sudo dnf install bash-completion ``` -------------------------------- ### Install Bash-Completion on macOS Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Install bash-completion using Homebrew on macOS and add the command to source completions to your .bash_profile. ```sh brew install bash-completion echo '[ -f "$(brew --prefix)/etc/bash_completion" ] && . "$(brew --prefix)/etc/bash_completion"' >> ~/.bash_profile ``` -------------------------------- ### Set Environment Variables for Example Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/possible_exit_codes.md Sets the prefix for resource names and the zone for operations. ```env prefix=example-upctl-exit-codes- zone=pl-waw1 ``` -------------------------------- ### Run mdtest to test examples Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/README.md Execute the mdtest command to test all examples within the current directory. This command parses and runs 'env' and 'sh' code blocks found in markdown files. ```sh mdtest . ``` -------------------------------- ### Show Account Information Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Run this command to verify API access and display your current UpCloud account balance and resource limits. For more detailed usage, refer to the Examples and Commands reference sections. ```sh upctl account show ``` -------------------------------- ### User-Data Script for Podman and Hello Container Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/use_userdata_to_configure_server.md A shell script to update package lists, install podman, and run a hello-container accessible on port 80. ```sh #!/bin/sh sudo apt-get update sudo apt-get install -y podman podman run -d -p 80:80 ghcr.io/upcloudltd/hello ``` -------------------------------- ### Configure Nginx Server Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_and_restore_backup.md Installs Nginx and sets custom HTML content on the server. This script is intended to be run remotely via SSH. ```sh #!/bin/sh -xe apt-get update apt-get install nginx -y echo "Hello from $(hostname)"'!' > /var/www/html/index.html ``` -------------------------------- ### Cleanup Created Resources Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/use_userdata_to_configure_server.md Removes all UpCloud resources that were created during the example, identified by the common prefix. ```sh upctl all purge -i ${prefix}* ``` -------------------------------- ### Supabase Ingress Controller Configuration Source: https://github.com/upcloudltd/upcloud-cli/blob/main/internal/commands/stack/supabase/charts/supabase/README.md Configure the ingress controller for Supabase, specifying the `className` and annotations. This example uses `nginx`. ```yaml kong: ingress: enabled: 'true' className: "nginx" annotations: nginx.ingress.kubernetes.io/rewrite-target: / ``` -------------------------------- ### Supabase Database Migration Configuration Source: https://github.com/upcloudltd/upcloud-cli/blob/main/internal/commands/stack/supabase/charts/supabase/README.md Apply migration scripts during database initialization by adding them to the `db.config` field. This example shows a `profiles` table migration. ```yaml db: config: 20230101000000_profiles.sql: | create table profiles ( id uuid references auth.users not null, updated_at timestamp with time zone, username text unique, avatar_url text, website text, primary key (id), unique(username), constraint username_length check (char_length(username) >= 3) ); ``` -------------------------------- ### Check Supabase Pod Status Source: https://github.com/upcloudltd/upcloud-cli/blob/main/internal/commands/stack/supabase/charts/supabase/README.md View the status of Supabase pods after installation to ensure all components are running correctly. ```bash kubectl get pod -l app.kubernetes.io/instance=demo NAME READY STATUS RESTARTS AGE demo-supabase-analytics-xxxxxxxxxx-xxxxx 1/1 Running 0 47s demo-supabase-auth-xxxxxxxxxx-xxxxx 1/1 Running 0 47s demo-supabase-db-xxxxxxxxxx-xxxxx 1/1 Running 0 47s demo-supabase-functions-xxxxxxxxxx-xxxxx 1/1 Running 0 47s demo-supabase-imgproxy-xxxxxxxxxx-xxxxx 1/1 Running 0 47s demo-supabase-kong-xxxxxxxxxx-xxxxx 1/1 Running 0 47s demo-supabase-meta-xxxxxxxxxx-xxxxx 1/1 Running 0 47s demo-supabase-realtime-xxxxxxxxxx-xxxxx 1/1 Running 0 47s demo-supabase-rest-xxxxxxxxxx-xxxxx 1/1 Running 0 47s demo-supabase-storage-xxxxxxxxxx-xxxxx 1/1 Running 0 47s ``` -------------------------------- ### Get Storage UUID Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_a_custom_template.md Retrieve the UUID of the server's OS storage disk using `upctl show` and `jq`. ```sh upctl server show ${prefix}source-server -o json \ | jq -r ".storage[0].uuid" ``` -------------------------------- ### Clean Up Resources Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_cluster_and_expose_service.md Deletes the exposed service and purges all created UpCloud resources that match the defined prefix. This command ensures a clean state after the example. ```sh kubectl delete service hello-uks upctl all purge --include "*${prefix}*"; ``` -------------------------------- ### Attach Policy to Grant User Bucket Access Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/use_object_storage.md Attach a policy to a user to grant them access to buckets within the object storage service. 'ECSS3FullAccess' is used here as an example policy. ```sh upctl object-storage user policy attach ${prefix}service --username ${prefix}user --policy ECSS3FullAccess ``` -------------------------------- ### Create Source Server Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_and_restore_backup.md Provisions a new server with a public network interface and default settings, waiting for it to become available. ```sh upctl server create \ --hostname ${prefix}source-server \ --zone ${zone} \ --ssh-keys ./id_ed25519.pub \ --network type=public \ --wait ``` -------------------------------- ### Serve MkDocs Documentation Locally Source: https://github.com/upcloudltd/upcloud-cli/blob/main/README.md Builds the documentation using MkDocs and serves it locally. Assumes a static HTTP server is available or uses 'mkdocs serve'. ```sh make docs mkdocs serve ``` -------------------------------- ### Create Server from Template Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_a_custom_template.md Provision a new server using the custom template created earlier. This verifies the template's functionality. ```sh upctl server create \ --hostname ${prefix}server \ --zone ${zone} \ --network type=public \ --network type=utility \ --os ${prefix}template \ --wait ``` -------------------------------- ### Create New Server from Backup Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_and_restore_backup.md Provisions a new server, cloning storage from the previously created backup, and waits for it to be ready. ```sh upctl server create \ --hostname ${prefix}restored-server \ --zone ${zone} \ --ssh-keys ./id_ed25519.pub \ --network type=public \ --storage action=clone,storage=${prefix}source-server-backup \ --wait ``` -------------------------------- ### Build and Test CLI Source: https://github.com/upcloudltd/upcloud-cli/blob/main/README.md Builds and tests the UpCloud CLI tool. Use 'make help' for a list of available make targets. ```sh make help ``` -------------------------------- ### Create Server with User-Data Configuration Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/use_userdata_to_configure_server.md Creates a new UpCloud server using upctl, specifying plan, SSH keys, network, and executing the user-data script for initial configuration. The --wait flag ensures the command blocks until the server is ready. ```sh # Create ssh-key into current working directory ssh-keygen -t ed25519 -q -f "./id_ed25519" -N "" upctl server create \ --hostname ${prefix}server \ --zone ${zone} \ --plan "DEV-1xCPU-1GB-10GB" \ --ssh-keys ./id_ed25519.pub \ --network type=public \ --user-data "$(cat user-data.sh)" \ --wait; ``` -------------------------------- ### Create Branch, Commit, and Push Changes Source: https://github.com/upcloudltd/upcloud-cli/blob/main/README.md Create a new branch for your changes, commit your modifications with a descriptive message, and push the branch to your fork. ```bash git checkout -b git commit -m "New feature: create a new server in the nearest zone if not specified" git push --set-upstream ``` -------------------------------- ### Configure Upctl Bash Completions (System-wide) Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Configure upctl bash completions system-wide by creating a completion file in /usr/share/bash-completion/completions/ for bash-completion versions older than 2.12. ```sh # Either system wide: printf "%s\n" 'eval -- "$("$1" completion bash 2>/dev/null)"' > /usr/share/bash-completion/completions/upctl ``` -------------------------------- ### Create Deployment and Expose Service Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_cluster_and_expose_service.md Creates a Kubernetes deployment named 'hello-uks' using a specified container image and exposes it as a service. The service type is determined by the `svc_type` variable. ```sh kubectl create deployment --image=ghcr.io/upcloudltd/hello hello-uks kubectl expose deployment hello-uks --port=80 --target-port=80 --type=$svc_type ``` -------------------------------- ### Create Server Backup Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_and_restore_backup.md Initiates a backup of the OS disk for the specified source server, assigning a title to the backup. ```sh upctl storage backup create ${prefix}source-server-OS --title ${prefix}source-server-backup ``` -------------------------------- ### Download and extract upctl on Windows Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Download the Windows zip archive from GitHub releases and extract the binary. ```powershell Invoke-WebRequest -Uri "https://github.com/UpCloudLtd/upcloud-cli/releases/download/v{{ latest_release }}/upcloud-cli_{{ latest_release }}_windows_x86_64.zip" -OutFile "upcloud-cli_{{ latest_release }}_windows_x86_64.zip" # Preferably verify the asset before proceeding with install, see "Verify assets" below Expand-Archive -Path "upcloud-cli_{{ latest_release }}_windows_x86_64.zip" # Print current location Get-Location ``` -------------------------------- ### Display Upctl Completion Help Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Display help information for the `upctl completion` command to list supported shells. ```sh upctl completion --help ``` -------------------------------- ### Cleanup Resources Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_a_custom_template.md Stop and delete the newly created server and delete the custom template to clean up all created resources. ```sh upctl server stop --type hard --wait ${prefix}server upctl server delete ${prefix}server --delete-storages upctl storage delete ${prefix}template ``` -------------------------------- ### Configure Upctl Bash Completions (Per User) Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Configure upctl bash completions for a specific user by creating a completion file in ~/.local/share/bash-completion/completions/ for bash-completion versions older than 2.12. ```sh # ...or per user: mkdir -p ~/.local/share/bash-completion/completions printf "%s\n" 'eval -- "$("$1" completion bash 2>/dev/null)"' > ~/.local/share/bash-completion/completions/upctl ``` -------------------------------- ### Configure Hosts File for Minikube Access Source: https://github.com/upcloudltd/upcloud-cli/blob/main/internal/commands/stack/supabase/charts/supabase/README.md Add the Minikube IP address to your hosts file to redirect requests for example.com to your Minikube cluster. ```bash # This will redirect request for example.com to the minikube IP example.com ``` -------------------------------- ### Define Server and Zone Variables Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/use_userdata_to_configure_server.md Sets environment variables for resource naming prefix and server zone. ```env prefix=example-upctl-server-userdata- zone=pl-waw1 ``` -------------------------------- ### Verify Release Assets with Checksum Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Verify SHA-256 digests of release assets using the checksums.txt file. Ensure the downloaded assets and checksums.txt are in the current directory. ```sh sha256sum -c --ignore-missing checksums.txt ``` -------------------------------- ### Create a Managed Object Storage Service Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/use_object_storage.md Create a new managed object storage service with a specified name, network configuration, and region. ```sh upctl object-storage create --name ${prefix}service --network type=public,name=${prefix}network,family=IPv4 --region ${region} ``` -------------------------------- ### Verify Release Asset with GitHub CLI Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Use the GitHub CLI to verify release asset attestations. This command requires the path to the downloaded asset and specifies the repository and signer repository. ```sh gh attestation verify \ /path/to/locally/downloaded/upcloud-cli_{{ latest_release }}_linux_x86_64.tar.gz \ --repo UpCloudLtd/upcloud-cli \ --signer-repo UpCloudLtd/workflows ``` -------------------------------- ### Configure Server and Validate Nginx Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_and_restore_backup.md Retrieves the server's public IP, waits for SSH, runs a configuration script, and verifies Nginx response. ```sh # Parse public IP of the server with jq ip=$(upctl server show ${prefix}source-server -o json | jq -r '.networking.interfaces[] | select(.type == "public") | .ip_addresses[0].address') # Wait for a moment for the ssh server to become available sleep 30 # Run the script defined above ssh -i id_ed25519 -o StrictHostKeyChecking=accept-new root@$ip "sh" < configure-nginx.sh # Validate HTTP server response test "$(curl -s $ip)" = 'Hello from example-upctl-backup-source-server!' ``` -------------------------------- ### Create a New Bucket Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/use_object_storage.md Create a new bucket within a specified object storage service. ```sh upctl object-storage bucket create ${prefix}service --name ${prefix}bucket ``` -------------------------------- ### Create and Stop Servers Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/possible_exit_codes.md This sequence of commands creates two servers, stops one, and then attempts to stop both. It's used to illustrate subsequent exit codes related to stopping already stopped resources. ```sh # Create ssh-key into current working directory ssh-keygen -t ed25519 -q -f "./id_ed25519" -N "" upctl server create --hostname ${prefix}vm-1 --zone ${zone} --ssh-keys ./id_ed25519.pub --wait upctl server create --hostname ${prefix}vm-2 --zone ${zone} --ssh-keys ./id_ed25519.pub --wait upctl server stop --type hard ${prefix}vm-1 --wait ``` -------------------------------- ### Define Environment Variables for Cluster Creation Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_cluster_and_expose_service.md Sets up environment variables for resource naming, network configuration, cluster plan, node group details, and service type. These variables are used in subsequent commands. ```env prefix=example-upctl-kubernetes- zone=pl-waw1 # Network cidr=172.30.100.0/24 # Cluster plan=dev-md # Node-group ng_count=1 ng_name=default ng_plan=2xCPU-4GB test_label=upctl-example # Service svc_type=NodePort KUBECONFIG=./kubeconfig.yaml ``` -------------------------------- ### Enable Internal Minio Deployment Source: https://github.com/upcloudltd/upcloud-cli/blob/main/internal/commands/stack/supabase/charts/supabase/README.md Optional configuration to enable an internal Minio deployment for Supabase storage. ```yaml minio: enabled: true ``` -------------------------------- ### Set Environment Variables Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_a_custom_template.md Define variables for resource naming and zone. ```env prefix=example-upctl-custom-template- zone=pl-waw1 ``` -------------------------------- ### Cleanup Resources Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_and_restore_backup.md Deletes the restored server and its storages, then removes the backup storage. ```sh # Delete the restored server and its storages upctl server stop --type hard --wait ${prefix}restored-server upctl server delete ${prefix}restored-server --delete-storages # Delete the backup upctl storage delete ${prefix}source-server-backup ``` -------------------------------- ### Retrieve Server IP and Execute Remote Command via SSH Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_and_ssh_into_a_server.md Fetches the public IP address of the created server using `jq` and then connects to the server via SSH to execute the `hostname` command. Includes a delay to ensure SSH server availability. ```sh # Parse public IP of the server with jq ip=$(upctl server show ${prefix}server -o json | jq -r '.networking.interfaces[] | select(.type == "public") | .ip_addresses[0].address') # Wait for a moment for the ssh server to become available sleep 30 ssh -i id_ed25519 -o StrictHostKeyChecking=accept-new root@$ip "hostname" ``` -------------------------------- ### Set Environment Variables Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_and_ssh_into_a_server.md Define variables for resource naming prefix and zone for UpCloud operations. ```env prefix=example-upctl-ssh-server- zone=pl-waw1 ``` -------------------------------- ### Configure Upctl Bash Completions on macOS Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Configure upctl bash completions on macOS by saving the output of `upctl completion bash` to the appropriate directory and sourcing bash completion. ```sh upctl completion bash > $(brew --prefix)/etc/bash_completion.d/upctl . $(brew --prefix)/etc/bash_completion ``` -------------------------------- ### Create UpCloud Server with SSH Key Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_and_ssh_into_a_server.md Provisions a new UpCloud server using the generated SSH key for login. It configures public and utility network interfaces and waits for the server to be ready. ```sh upctl server create \ --hostname ${prefix}server \ --zone ${zone} \ --ssh-keys ./id_ed25519.pub \ --network type=public \ --network type=utility \ --wait ``` -------------------------------- ### Create User and Access Key for S3 Access Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/use_object_storage.md Create a user for the object storage service and generate an access key for S3-compatible access. The access key ID and secret access key are captured for later use. ```sh upctl object-storage user create ${prefix}service --username ${prefix}user # Create access key and save credentials access_key_output=$(upctl object-storage access-key create ${prefix}service --username ${prefix}user -o json) access_key_id=$(echo "$access_key_output" | jq -r '.access_key_id') secret_access_key=$(echo "$access_key_output" | jq -r '.secret_access_key') ``` -------------------------------- ### Create Custom Template Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_a_custom_template.md Generate a custom template from the server's OS storage. The template is given a title and the operation waits for completion. ```sh upctl storage templatise ${prefix}source-server-OS \ --title ${prefix}template \ --wait ``` -------------------------------- ### List Buckets in an Object Storage Service Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/use_object_storage.md List all buckets within a specified object storage service. This will be empty if no buckets have been created yet. ```sh upctl object-storage bucket list ${prefix}service ``` -------------------------------- ### Enable Bash-Completion in ~/.bashrc Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Manually enable bash-completion by adding a source command to the ~/.bashrc file if it's not automatically enabled by the package. ```sh printf "%s\n" "[[ -f /usr/share/bash-completion/bash-completion ]] && . /usr/share/bash-completion/bash-completion" >> ~/.bashrc ``` -------------------------------- ### Bash Script for Copying Migration Files Source: https://github.com/upcloudltd/upcloud-cli/blob/main/internal/commands/stack/supabase/charts/supabase/README.md A bash script to format migration files for easy copying into the `db.config` field. It reads files from a specified directory and prepares them with proper indentation. ```bash #!/bin/bash for file in $1/*; do clipboard+=" $(basename $file): |\n" clipboard+=$(cat $file | awk '{print " "$0}') clipboard+="\n" done echo -e "$clipboard" ``` -------------------------------- ### Delete Source Server Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_a_custom_template.md Remove the original server and its associated storages after the template has been created. ```sh upctl server delete ${prefix}source-server --delete-storages ``` -------------------------------- ### Generate Markdown Documentation Source: https://github.com/upcloudltd/upcloud-cli/blob/main/README.md Generates a markdown version of the command reference. The output is saved to the 'docs/commands_reference' directory. ```sh make md-docs ``` -------------------------------- ### Move upctl binary to Program Files and update Path on Windows Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Move the extracted upctl.exe to the Program Files directory and add it to the system's Path environment variable. ```powershell # Open the PowerShell with Run as Administrator option. # Use Set-Location to change into folder that you used in previous step. New-Item -ItemType Directory $env:ProgramFiles\upcloud-cli\ -Force Move-Item -Path upcloud-cli_{{ latest_release }}_windows_x86_64\upctl.exe -Destination $env:ProgramFiles\upcloud-cli\ -Force # Setting the Path is required only on first install. # Thus, this step can be skipped when updating to a more recent version. [Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) + ";$env:ProgramFiles\upcloud-cli\", [EnvironmentVariableTarget]::Machine) ``` -------------------------------- ### Create SSH Key Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_a_custom_template.md Generate an SSH key pair for server access. ```sh # Create ssh-key into current working directory ssh-keygen -t ed25519 -q -f "./id_ed25519" -N "" ``` -------------------------------- ### Stop Source Server Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_a_custom_template.md Halt the source server to prepare its disk for templating. A hard stop is used. ```sh upctl server stop --type hard --wait ${prefix}source-server ``` -------------------------------- ### Create a Kubernetes Cluster Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_cluster_and_expose_service.md Provisions a new Kubernetes cluster with specified network, plan, and node group configuration. It allows all IP addresses to access the Kubernetes API and waits for all resources to be ready. ```sh upctl kubernetes create \ --name ${prefix}cluster \ --network ${prefix}net \ --plan $plan \ --zone $zone \ --kubernetes-api-allow-ip "0.0.0.0/0" \ --node-group count=$ng_count,name=$ng_name,plan=$ng_plan,label="test=$test_label" \ --wait=all; ``` -------------------------------- ### Run Chart-Testing Lint Source: https://github.com/upcloudltd/upcloud-cli/blob/main/internal/commands/stack/supabase/charts/supabase/README.md Execute the `ct lint` command using a Docker container to lint Supabase charts. This command validates chart maintainers and chart directories. ```shell # Run chart-testing (lint) docker run -it \ --workdir=/data \ --volume $(pwd)/charts/supabase:/data \ quay.io/helmpack/chart-testing:v3.7.1 \ ct lint --validate-maintainers=false --chart-dirs . --charts . ``` -------------------------------- ### Generate Kubeconfig File Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_cluster_and_expose_service.md Generates and writes the kubeconfig file for the created Kubernetes cluster to a specified path, enabling interaction with the cluster using `kubectl`. ```sh upctl kubernetes config ${prefix}cluster \ --write $KUBECONFIG; ``` -------------------------------- ### Verify S3 Access with AWS CLI Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/use_object_storage.md Configure the AWS CLI with the generated credentials and endpoint to test S3 access to the object storage service. ```sh # Get the service endpoint service_endpoint=$(upctl object-storage show ${prefix}service -o json | jq -r '.endpoints[0].domain_name') # Configure AWS CLI with your credentials and test access AWS_ACCESS_KEY_ID=${access_key_id} \ AWS_SECRET_ACCESS_KEY=${secret_access_key} \ aws s3 ls --endpoint-url https://${service_endpoint} ``` -------------------------------- ### Supabase S3 Storage Environment Variables Source: https://github.com/upcloudltd/upcloud-cli/blob/main/internal/commands/stack/supabase/charts/supabase/README.md Set environment variables to enable S3 for Supabase storage. Configure the storage backend and S3 endpoint if using external object storage. ```yaml storage: environment: # Set S3 endpoint if using external object-storage # GLOBAL_S3_ENDPOINT: http://minio:9000 STORAGE_BACKEND: s3 GLOBAL_S3_PROTOCOL: http GLOBAL_S3_FORCE_PATH_STYLE: true AWS_DEFAULT_REGION: stub ``` -------------------------------- ### Set Environment Variables for Object Storage Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/use_object_storage.md Set environment variables for convenience to define a prefix and region for object storage resources. ```env prefix=example-upctl- region=europe-1 ``` -------------------------------- ### Create a Private Network for the Kubernetes Cluster Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_cluster_and_expose_service.md Creates a private network using `upctl` which will be used by the Kubernetes cluster. It specifies the network name, zone, and IP address range. ```sh upctl network create \ --name ${prefix}net \ --zone $zone \ --ip-network address=$cidr,dhcp=true; ``` -------------------------------- ### Access Service via LoadBalancer Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_cluster_and_expose_service.md Waits for a LoadBalancer service to be provisioned and assigned a public hostname. It then repeatedly attempts to access the service via the hostname until it is reachable. ```sh # Wait for hostname to be available in service status until kubectl get service hello-uks -o json | jq -re .status.loadBalancer.ingress[0].hostname; do sleep 15; done; # Wait until the service is reachable hostname=$(kubectl get service hello-uks -o json | jq -re .status.loadBalancer.ingress[0].hostname) until curl -sSf $hostname; do sleep 15; done; ``` -------------------------------- ### Delete Source Server Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_and_restore_backup.md Stops the source server forcefully and then deletes it along with its associated storages. ```sh upctl server stop --type hard --wait ${prefix}source-server upctl server delete ${prefix}source-server --delete-storages ``` -------------------------------- ### Configure SMTP Secrets in values.yaml Source: https://github.com/upcloudltd/upcloud-cli/blob/main/internal/commands/stack/supabase/charts/supabase/README.md Provide SMTP connection credentials, including username and password, via a Kubernetes secret referenced in values.yaml. ```yaml secret: smtp: username: password: ``` -------------------------------- ### Uninstall Supabase Helm Chart Source: https://github.com/upcloudltd/upcloud-cli/blob/main/internal/commands/stack/supabase/charts/supabase/README.md Uninstall the Helm chart and delete any associated Persistent Volume Claims. ```bash # Uninstall Helm chart helm uninstall demo # Backup and/or remove any Persistent Volume Claims that have keep annotation kubectl delete pvc demo-supabase-storage-pvc ``` -------------------------------- ### Wait for Container Availability with curl Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/use_userdata_to_configure_server.md Retrieves the public IP address of the created server and repeatedly attempts to connect to the exposed container on port 80 using curl until successful. ```sh ip=$(upctl server show ${prefix}server -o json | jq -r '.networking.interfaces[] | select(.type == "public") | .ip_addresses[0].address') until curl -sf http://$ip; do sleep 5; done; ``` -------------------------------- ### Validate Restored Server Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_and_restore_backup.md Retrieves the public IP of the restored server and repeatedly checks if the Nginx server responds with the expected content. ```sh # Parse public IP of the server with jq ip=$(upctl server show ${prefix}restored-server -o json | jq -r '.networking.interfaces[] | select(.type == "public") | .ip_addresses[0].address') # Wait until server returns expected response for i in $(seq 1 9); do test "$(curl -s $ip)" = 'Hello from example-upctl-backup-source-server!' && break || true; sleep 15; done; ``` -------------------------------- ### Clean Up UpCloud Server Resources Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_and_ssh_into_a_server.md Stops the created UpCloud server using a hard stop and then deletes the server along with its associated storage. ```sh upctl server stop --type hard --wait ${prefix}server upctl server delete ${prefix}server --delete-storages ``` -------------------------------- ### Authentication Failure Exit Code Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/possible_exit_codes.md Illustrates an exit code of 103, which is set when authentication fails due to an invalid token or credentials. ```sh upctl server list # Error: invalid user credentials, authentication failed using the given username and password ``` -------------------------------- ### Generate SSH Key Pair Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_and_ssh_into_a_server.md Creates an Ed25519 SSH key pair for server authentication. The key is saved in the current directory. ```sh # Create ssh-key into current working directory ssh-keygen -t ed25519 -q -f "./id_ed25519" -N "" -C "upctl example" ``` -------------------------------- ### Pull latest upctl Docker image Source: https://github.com/upcloudltd/upcloud-cli/blob/main/docs/index.md Pull the most recent build of the upctl Docker image from GHCR. ```shell docker pull ghcr.io/upcloudltd/upctl:latest ``` -------------------------------- ### Supabase Dashboard Secret Configuration Source: https://github.com/upcloudltd/upcloud-cli/blob/main/internal/commands/stack/supabase/charts/supabase/README.md Configure the username and password for accessing the Supabase Studio dashboard. Ensure the password is updated from the default insecure value. ```yaml secret: dashboard: username: supabase password: this_password_is_insecure_and_should_be_updated ``` -------------------------------- ### Command Argument Validation Failure Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/possible_exit_codes.md Demonstrates an exit code of 100, which is set when command argument validation fails, such as missing required flags. ```sh upctl server create # Error: required flag(s) "hostname", "zone" not set ``` -------------------------------- ### Supabase S3 Storage Secret Configuration Source: https://github.com/upcloudltd/upcloud-cli/blob/main/internal/commands/stack/supabase/charts/supabase/README.md Configure S3 key ID and access key for Supabase storage. These are required to enable S3 object-storage. ```yaml secret: s3: keyId: your-s3-key-id accessKey: your-s3-access-key ``` -------------------------------- ### Configure Invalid Authentication Token Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/possible_exit_codes.md Sets the UPCLOUD_TOKEN environment variable to an invalid value to test authentication failure scenarios. ```env UPCLOUD_TOKEN=invalid ``` -------------------------------- ### Configure DB Secrets in values.yaml Source: https://github.com/upcloudltd/upcloud-cli/blob/main/internal/commands/stack/supabase/charts/supabase/README.md Store database credentials such as username, password, and database name in a Kubernetes secret referenced in values.yaml. This configuration can be adapted for various database providers. ```yaml secret: db: username: password: database: ``` -------------------------------- ### Generate JWT Secret Source: https://github.com/upcloudltd/upcloud-cli/blob/main/internal/commands/stack/supabase/charts/supabase/README.md Generate a 32-character secret for JWT encryption using openssl. ```bash openssl rand 64 | base64 ``` -------------------------------- ### Access Service via NodePort Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/create_cluster_and_expose_service.md Retrieves the external IP of a node and the service port for a NodePort service. It then repeatedly attempts to access the service until it becomes reachable. ```sh # Get node IP node_ip=$(kubectl get node -o json | jq -r '.items[0].status.addresses.[] | select(.type == "ExternalIP").address') # Get service port svc_port=$(kubectl get service hello-uks -o json | jq -r '.spec.ports[0].nodePort') # Wait until the service is reachable until curl -sSf $node_ip:$svc_port; do sleep 15; done; ``` -------------------------------- ### Supabase Analytics Secret Configuration Source: https://github.com/upcloudltd/upcloud-cli/blob/main/internal/commands/stack/supabase/charts/supabase/README.md Set the Logflare API key for securing communication between Supabase services. The key must be at least 32 characters long. ```yaml secret: analytics: apiKey: your-super-secret-with-at-least-32-characters-long-logflare-key ``` -------------------------------- ### Partial Stop Failure Exit Code Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/possible_exit_codes.md Shows an exit code of 1 when attempting to stop two servers, where one is already stopped. This indicates that at least one of the stop operations failed. ```sh upctl server stop --type hard ${prefix}vm-1 ${prefix}vm-2 --wait ``` -------------------------------- ### Configure JWT Secrets in values.yaml Source: https://github.com/upcloudltd/upcloud-cli/blob/main/internal/commands/stack/supabase/charts/supabase/README.md Specify JWT secrets for anonymous and service roles within the values.yaml file. A 32-character secret can be generated using openssl. ```yaml secret: jwt: anonKey: serviceKey: secret: ``` -------------------------------- ### Delete Object Storage Service Source: https://github.com/upcloudltd/upcloud-cli/blob/main/examples/use_object_storage.md Delete the managed object storage service, which will also remove all associated resources like buckets and users. The --force flag bypasses confirmation prompts. ```sh upctl object-storage delete ${prefix}service --force ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.