Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 0 additions & 57 deletions Dockerfile.konflux

This file was deleted.

37 changes: 20 additions & 17 deletions Dockerfile.mcp
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
# mcp (monitoring-console-plugin)

FROM registry.redhat.io/ubi9/nodejs-22:latest AS web-builder

USER 0

WORKDIR /opt/app-root

ENV HUSKY=0
USER 0

ENV HUSKY=0
COPY web/package*.json web/
COPY Makefile Makefile
COPY scripts/update-plugin-name.sh scripts/update-plugin-name.sh
COPY web/ web/

RUN make update-plugin-name

ENV I18N_NAMESPACE="plugin__monitoring-console-plugin"
RUN make install-frontend-ci

RUN make install-frontend
COPY web/ web/
COPY config/ config/
ENV CONSOLE_PLUGIN_NAME="monitoring-console-plugin"
RUN make build-frontend

FROM registry.access.redhat.com/ubi9/go-toolset:1.26 AS go-builder
Expand All @@ -27,20 +22,28 @@ COPY Makefile Makefile
COPY go.mod go.mod
COPY go.sum go.sum

RUN go mod download
RUN make install-backend

COPY cmd/ cmd/
COPY pkg/ pkg/

RUN go build -mod=mod -o plugin-backend cmd/plugin-backend.go
ENV GOOS=${TARGETOS:-linux}
ENV GOARCH=${TARGETARCH}
ENV GOEXPERIMENT=strictfipsruntime
ENV GOFLAGS=-mod=readonly
ENV CGO_ENABLED=1

RUN make build-backend

FROM registry.access.redhat.com/ubi9/ubi-minimal

RUN mkdir /licenses
COPY LICENSE /licenses/.

USER 1001

COPY --from=web-builder /opt/app-root/web/dist /opt/app-root/web/dist
COPY --from=web-builder /opt/app-root/web/package.json /opt/app-root/web/package.json
COPY --from=go-builder /opt/app-root/plugin-backend /opt/app-root
COPY config/ /opt/app-root/config
COPY --from=web-builder /opt/app-root/config /opt/app-root/config

ENTRYPOINT ["/opt/app-root/plugin-backend", "-static-path", "/opt/app-root/web/dist", "-config-path", "/opt/app-root/config"]
ENTRYPOINT ["/opt/app-root/plugin-backend", "-static-path", "/opt/app-root/web/dist"]
14 changes: 3 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ PLATFORMS ?= linux/arm64,linux/amd64
ORG ?= openshift-observability-ui
PLUGIN_NAME ?= monitoring-plugin
IMAGE ?= quay.io/${ORG}/${PLUGIN_NAME}:${VERSION}
FEATURES ?= incidents,perses-dashboards,dev-config
FEATURES ?= cluster-health-analyzer,perses-dashboards,dev-config

.PHONY: install-frontend
install-frontend:
cd web && npm install

.PHONY: install-frontend-ci
install-frontend-ci:
cd web && npm ci --omit=optional --ignore-scripts
cd web && npm ci --ignore-scripts

.PHONY: install-frontend-ci-clean
install-frontend-ci-clean: install-frontend-ci
Expand Down Expand Up @@ -53,7 +53,7 @@ build-backend:

.PHONY: start-backend
start-backend:
go run ./cmd/plugin-backend.go -port='9001' -config-path='./config' -static-path='./web/dist'
go run ./cmd/plugin-backend.go -port='9443' -config-path='./config' -static-path='./web/dist'

.PHONY: build-image
build-image:
Expand All @@ -64,10 +64,6 @@ build-image:
install:
make install-frontend && make install-backend

.PHONY: update-plugin-name
update-plugin-name:
./scripts/update-plugin-name.sh

.PHONY: deploy
deploy:
make lint-backend
Expand All @@ -83,10 +79,6 @@ deploy-acm:
build-mcp-image:
DOCKER_FILE_NAME="Dockerfile.mcp" scripts/build-image.sh

.PHONY: start-feature-console
start-feature-console:
PLUGIN_PORT=9443 ./scripts/start-console.sh

.PHONY: start-feature-backend
start-feature-backend:
go run ./cmd/plugin-backend.go -port='9443' -config-path='./config' -static-path='./web/dist' -features='$(FEATURES)'
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@ $ podman machine start
# Install dependencies
$ make install

