Skip to content
Merged
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
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ web/cypress/videos/
web/dist/
web/node_modules/
plugin-backend
# adding these while the PR is in review. This should be removed after
# Leave these permanently for backwards compatability for backporting
node_modules/
dist/
web/po-files/
.devspace
web/po-files/
26 changes: 26 additions & 0 deletions Dockerfile.devspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_9_golang_1.24 AS web-builder

WORKDIR /opt/app-root

USER 0
RUN chgrp -R 0 /opt/app-root
RUN chmod -R g+rw /opt/app-root
RUN mkdir /.devspace
RUN chgrp -R 0 /.devspace
RUN chmod -R g+rw /.devspace

ENV HUSKY=0

COPY Makefile Makefile
COPY go.mod go.mod
COPY go.sum go.sum

RUN make install-backend

COPY config/ config/
COPY cmd/ cmd/
COPY pkg/ pkg/

RUN make build-backend

ENTRYPOINT ["make", "start-devspace-backend"]
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ start-feature-console:
start-feature-backend:
go run ./cmd/plugin-backend.go -port='9443' -config-path='./config' -static-path='./web/dist' -features='${FEATURES}'

.PHONY: start-devspace-backend
start-devspace-backend:
/opt/app-root/plugin-backend -port='9443' -cert='/var/cert/tls.crt' -key='/var/cert/tls.key' -static-path='/opt/app-root/web/dist' -config-path='/opt/app-root/config' -features='${FEATURES}'

.PHONY: podman-cross-build
podman-cross-build:
podman manifest create ${IMAGE}
Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ The monitoring-plugin is currently in a transitionary state as the remaining pag

Changes to the store must be completed in the `openshift/console` codebase and are not backwards compatible unless cherry-picked with purpose.

### Running using Devspace

