Plugins - zhuje/openshift-wiki GitHub Wiki

Plugins Overview

Why do we use plugins?

To have an independent extension of the OpenShift Console Platform. It allows code to be more modular and allows us to change/release code in a different cadence than the console.

Plugin Template

Use this template as a base to create new plugins.
https://github.com/openshift/console-plugin-template

Create a new route https://github.com/openshift/console/blob/master/frontend/packages/console-dynamic-plugin-sdk/docs/console-extensions.md#consolepageroute

OpenShift Observability UI Plugins

PM Contact UXD Contact
Vanessa Martini Foday Kargbo
Dynamic Plugin Associated Operator Eng Contact git repo(Link) wiki
Logging Loki Gabriel Bernal https://github.com/openshift/logging-view-plugin
Monitoring Cluster Monitoring Operator (Thanos\Prometheus) Andrew Pickering https://github.com/openshift/monitoring-plugin
Tracing* Jaeger -- https://github.com/zhuje/tracing-console-plugin
Dashboard No Operator -- this allows custom dashboards Gabriel Bernal https://github.com/openshift/console-dashboards-plugin dashboard-console-plugin

*plugin is still in progress

Creating New Plugins

Plugin Template

Use this template as a base to create new plugins.
https://github.com/openshift/console-plugin-template

dashboard-console-plugin

Screenshot 2023-07-10 at 12 56 31 PM
# Ports used 
# pluginBackendPort  : 9001 
# pluginFrontendPort : 9002
# console            : 9000 

# 1. Use MakeFile to install frontend and backend of plugin 
$ make install 

# 1.1 MakeFile deploys an image so we need docker or podman to be running 
$ podman machine start 
OR 
$ docker start 

# 2 Start backend 
$ make start-backend 
# In a seperate terminal start frontend 
$ make start-frontend 

# Start the Openshift Console -- uses docker/podman to run an image of the console
$ make start-console 

# ** NOTE: ** 
# There is no hot reloading for the plugin. 
# So if you make changes you need to stop/restart the plugin. 
# cmd + c termainls running the command make start-frontend and make start-backend
# restart with commands from step #2 

*** IMPORTANT ****
# start-console.sh 
# for some reason my podman isn't working, this shell script uses 
# podman as a default to run images. The code makes the shell script 
# use docker instead of podman 

# Prefer podman if installed. Otherwise, fall back to docker.
# # if [ -x "$(command -v podman)" ]; then
#     if [ "$(uname -s)" = "Linux" ]; then
#         # Use host networking on Linux since host.containers.internal is unreachable in some environments.
#         BRIDGE_PLUGINS="dashboards-console-plugin=http://localhost:9001"
#         podman run --pull always --rm --network=host --env-file <(set | grep BRIDGE) --env BRIDGE_PLUGIN_PROXY="${PLUGIN_PROXY}" $CONSOLE_IMAGE
#     else
#         BRIDGE_PLUGINS="dashboards-console-plugin=http://host.containers.internal:9001"
#         podman run --pull always --rm -p "$CONSOLE_PORT":9000 --env-file <(set | grep BRIDGE) --env BRIDGE_PLUGIN_PROXY="${PLUGIN_PROXY}" $CONSOLE_IMAGE
#     fi
# else
    BRIDGE_PLUGINS="dashboards-console-plugin=http://host.docker.internal:9001"
    docker run --pull always --rm -p "$CONSOLE_PORT":9000 --env-file <(set | grep BRIDGE) --env BRIDGE_PLUGIN_PROXY="${PLUGIN_PROXY}" $CONSOLE_IMAGE
# fi

MakeFile Explained

.PHONY: install
install: install-frontend install-backend

.PHONY 
just means that its a command not a fileName that should be executed. 
For example if we had a file in the same directory as the makeFile it would 
run the file `install` instead of doing the command `install-frontend install-backend`. 
The `make` program usually will look for files to execute that's why we have to 
create a distinction that this is a 'phony file' -- in other words we're telling 
`make` that `install` isn't a fileName but a function. 

install: install-frontend install-backend
is defining the command that we declared with .PHONY: install 

Troubleshooting

# ERROR 

$ make start-console 
./scripts/start-console.sh
Starting local OpenShift console...
API Server: https://api.rhoms-4.13-022204.dev.openshiftappsvc.org:6443
Console Image: quay.io/openshift/origin-console:latest
Console URL: http://localhost:9000
Plugin proxy: {"services": [{"consoleAPIPath": "/api/proxy/plugin/dashboards-console-plugin/backend/", "authorize": true, "endpoint": "http://localhost:9001/"}]}
Error: failed to connect: dial tcp [::1]:61604: connect: connection refused
make: *** [start-console] Error 125
# FIX 
# delete the exisiting virtual machine and start a new one 

$ podman machine info 
$ podman machine remove 
$ podman machine init 
$ podman machine start 

Supplemental Information

Openshift Console

https://github.com/openshift/console/

Dynamic plugin SDK

Provides the plugin API, types and utilities used by dynamic plugins at runtime.
https://github.com/openshift/dynamic-plugin-sdk

⚠️ **GitHub.com Fallback** ⚠️