Dormeto

Docs

Router

A router naps and wakes the workloads of one AWS account or Google Cloud project, in one region.

9 min read

What the install creates

Amazon Web ServicesAWS

  • By: the manager, as the command role (Roles), in no stack or Terraform state.
  • Its name: dmtr-<env>-<region> in the manager's own account, dmtr-<env>-<account>-<region> in another.
  • Its roles: dmtr-<env>-<region>-controller, dmtr-<env>-<region>-waker, dmtr-<env>-<region>-scheduler and dmtr-<env>-<region>-onboarder, under the path /dormeto/router/, each with the boundary DmtRouterBoundary (Roles).
  • Its functions: the Lambda functions dmtr-<env>-controller, dmtr-<env>-waker and dmtr-<env>-onboarder, their logs under /aws/lambda/ kept 14 days.
  • Its state: the DynamoDB table dmtr-<env>-router, with point-in-time recovery.
  • Its queues: dmtr-<env>-work, dmtr-<env>-drift, dmtr-<env>-check-failures and dmtr-<env>-controller-failures.
  • Its triggers: the EventBridge Scheduler schedule dmtr-<env>-check, the idle check every 5 minutes. The EventBridge rule dmtr-<env>-drift repairs outside changes.
  • Its access to EKS: its roles' access entries, the proxy function dmtr-<env>-kube-<cluster> per private cluster (Kubernetes).
  • Your Terraform: it must ignore what onboarding changes (Workloads).

Google Cloud

  • By: the CLI, as you, once you confirm its plan of every IAM change (Access).
  • Its name: dmtr-<region> in its project (CLI).
  • In the project: the APIs, the custom roles dormetoRouter and dormetoRouterBackends (Roles), the secure tag dormeto=managed.
  • Its service account: dmtr-<region>@<project>.iam.gserviceaccount.com, the only identity of its services and tasks (Roles).
  • Its state: the Firestore database dmtr-<region>, which holds the install record, and the Cloud Tasks queue dmtr-<region>.
  • Its log view: dmtr-<region>-lb, on the project's _Default bucket (Request logs).
  • The router, unless --access-only: the Cloud Run services dmtr-<region>-waker and dmtr-<region>-controller, from its image. Its network endpoint group dmtr-<region>-waker, and the Cloud Scheduler job dmtr-<region>-check every 5 minutes.
  • Its optional access: Cloud SQL's and GKE's, when you ask (Optional access).
  • Your Terraform: it must ignore what onboarding changes (Workloads).

Install

Amazon Web ServicesAWS

  1. Give the account the command role (Access).
  2. Install it from Routers, Install a router, with the account's ID and region, as an administrator. Or with the CLI, which follows the operation to its end:
    dormeto aws routers install --account 111122223333 --router-region eu-west-3
  3. Follow its steps in Operations.
  • An onboarding where no router runs installs one first, in the same operation.
  • The router is the manager's release's (Releases). Routers offers to upgrade an older one, as dormeto aws routers upgrade does.
  • A router written in Terraform is upgraded and removed by that Terraform: the manager refuses to.

Google Cloud

  1. Check your permissions (Check).
  2. Install it with your gcloud account:
    dormeto gcp routers install --project my-project --region europe-west1

Capacity and fallback types

A start refused for lack of capacity is retried within the wake.

  • The retries come after 30 s, 60 s, then every 120 s, until the wake's deadline.
  • Fallback types give a machine up to 5 other types for such a wake, in order (Workloads). Databases have none.
  • At its next stop, the machine gets its own type back; a failure is logged InstanceTypeNotReverted.
  • A hibernated or suspended machine wakes on its own type, with the retries only.

Amazon Web ServicesAWS

  • Retried: an EC2 or RDS start. Auto Scaling and ECS keep trying on their own.
  • Fallback instance types: EC2 instances only, such as m6i.large, m5.large, t3a.large.
  • In Terraform: the workload module's fallback_instance_types.
  • What you see: the workload's page says On fallback instance types.

Google Cloud

  • Retried: a VM's or managed group's start or resume, on ZONE_RESOURCE_POOL_EXHAUSTED or POOL_CAPACITY_INSUFFICIENT, not a quota error.
  • Fallback machine types: such as e2-medium, for VMs of unmanaged and zonal network endpoint groups.
  • Refused: managed groups, pods, a type the VM's zone lacks, local SSDs and GPUs (Eligibility).
  • Another series: both must be among N1, F1, G1, N2, N2D, E2, C2, C2D, M1, M2 and T2D.
  • After the onboarding: the list can't change. An offboarding names a VM still on a fallback type, which keeps it.
  • What you see: each VM's type in the run's instanceTypes, the log InstanceTypeFallback and dormeto gcp workloads show. The workload's page and the offboarding say fallbacks.
