Skip to content

Commit 07aef07

Browse files
committed
roachprod: add web UI for cluster management
This commit introduces a new web-based UI for roachprod, providing an intuitive interface for managing CockroachDB clusters. Previously, all roachprod operations required command-line usage, which could be cumbersome for common workflows like viewing cluster status, creating clusters, and managing cluster lifecycle. The new UI is accessible via `roachprod ui` and provides: **Cluster Management:** - List all clusters or filter to show only user's clusters - View cluster details: nodes, lifetime remaining, cloud provider, machine type - Create new clusters with an interactive modal - Delete, extend, start, stop, stage, and wipe clusters - Real-time cluster status with node-level information - Access to Admin UI and PostgreSQL connection strings **Interactive Terminals:** - SSH terminal access to cluster nodes via WebSocket - SQL console for direct database interaction - Backend console showing roachprod command output **Cloud Provider Integration:** - Dynamic machine type and zone selection based on cloud provider - Queries GCE, AWS, and Azure APIs for up-to-date options - Displays machine specifications (vCPUs, RAM) alongside each type - Intelligent sorting by machine class and size - Multi-zone selection for geo-distributed clusters **User Experience:** - Real-time notifications for operations - Confetti celebration when clusters are created successfully - Split-panel layout with cluster list and terminal/console views - Loading states and error handling throughout **Technical Implementation:** Backend (Go): - Embedded web server with HTTP and WebSocket handlers - REST API for cluster operations (/api/clusters/*, /api/cloud-providers/*) - WebSocket endpoints for SSH and SQL console streaming - Integration with existing roachprod cluster management functions - UI assets embedded in binary via Bazel Frontend (React + TypeScript): - Ant Design component library for consistent UI - XTerm.js for terminal emulation - Real-time WebSocket communication for terminals - Notification system with drawer interface - Split panel layout The UI is launched with `roachprod ui [--port 8080]` and opens automatically in the default browser. Release note: none Epic: None
1 parent ae0b3d7 commit 07aef07

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+9332
-283
lines changed

.bazelignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ pkg/ui/workspaces/db-console/ccl/src/js/node_modules
1111
pkg/ui/workspaces/e2e-tests/node_modules
1212
pkg/ui/workspaces/eslint-plugin-crdb/node_modules
1313
pkg/ui/workspaces/crdb-api-client/node_modules
14+
pkg/ui/workspaces/roachprod-ui/node_modules
1415
tmp
1516
vendor

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,5 @@ pkg/testutils/serverutils/*_generated.go
6666
.DS_Store
6767
.idea/
6868
.vscode/
69+
/pkg/roachprod/ui/dist/
70+
/pkg/roachprod/ui/assets.tar.zst

WORKSPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ npm_translate_lock(
307307
"//pkg/ui/workspaces/db-console/src/js:package.json",
308308
"//pkg/ui/workspaces/e2e-tests:package.json",
309309
"//pkg/ui/workspaces/eslint-plugin-crdb:package.json",
310+
"//pkg/ui/workspaces/roachprod-ui:package.json",
310311
],
311312
npmrc = "//pkg/ui:.npmrc.bazel",
312313
patch_args = {

pkg/cmd/roachprod/cli/commands.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,3 +2256,30 @@ If a destination is not provided, the certs will be downloaded to a default %s d
22562256
}),
22572257
}
22582258
}
2259+
2260+
func (cr *commandRegistry) buildUICmd() *cobra.Command {
2261+
uiCmd := &cobra.Command{
2262+
Use: "ui",
2263+
Short: "start the roachprod web UI",
2264+
Long: `Start a web-based user interface for managing roachprod clusters.
2265+
2266+
The UI provides a graphical interface for:
2267+
- Listing and filtering clusters
2268+
- Creating new clusters with a wizard
2269+
- Deleting clusters
2270+
- Extending cluster lifetimes
2271+
- SSH access to cluster nodes via an interactive terminal
2272+
2273+
The UI server will start on the specified port (default 7763) and can be
2274+
accessed via a web browser at http://localhost:<port>.
2275+
2276+
Press Ctrl+C to stop the server.
2277+
`,
2278+
Args: cobra.NoArgs,
2279+
Run: Wrap(func(cmd *cobra.Command, args []string) error {
2280+
return roachprod.StartUIServer(uiPort)
2281+
}),
2282+
}
2283+
uiCmd.Flags().IntVarP(&uiPort, "port", "p", 7763, "Port for the web UI server")
2284+
return uiCmd
2285+
}

pkg/cmd/roachprod/cli/flags.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ var (
9898

9999
grafanaTags []string
100100
grafanaDashboardUID string
101+
102+
uiPort int
101103
grafanaTimeRange []int64
102104

103105
sshKeyUser string

pkg/cmd/roachprod/cli/resgistry.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,6 @@ func (cr *commandRegistry) register() {
7373
cr.buildFetchLogsCmd(),
7474
cr.buildGetLatestPProfCmd(),
7575
cr.buildFetchCertsDir(),
76+
cr.buildUICmd(),
7677
})
7778
}

pkg/gen/misc.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ MISC_SRCS = [
1313
"//pkg/kv/kvserver/spanlatch:latch_interval_btree_test.go",
1414
"//pkg/roachprod/agents/opentelemetry:cockroachdb_metrics.go",
1515
"//pkg/roachprod/install:types_generated.go",
16+
"//pkg/roachprod/ui:assets.tar.zst",
1617
"//pkg/roachprod/vm/aws:terraform/main.tf",
1718
"//pkg/spanconfig/spanconfigstore:entry_interval_btree.go",
1819
"//pkg/spanconfig/spanconfigstore:entry_interval_btree_test.go",

pkg/roachprod/BUILD.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ go_library(
99
"node_stability.go",
1010
"roachprod.go",
1111
"roachprod_pprof.go",
12+
"ui.go",
13+
"ui_cluster_manager.go",
1214
],
1315
importpath = "github.com/cockroachdb/cockroach/pkg/roachprod",
1416
visibility = ["//visibility:public"],
@@ -26,6 +28,7 @@ go_library(
2628
"//pkg/roachprod/logger",
2729
"//pkg/roachprod/prometheus",
2830
"//pkg/roachprod/promhelperclient",
31+
"//pkg/roachprod/ui",
2932
"//pkg/roachprod/vm",
3033
"//pkg/roachprod/vm/aws",
3134
"//pkg/roachprod/vm/azure",
@@ -41,6 +44,7 @@ go_library(
4144
"//pkg/util/timeutil",
4245
"@com_github_cockroachdb_errors//:errors",
4346
"@com_github_cockroachdb_errors//oserror",
47+
"@com_github_creack_pty//:pty",
4448
"@org_golang_x_sys//unix",
4549
],
4650
)

0 commit comments

Comments
 (0)