fleetconsole/

directory
v0.0.0-...-636a2a8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2025 License: BSD-3-Clause

README

Fleet Console Server

Googlers, for broad docs on the Fleet Console, see: go/fleet-console

This directory hosts the code for the backend of the Fleet Console UI, a unified UI for managing machines in the fleet.

How to run locally

From the root directory for this repo.

With a local db

First start the db using docker docker:

docker compose up -d

If this is your first time you will have to run migrations

You can now run the web server:

go build ./cmd/fleetconsoleserver
./fleetconsoleserver
Connecting to the dev db

Check that you have gcloud ssh keys saved

gcloud compute os-login describe-profile

otherwise add them via

gcloud compute os-login ssh-keys add --key="$(ssh-add -L | grep publickey)" --project=fleet-console-dev

Create a ssh tunnel inside the db's vpc:

gcloud compute ssh alloydb-bastion \
    --project fleet-console-dev \
    --zone us-central1-c \
    --ssh-flag="-L 5432:10.89.112.2:5432"\
    -- -o Hostname=nic0.alloydb-bastion.us-central1-c.c.fleet-console-dev.internal.gcpnode.com

You can now run the web server specifying -use-dev-db

go build ./cmd/fleetconsoleserver/main.go
./fleetconsoleserver -use-dev-db
Run the web client

How to manually test

This codebase include a Fleet Console CLI tool for the purpose of helping test the functionality of Fleet Console Server.

To build / run the CLI, run:

go build ./cmd/consoleadmin
./consoleadmin

You can do a liveness check for the local Fleet Console backend like so:

./consoleadmin ping -local
{}

And you can check the connection to the database like so:

./consoleadmin ping-db -local
{}

To see more commands available in the CLI run:

./consoleadmin help

How to run tests

Run go test ./...

Run migrations

Local

Create a virtualenv and install Alembic database migration tool:

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

The necessary tools to manage the Postgres or AlloyDB database are installed.

You can now apply the migrations:

alembic upgrade head
Dev

Check that you have gcloud ssh keys saved

gcloud compute os-login describe-profile

otherwise add them via

gcloud compute os-login ssh-keys add --key="$(ssh-add -L | grep publickey)" --project=fleet-console-dev

Create a ssh tunnel inside the db's vpc: more info

gcloud compute ssh alloydb-bastion \
    --project fleet-console-dev \
    --zone us-central1-c \
    --ssh-flag="-L 5432:10.89.112.2:5432"\
    -- -o Hostname=nic0.alloydb-bastion.us-central1-c.c.fleet-console-dev.internal.gcpnode.com

Run migrations specifying env=dev

alembic -x env=dev upgrade head

If you get an error make sure you are logged in gcloud cli for your application-default

gcloud auth application-default login
Prod

Check that you have gcloud ssh keys saved

gcloud compute os-login describe-profile

otherwise add them via

gcloud compute os-login ssh-keys add --key="$(ssh-add -L | grep publickey)" --project=fleet-console-prod

Create a ssh tunnel inside the db's vpc: more info

# gcloud alternative
gcloud compute ssh alloydb-bastion \
    --project fleet-console-prod \
    --zone us-central1-c \
    --ssh-flag="-L 5432:10.87.208.2:5432"\
    -- -o Hostname=nic0.alloydb-bastion.us-central1-c.c.fleet-console-prod.internal.gcpnode.com

Run migrations specifying env=prod

alembic -x env=prod upgrade head

If you get an error make sure you are logged in gcloud cli for your application-default

gcloud auth application-default login

How to deploy

Deployment configs are hosted in the infradata repo

Dev

fleet-console-dev is deployed automatically after CLs land.

Prod

fleet-console-prod must have deployment triggered using a CL.

TODO: Add instructions on how to deploy to prod

Directories

Path Synopsis
api
fleetconsolerpc
Package fleetconsolerpc is the generated protos for the fleet console service.
Package fleetconsolerpc is the generated protos for the fleet console service.
cmd
consoleadmin/clilib
Package clilib contains the command line application for the fleet console project.
Package clilib contains the command line application for the fleet console project.
fleetconsoleserver
Package main is the entrypoint to the fleet console server.
Package main is the entrypoint to the fleet console server.
fleetconsoleserver/flags
Package flags defines flags for the fleetconsoleserver.
Package flags defines flags for the fleetconsoleserver.
fleetconsoleserver/serverlib
Package serverlib contains the main server loop and the modules used.
Package serverlib contains the main server loop and the modules used.
internal
bigqueryclient
Package bigqueryclient contains utils to connect to Big Query
Package bigqueryclient contains utils to connect to Big Query
commands
Package commands contains the fleet console CLI.
Package commands contains the fleet console CLI.
consoleserver
Package consoleserver is the implementation of the backend of the console UI.
Package consoleserver is the implementation of the backend of the console UI.
database
Package database connects to a postgres or alloydb database.
Package database connects to a postgres or alloydb database.
database/devicesdb
Package devicesdb provides utilities to retrieve/update devices from db
Package devicesdb provides utilities to retrieve/update devices from db
database/queryutils
Package queryutils provides utilities to query the Devices table.
Package queryutils provides utilities to query the Devices table.
devicemanagerclient
Package devicemanagerclient is the client lib for device manager.
Package devicemanagerclient is the client lib for device manager.
internalproto
Package internalproto is the generated protos used internally.
Package internalproto is the generated protos used internally.
site
Package site contains settings related to the fleet console project as a whole.
Package site contains settings related to the fleet console project as a whole.
ufsclient
Package ufsclient is the client lib for UFS.
Package ufsclient is the client lib for UFS.
utils
Package utils is a set of utilities for the console server.
Package utils is a set of utilities for the console server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL