=> Upspin Project => Google Provider Intro
Start at the server page to get familiar, jog memory => Upspin Server
Keep in mind we’ll skip around because we actually have our registration from years ago when we did our first test drive. Read down to the subheading for Specific instructions for cloud services, making sure everything looks good so far (the instructions should not be a surprise as we completed them once before).
Next visit the GCP page to continue => Setup Google Compute
Stick to the instructions on building upspinserver-gcp
and upspin-setupstorage-gcp
with only minor adjustments:
mkdir uptest && cd uptest
go mod init example.com/uptest
go get -d gcp.upspin.io/cmd/...
go install gcp.upspin.io/cmd/upspin-setupstorage-gcp
GOOS=linux GOARCH=arm64 go build gcp.upspin.io/cmd/upspinserver-gcp
The GOOS
and GOARCH
env values are for the Google Compute machine type which in our case will be ARM (t2a-standard-1
).
We are recycling the Google Cloud Project and skipped creation this time around. With the Google Cloud SDK, the snapcraft option was the easiest.
TBD check Google Cloud Storage bucket steps (because “Bucket already exists”)
Now it’s time to provision the Google Compute machine (t2a-standard-1
). Collected into Terraform HCL (where MY-SUBDOMAIN-EXAMPLE-COM is a placeholder and should be replaced with a real value):
provider "google" {
project = "MY-SUBDOMAIN-EXAMPLE-COM"
region = "us-central1"
zone = "us-central1-a"
}
resource "google_compute_network" "vpc_network" {
name = "my-custom-mode-net"
auto_create_subnetworks = false
mtu = 1460
}
resource "google_compute_subnetwork" "default" {
name = "my-custom-subnet"
ip_cidr_range = "10.0.1.0/24"
network = google_compute_network.vpc_network.self_link
}
# Create a single Compute Engine instance
resource "google_compute_instance" "vm_instance" {
name = "upspin-MY-SUBDOMAIN-EXAMPLE-COM"
machine_type = "t2a-standard-1"
allow_stopping_for_update = true
tags = ["ssh"]
boot_disk {
initialize_params {
image = "debian-11-arm"
size = 20
}
}
# Install Flask (python cgi)
##metadata_startup_script = "sudo apt-get update; sudo apt-get install -yq build-essential python3-pip rsync; pip install flask"
# TODO kept here as reminder because we will use upspin command to deploy to the instance
network_interface {
nic_type = "GVNIC"
subnetwork = google_compute_subnetwork.default.self_link
access_config {
# Include this section to give the VM an external IP address
}
}
}
resource "google_compute_firewall" "ssh" {
name = "allow-ssh"
allow {
ports = ["22"]
protocol = "tcp"
}
direction = "INGRESS"
network = google_compute_network.vpc_network.self_link
priority = 1000
source_ranges = ["0.0.0.0/0"]
target_tags = ["ssh"]
}
resource "google_compute_firewall" "upspin" {
name = "upspin-app-firewall"
network = google_compute_network.vpc_network.self_link
allow {
protocol = "tcp"
ports = ["80", "443"]
}
source_ranges = ["0.0.0.0/0"]
}
##resource "google_compute_snapshot" "upspin_server_snapshot" {
## name = "upspin-20221129-ubuntu2204lts"
## source_disk = google_compute_instance.vm_instance.self_link
##}
# A variable for extracting the external IP address of the VM
output "Upspin-server-URL" {
value = join("", ["http://", google_compute_instance.vm_instance.network_interface.0.access_config.0.nat_ip, ":80"])
}
The assigned IP should be displayed at the end of deployment. The rest of the instructions for DNS, upload, and configuration of the upspinserver binary can be followed as described.
Why use ephemeral IP? shouldn’t it be a static IP. TBD
What is the snapshot about? TBD
Why Terraform? terraform destroy
when we need to undo/start over is very convenient. The alternative was to reverse the GCP steps using the console UI.
Why Terraform? No installation required. The GCP console has a shell tool that is embedded inside the web browser. It will link to the project at launch. It also stores the state of the Terraform deployments; similar to choosing Terraform Cloud to be the backend for the state data.
Why choose a ARM machine type? At least until Apr 2023, the free tier treats this machine type as a trial. Which means it will need revisiting later to make sure the pricing isn’t a sudden surprise.