MessageCauseFix
the router's role lacks compute.instances.setMachineType: run dormeto gcp routers install again Google Cloud onlyIts role lacks compute.instances.setMachineType.Run the install again.

Features

Optional access Google Cloud only

Cloud SQL and GKE each need their own roles, asked by name.

dormeto gcp routers install --with cloud-sql,gke
  • Each API brings Google's agents: none for cloud-sql, two agents and six APIs for gke (Roles).
  • The install record keeps each feature until the uninstall.
  • The CLI's next run prints any binding Google added.

Databases

Companion databases stop after the application, and start before it.

  • The router starts and stops only those the onboarding tagged.

Amazon Web ServicesAWS

  • RDS instances and Aurora clusters, given at the onboarding (Workloads).
  • The onboarding tags them dormeto:workload.

Google Cloud

  • Primary Cloud SQL instances of the project, with the access cloud-sql and its API sqladmin.googleapis.com.
  • The onboarding tags them dormeto=managed.

Kubernetes

Deployments and StatefulSets, scaled to zero by a nap.

Amazon Web ServicesAWS

  • Of the EKS clusters in the router's account and region.
  • Its access entries, a private cluster's proxy and the rights inside, from the release's manifest: Access.

Google Cloud

  • Behind standalone network endpoint groups, on your load balancer, with the access gke and its API container.googleapis.com.
  • The CLI reads the cluster as you, then shows and asks. It applies, in the workload's namespace, a Role and a RoleBinding dormeto-<workload>:
    • get on deployments, statefulsets.
    • list on replicasets.
    • patch on deployments/scale, statefulsets/scale.
    • list on pods, events.
    • list, patch on scaledobjects.
  • The offboarding removes both.
  • You need container.roles.escalate and container.roles.bind; Google marks container.roles.escalate as TESTING in custom roles.

IP lists

IP lists keep listed addresses, such as scanners, from waking workloads.

Amazon Web ServicesAWS

  • They are the manager's: the ip_lists of its module, each with its action (Manager).
  • A router the manager installed reads them; a change reaches it within 5 minutes.

Google Cloud

  • They are the router's own, set at its install (routers).
  • The action is ignore only.
  • A listed visit never wakes; an API client's POST /_dormeto/wake still does.
  • The manager's lists don't reach a Google Cloud router; its own need no extra role.
  • A list's URL, query string included, is printed and stored: keep tokens out. One with credentials is refused.
  • Behind a global or classic load balancer, a forged header can't change the client's address.

Check

Amazon Web ServicesAWS

dormeto aws routers show dmtr-prod-eu-west-3
  • Before the install: Discovery's check of the command role (Access).
  • Once installed: its health, ok, warning or error, with its problems.
  • Where: Routers and dormeto aws routers list; routers show prints each problem (routers).
  • An error: a late idle check, so the workloads no longer nap on their own.
  • A warning: any other problem: a failure queue's messages, Lambda errors, a failing IP list or workload.
  • Its EKS clusters: the router's page under Routers lists them, and whether it reaches them (Access).
  • Alerts: a router that reports a problem, or stops reporting, alerts the addresses of alert_emails (Manager).

Google Cloud

dormeto gcp check --project my-project --region europe-west1
  • Before the install: dormeto gcp check reads your permissions and changes nothing.
  • Per command: a tick, or a cross with the missing permissions, all of them with no role.
  • Also: the project's parent and billing, the APIs on, and warnings such as the default service account's Editor.
  • Its exit: 1 when a permission or billing is missing.
  • Once installed: dormeto gcp routers show shows the record and the live state: version, services, controller health, queue, job, database, grants.

Remove

The uninstall refuses a router with workloads.

Amazon Web ServicesAWS

  1. Offboard its workloads first.
  2. Uninstall it from its row's ⋮ on Routers, or from the router's page, as an administrator. Or with the CLI, which asks first:
    dormeto aws routers uninstall dmtr-prod-eu-west-3
  • The uninstall deletes its EKS access entries. And private clusters' proxies, with their TCP 443 rule on the cluster's security group.
  • The account keeps its access: the command role, its boundary and the discovery role (Access).