# Run the application
# Run the frontend
$ make start-frontend
# In a separate terminal
# Run the backend
$ make start-backend
# In a separate terminal
$ make start-console
```

Expand All @@ -94,12 +97,13 @@ The application will be running at [localhost:9000](http://localhost:9000/).
## monitoring-console-plugin (mcp)

### Dependencies

1. [Local Development Dependencies](README#Dependencies)
2. [yq](https://github.com/mikefarah/yq) for acm deployment
3. sed ([gnu-sed](https://formulae.brew.sh/formula/gnu-sed) for mac, with sed being aliased to that gnu-sed)


### Building an image

Images for the mcp can be built by running the following command. Due to the limitation of linux/amd64 image builds on Apple Silicon Macs's, some of the changes are run locally and not just in the Dockerfiles. If you are on a Mac, it is not suggested to cancel the exection of this scipt part way through

```bash
Expand All @@ -111,10 +115,9 @@ make build-mcp-image
Feature flags are used by the mcp mode to dictate the specific features which are enabled when the server starts up. Feature flags should be added to the Feature enum [here](pkg/server.go) and to the useFeature hook [here](web/src/components/hooks/useFeatures.ts). When any feature flag is enabled the default extension points are overridden, including a new monitoring-console-plugin exclusive redux store and all extension points for the flags. These feature extension points are created through the use of [json-patches](https://datatracker.ietf.org/doc/html/rfc6902), such as the `acm-alerting` patch [here](config/acm-alerting.patch.json). The server looks for a patch in the format of `{feature-flag-name}.patch.json` to apply.

| Feature | OCP Version |
|-------------------|-------------|
| ----------------- | ----------- |
| acm-alerting | 4.14+ |
| perses-dashboards | 4.14+ |
| incidents | 4.19+ |
| dev-config | |

#### ACM
Expand All @@ -137,7 +140,7 @@ Since the store for the `monitoring-plugin` is stored in the `openshift/console`
# Login to an OpenShift cluster
$ oc login <clusterAddress> -u <username> -p <password>

# Start podman (or Docker)
# Start podman (or Docker) - Linux machines can skip this part
$ podman machine init
$ podman machine start

Expand Down
5 changes: 3 additions & 2 deletions scripts/start-console.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ set -euo pipefail

CONSOLE_IMAGE=${CONSOLE_IMAGE:="quay.io/openshift/origin-console:latest"}
CONSOLE_PORT=${CONSOLE_PORT:=9000}
PLUGIN_PORT=${PLUGIN_PORT:=9001}
PLUGIN_PORT=${PLUGIN_PORT:=9443}
CONSOLE_IMAGE_PLATFORM=${CONSOLE_IMAGE_PLATFORM:="linux/amd64"}
npm_package_consolePlugin_name=${npm_package_consolePlugin_name:="monitoring-plugin"}
npm_package_consolePlugin_name=${CONSOLE_PLUGIN_NAME:-"monitoring-plugin"}

echo "Starting local OpenShift console..."

Expand All @@ -19,6 +19,7 @@ BRIDGE_K8S_MODE_OFF_CLUSTER_THANOS=$(oc -n openshift-config-managed get configma
BRIDGE_K8S_MODE_OFF_CLUSTER_ALERTMANAGER=$(oc -n openshift-config-managed get configmap monitoring-shared-config -o jsonpath='{.data.alertmanagerPublicURL}')
BRIDGE_K8S_AUTH_BEARER_TOKEN=$(oc whoami --show-token 2>/dev/null)
BRIDGE_USER_SETTINGS_LOCATION="localstorage"
BRIDGE_I18N_NAMESPACES="plugin__${npm_package_consolePlugin_name}"

echo "API Server: $BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT"
echo "Console Image: $CONSOLE_IMAGE"
Expand Down
8 changes: 0 additions & 8 deletions scripts/update-plugin-name.sh

This file was deleted.

30 changes: 26 additions & 4 deletions web/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { DefinePlugin, Configuration as WebpackConfiguration } from 'webpack';
import { Configuration as WebpackDevServerConfiguration } from 'webpack-dev-server';
import * as path from 'path';
import { ConsoleRemotePlugin } from '@openshift-console/dynamic-plugin-sdk-webpack';
import pkg from './package.json';

interface Configuration extends WebpackConfiguration {
devServer?: WebpackDevServerConfiguration;
Expand Down Expand Up @@ -82,17 +83,38 @@ const config: Configuration = {
},
plugins: [
new ConsoleRemotePlugin({
pluginMetadata: process.env.CONSOLE_PLUGIN_NAME
? { ...pkg.consolePlugin, name: process.env.CONSOLE_PLUGIN_NAME }
: undefined,
validateExtensionIntegrity: false,
}),
new CopyWebpackPlugin({
patterns: [{ from: path.resolve(__dirname, 'locales'), to: 'locales' }],
patterns: [
{
from: path.resolve(__dirname, 'locales'),
to({ absoluteFilename }) {
if (!absoluteFilename) {
return 'locales/[path][name][ext]';
}
const i18nNamespace = `plugin__${process.env.CONSOLE_PLUGIN_NAME ?? 'monitoring-plugin'}`;
const relativePath = path.relative(
path.resolve(__dirname, 'locales'),
absoluteFilename,
);
return path.join(
'locales',
relativePath.replace('plugin__monitoring-plugin', i18nNamespace),
);
},
},
],
}),
new DefinePlugin({
// Build-time injection of proxy path for config module
PERSES_PROXY_BASE_URL: JSON.stringify('/api/proxy/plugin/monitoring-console-plugin/perses'),
'process.env.I18N_NAMESPACE': process.env.I18N_NAMESPACE
? JSON.stringify(process.env.I18N_NAMESPACE)
: JSON.stringify('plugin__monitoring-plugin'),
'process.env.I18N_NAMESPACE': JSON.stringify(
`plugin__${process.env.CONSOLE_PLUGIN_NAME ?? 'monitoring-plugin'}`,
),
}),
],
devtool: 'source-map',
Expand Down