Install the [devspace](https://www.devspace.sh/docs/getting-started/installation) cli.

1. Install the frontend dependencies running `make install-frontend`.
2. Start the frontend `make start-feature-frontend`.
4. Select the namespace the monitoring-plugin is located in `devspace use namespace openshift-monitoring`.
5. In a different terminal start the devspace sync `devspace dev`.

When running the `devspace dev` command, the pipeline will run the `scale_down_cmo` function to prevent CMO from fighting over control of the pod. After CMO has been scaled down, devspace will "take over" the monitoring-plugin pod, grabbing all of the certificates and backend binary and configuration to run in the devspace pod. The backend will stay the same as what is built in the Dockerfile.devspace file, only the frontend changes will be reflected live in cluster.

After the pod has been "taken over" Devspace begins a sync process which will mirror changes from you local `./web/dist` folder into the `/opt/app-root/web/dist` folder in the devspace pod. You can then make changes to your frontend files locally which will trigger the locally running webpack dev server to rebuild the `./web/dist` folder, which will trigger Devspace to re-synced. You can then reload your console webpage to see your local changes running in the cluster.

After development you can run `devspace purge` which will cleanup and then call the `scale_up_cmo` pipeline.

### Local Development

#### Dependencies
Expand Down Expand Up @@ -192,6 +207,4 @@ oc port-forward -n openshift-monitoring service/prometheus-operated 9090:9090
curl "http://localhost:9090/api/v1/query?query=up"
```

Adjust Perses local instance http://localhost:8080/ to use the a proxy to http://localhost:9090/ instead of http://demo.prometheus.io.


Adjust Perses local instance http://localhost:8080/ to use the a proxy to http://localhost:9090/ instead of http://demo.prometheus.io.
2 changes: 2 additions & 0 deletions charts/openshift-console-plugin/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ Selector labels
{{- if or (.Values.plugin.features.acm.enabled) (.Values.plugin.features.incidents.enabled) }}
app: {{ .Values.plugin.features.name }}
app.kubernetes.io/name: {{ .Values.plugin.features.name }}
app.kubernetes.io/component: {{ .Values.plugin.features.name }}
app.kubernetes.io/part-of: {{ .Values.plugin.features.name }}
{{- else }}
app: {{ include "openshift-console-plugin.name" . }}
app.kubernetes.io/component: {{ .Values.plugin.features.name }}
app.kubernetes.io/name: {{ include "openshift-console-plugin.name" . }}
app.kubernetes.io/part-of: {{ include "openshift-console-plugin.name" . }}
{{- end }}
Expand Down
14 changes: 14 additions & 0 deletions devspace-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This is a list of `deployments` that DevSpace can create for this project
app:
# This deployment uses `helm` but you can also define `kubectl` deployments or kustomizations
helm:
# We are deploying this project with the Helm chart you provided
chart:
name: ./charts/openshift-console-plugin
# Under `values` we can define the values for this Helm chart used during `helm install/upgrade`
# You may also use `valuesFiles` to load values from files, e.g. valuesFiles: ["values.yaml"]
valuesFiles: ["./charts/openshift-console-plugin/values.yaml"]
values:
plugin:
image: "quay.io/rh-ee-pyurkovi/monitoring-plugin:v4.21"
namespace: ${DEVSPACE_NAMESPACE}
48 changes: 48 additions & 0 deletions devspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: v2beta1
name: monitoring-plugin

vars:
USE_HELM:
question: Do you want to deploy using helm? (y/[n])
default: "n"
noCache: true

functions:
scale_down_cmo: |-
oc patch clusterversion version --type json -p "$(cat ./web/cypress/fixtures/cmo/disable-monitoring.yaml)"
kubectl scale --replicas=0 -n ${DEVSPACE_NAMESPACE} deployment/cluster-monitoring-operator
scale_up_cmo: |-
kubectl scale --replicas=1 -n ${DEVSPACE_NAMESPACE} deployment/cluster-monitoring-operator

# This is a list of `pipelines` that DevSpace can execute (you can define your own)
pipelines:
# This is the pipeline for the main command: `devspace dev` (or `devspace run-pipeline dev`)
dev:
run: |-
scale_down_cmo
start_dev app
purge:
run: |-
stop_dev --all
scale_up_cmo

deployments: $( [ ${USE_HELM} == "y" ] && cat devspace-deployment.yaml || echo "app:")

# This is a list of `dev` containers that are based on the containers created by your deployments
dev:
app:
# Search for the container that runs this image
labelSelector:
# Use the instance selector that CMO & helm add
app.kubernetes.io/component: monitoring-plugin
# Replace the container image with this dev-optimized image (allows to skip image building during development)
devImage: quay.io/rh-ee-pyurkovi/monitoring-plugin:devspace-2
# Sync files between the local filesystem and the development container
sync:
- path: ./web/dist:/opt/app-root/web/dist
startContainer: true
command: ["make"]
args: ["start-devspace-backend"]
# Inject a lightweight SSH server into the container (so your IDE can connect to the remote dev env)
ssh:
enabled: true
40 changes: 40 additions & 0 deletions devspace_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
set +e # Continue on errors

export NODE_ENV=development
npm install

COLOR_BLUE="\033[0;94m"
COLOR_GREEN="\033[0;92m"
COLOR_RESET="\033[0m"

# Print useful output for user
echo -e "${COLOR_BLUE}
%########%
%###########% ____ _____
%#########% | _ \ ___ __ __ / ___/ ____ ____ ____ ___
%#########% | | | | / _ \\\\\ \ / / \___ \ | _ \ / _ | / __// _ \\
%#############% | |_| |( __/ \ V / ____) )| |_) )( (_| |( (__( __/
%#############% |____/ \___| \_/ \____/ | __/ \__,_| \___\\\\\___|
%###############% |_|
%###########%${COLOR_RESET}


Welcome to your development container!

This is how you can work with it:
- Files will be synchronized between your local machine and this container
- Some ports will be forwarded, so you can access this container via localhost
- Run \`${COLOR_GREEN}npm start${COLOR_RESET}\` to start the application
"

# Set terminal prompt
export PS1="\[${COLOR_BLUE}\]devspace\[${COLOR_RESET}\] ./\W \[${COLOR_BLUE}\]\\$\[${COLOR_RESET}\] "
if [ -z "$BASH" ]; then export PS1="$ "; fi

# Include project's bin/ folder in PATH
export PATH="./bin:$PATH"

# Open shell
bash --norc
devspace-start