3.9 KiB
Admin Portal
Introduction
The admin portal is a SRE-facing front end used for performing various actions and retrieving information for clusters in a given region.
The admin portal runs inside the RP and calls against the RP for cluster information and serves that information using a MSFT inspired front end.
The front end is developed using react and typescript. The back end api is written in golang and makes direct calls to CosmosDB for cluster information.
The portal front end lives in the top level directory of the ARO-RP repo within the portal
directory. The portal back end exists within pkg/portal
The front end code is built into the aro
binary (via go embed) and the static files are served by aro portal
.
The admin portal also serves a static Prometheus web frontend. The contents are taken from a Prometheus release's web-ui artifact (e.g. 2.48), and the static/react subdirectory is mirrored to this repository's pkg/portal/assets/prometheus-ui directory.
Developing
You will require Node.js and npm
. These instructions were tested with the versions from the Fedora 34 repos.
-
Make your desired changes in
portal/v2/src/
and commit them. -
Run
make build-portal
from the main directory. This will install the dependencies and kick off the Webpack build, placing the results inportal/v2/build/
.
NOTE: Due to security compliance requirements, the
make build-portal
target pulls fromarointsvc.azurecr.io
. You can either authenticate to this registry usingaz acr login --name arointsvc
to pull the image, or modify the $RP_IMAGE_ACR environment variable to point the builds atregistry.access.redhat.com
instead.
-
Run
make generate
. This will regenerate the golang file containing the portal content to be served. -
Commit the results of
build-portal
andgenerate
.
Running Admin Portal in development
Running Portal Served from development RP
-
Complete Steps mentioned above to build and compile portal.
-
Make sure development environment variables are set and also set
export NO_NPM=1
. Setting this environment variable will make sure in development mode that the admin portal does not redirect to the front end development server at localhost:3000 and instead will route to localhost:8444 where the front end code is being served by the RP -
Run
make run-portal
-
Go to localhost:8444 to view admin portal running
Running Portal Served from the front end development server
-
Complete Steps mentioned above to build and compile portal.
-
Make sure development environment variables are set
-
Run
make run-portal
-
In a seperate tab change directory to
portal/v2/
and runnpm run start
to run front end development server -
Go to localhost:3000 to view admin portal running
Pointing Portal At Fake APIServer
- Create a file containing the following as
fakekubeconfig
:
kind: Config
apiVersion: v1
clusters:
- cluster:
insecure-skip-tls-verify: true
server: https://localhost:6443
name: test:6443
contexts:
- context:
cluster: test:6443
namespace: default
user: test
name: test
current-context: test
users:
- name: test
user:
token: sha256~aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-
source secrets/env
-
go run hack/aead/aead.go --file fakekubeconfig
-
Replace the CosmosDB Kubeconfig entries with what's returned (except the logs)
-
Replace
OpenShiftCluster.Properties.APIServerProfile.IP
value in CosmosDB with "127.0.0.1"
Running the fake API Server
go run hack/fakecluster/fakecluster.go
Adding Fake Data
-
Use
oc get --raw="/path/to/api
to get the raw output, and put it inpkg/portal/cluster/testdata/<api.json>
-
Add a new route to
hack/fakecluster/fakecluster.go
-
Add new fetcher tests in
pkg/portal/cluster
, too!