Google Cloud

  1. Offboard its workloads first, or uninstall with --force (routers).
  2. Uninstall it:
    dormeto gcp routers uninstall --project my-project --region europe-west1
  3. Turn off the APIs nothing else needs (The APIs).
  4. Remove the default service account's Editor (Roles).
  • It removes what its record says the install added, in reverse order, optional access included.
  • It keeps the custom roles and the tag while another router of the project lists them.
  • It names the APIs and Google's bindings it leaves on.
  • A deleted queue's name stays blocked up to 3 days, a database's ID about 5 minutes. Installing again before fails.

The APIs Google Cloud only

The install turns these on.

APIService
compute.googleapis.comCompute Engine
run.googleapis.comCloud Run
firestore.googleapis.comFirestore
cloudtasks.googleapis.comCloud Tasks
cloudscheduler.googleapis.comCloud Scheduler
monitoring.googleapis.comCloud Monitoring
artifactregistry.googleapis.comArtifact Registry, with --image only.
iam.googleapis.comIdentity and Access Management
cloudresourcemanager.googleapis.comCloud Resource Manager
logging.googleapis.comCloud Logging

With the optional access, also sqladmin.googleapis.com, container.googleapis.com and the six Google turns on with GKE (Roles).

To turn them off:

gcloud services disable \
  compute.googleapis.com \
  run.googleapis.com \
  firestore.googleapis.com \
  cloudtasks.googleapis.com \
  cloudscheduler.googleapis.com \
  monitoring.googleapis.com \
  artifactregistry.googleapis.com \
  iam.googleapis.com \
  cloudresourcemanager.googleapis.com \
  logging.googleapis.com \
  --project my-project

Google may refuse while another service depends on one, or ask for --force.

The router's image Google Cloud only

The install deploys Dormeto's public image, in the multi-region of --region.

<europe|us|asia>-docker.pkg.dev/dormeto-releases/router/router:<version>
  • The multi-region: europe for europe-*, us for us-*, northamerica-* and southamerica-*, asia for any other.
  • A later run: it upgrades an older router to the CLI's default version.
  • By digest: the CLI deploys <name>@sha256:…, read without a token; you build, push and grant nothing.
  • An access-only record: it says accessOnly, and later runs keep it until one gives --version or --image.
  • Your own image: it stays for later runs. It needs artifactregistry.googleapis.com and your permissions on it (Roles). dormeto gcp check --image tests them.
  • An image in another project: it needs roles/artifactregistry.reader for this project's Cloud Run service agent (Roles). You grant it: the CLI doesn't.
MessageCauseFix
router <v> needs a newer CLI: brew upgrade dormeto--version above this CLI's own.Upgrade the CLI.
router <v> is newer than this CLI knows (<default>): brew upgrade dormetoA newer CLI installed the router.Upgrade the CLI.
the router isn't installed: dormeto gcp routers install --version <default>The record holds the access only.Install the router with --version.
router <v> is available: dormeto gcp routers install --version <v>Your own image stays; Dormeto's is at <v>.Install it with --version, or keep yours.
--ip-list and --access-only: one or the otherIP lists need the router.Drop one of the two options.
the install removes no router: dormeto gcp routers uninstall removes it with its access--access-only on an installed router.Uninstall the router instead.

Request logs Google Cloud only

The idle check counts every request the load balancer served, scanners included.

With the request logs, it ignores what the waker ignores: HEAD requests, scanners and IP lists.

  • They need the backend service to log every request: logging on, sample rate 1.0. dormeto gcp workloads onboard --request-logs turns it on (workloads).
  • Terraform keeps them only if you write them (Workloads).
  • Scanners that send a browser's user agent to the application's own paths count as visitors. IP lists stop known scanner networks.
  • On a regional load balancer, logging begins a few minutes after the change.
  • The router reads only its view dmtr-<region>-lb, of the load balancers' request logs, with roles/logging.viewAccessor (Roles).
  • Cloud Logging charges ingestion past 50 GiB a month and project, about 1 KiB a request.
MessageCauseFix
the router's log view isn't created: the project's _Default log bucket isn't in global; the idle check counts every requestThe project's _Default bucket isn't in global, where the view lives.Accept it: dormeto gcp routers show repeats it, and a later run tries again.