Skip to content

Commit 79dfae6

Browse files
feat: add devspace setup
a
1 parent 4e1f998 commit 79dfae6

7 files changed

Lines changed: 137 additions & 2 deletions

File tree

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ web/cypress/videos/
77
web/dist/
88
web/node_modules/
99
plugin-backend
10-
# adding these while the PR is in review. This should be removed after
10+
# Leave these permanently for backwards compatability for backporting
1111
node_modules/
1212
dist/
13-
web/po-files/
13+
.devspace
14+
web/po-files/

Dockerfile.devspace

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_9_golang_1.24 AS web-builder
2+
3+
WORKDIR /opt/app-root
4+
5+
USER 0
6+
RUN chgrp -R 0 /opt/app-root
7+
RUN chmod -R g+rw /opt/app-root
8+
RUN mkdir /.devspace
9+
RUN chgrp -R 0 /.devspace
10+
RUN chmod -R g+rw /.devspace
11+
12+
ENV HUSKY=0
13+
14+
COPY Makefile Makefile
15+
COPY go.mod go.mod
16+
COPY go.sum go.sum
17+
18+
RUN make install-backend
19+
20+
COPY config/ config/
21+
COPY cmd/ cmd/
22+
COPY pkg/ pkg/
23+
24+
RUN make build-backend
25+
26+
ENTRYPOINT ["make", "start-devspace-backend"]

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ start-feature-console:
9999
start-feature-backend:
100100
go run ./cmd/plugin-backend.go -port='9443' -config-path='./config' -static-path='./web/dist' -features='${FEATURES}'
101101

102+
.PHONY: start-devspace-backend
103+
start-devspace-backend:
104+
/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}'
105+
102106
.PHONY: podman-cross-build
103107
podman-cross-build:
104108
podman manifest create ${IMAGE}

charts/openshift-console-plugin/templates/_helpers.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ Selector labels
3232
{{- if or (.Values.plugin.features.acm.enabled) (.Values.plugin.features.incidents.enabled) }}
3333
app: {{ .Values.plugin.features.name }}
3434
app.kubernetes.io/name: {{ .Values.plugin.features.name }}
35+
app.kubernetes.io/component: {{ .Values.plugin.features.name }}
3536
app.kubernetes.io/part-of: {{ .Values.plugin.features.name }}
3637
{{- else }}
3738
app: {{ include "openshift-console-plugin.name" . }}
39+
app.kubernetes.io/component: {{ .Values.plugin.features.name }}
3840
app.kubernetes.io/name: {{ include "openshift-console-plugin.name" . }}
3941
app.kubernetes.io/part-of: {{ include "openshift-console-plugin.name" . }}
4042
{{- end }}

devspace-deployment.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This is a list of `deployments` that DevSpace can create for this project
2+
app:
3+
# This deployment uses `helm` but you can also define `kubectl` deployments or kustomizations
4+
helm:
5+
# We are deploying this project with the Helm chart you provided
6+
chart:
7+
name: ./charts/openshift-console-plugin
8+
# Under `values` we can define the values for this Helm chart used during `helm install/upgrade`
9+
# You may also use `valuesFiles` to load values from files, e.g. valuesFiles: ["values.yaml"]
10+
valuesFiles: ["./charts/openshift-console-plugin/values.yaml"]
11+
values:
12+
plugin:
13+
image: "quay.io/rh-ee-pyurkovi/monitoring-plugin:v4.21"
14+
namespace: ${DEVSPACE_NAMESPACE}

devspace.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
version: v2beta1
2+
name: monitoring-plugin
3+
4+
vars:
5+
USE_HELM:
6+
question: Do you want to deploy using helm? (y/[n])
7+
default: "n"
8+
noCache: true
9+
10+
functions:
11+
scale_down_cmo: |-
12+
oc patch clusterversion version --type json -p "$(cat ./web/cypress/fixtures/cmo/disable-monitoring.yaml)"
13+
kubectl scale --replicas=0 -n ${DEVSPACE_NAMESPACE} deployment/cluster-monitoring-operator
14+
scale_up_cmo: |-
15+
kubectl scale --replicas=1 -n ${DEVSPACE_NAMESPACE} deployment/cluster-monitoring-operator
16+
17+
# This is a list of `pipelines` that DevSpace can execute (you can define your own)
18+
pipelines:
19+
# This is the pipeline for the main command: `devspace dev` (or `devspace run-pipeline dev`)
20+
dev:
21+
run: |-
22+
scale_down_cmo
23+
start_dev app
24+
purge:
25+
run: |-
26+
stop_dev --all
27+
scale_up_cmo
28+
29+
deployments: $( [ ${USE_HELM} == "y" ] && cat devspace-deployment.yaml || echo "app:")
30+
31+
# This is a list of `dev` containers that are based on the containers created by your deployments
32+
dev:
33+
app:
34+
# Search for the container that runs this image
35+
labelSelector:
36+
# Use the instance selector that CMO & helm add
37+
app.kubernetes.io/component: monitoring-plugin
38+
# Replace the container image with this dev-optimized image (allows to skip image building during development)
39+
devImage: quay.io/rh-ee-pyurkovi/monitoring-plugin:devspace-2
40+
# Sync files between the local filesystem and the development container
41+
sync:
42+
- path: ./web/dist:/opt/app-root/web/dist
43+
startContainer: true
44+
command: ["make"]
45+
args: ["start-devspace-backend"]
46+
# Inject a lightweight SSH server into the container (so your IDE can connect to the remote dev env)
47+
ssh:
48+
enabled: true

devspace_start.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
set +e # Continue on errors
3+
4+
export NODE_ENV=development
5+
npm install
6+
7+
COLOR_BLUE="\033[0;94m"
8+
COLOR_GREEN="\033[0;92m"
9+
COLOR_RESET="\033[0m"
10+
11+
# Print useful output for user
12+
echo -e "${COLOR_BLUE}
13+
%########%
14+
%###########% ____ _____
15+
%#########% | _ \ ___ __ __ / ___/ ____ ____ ____ ___
16+
%#########% | | | | / _ \\\\\ \ / / \___ \ | _ \ / _ | / __// _ \\
17+
%#############% | |_| |( __/ \ V / ____) )| |_) )( (_| |( (__( __/
18+
%#############% |____/ \___| \_/ \____/ | __/ \__,_| \___\\\\\___|
19+
%###############% |_|
20+
%###########%${COLOR_RESET}
21+
22+
23+
Welcome to your development container!
24+
25+
This is how you can work with it:
26+
- Files will be synchronized between your local machine and this container
27+
- Some ports will be forwarded, so you can access this container via localhost
28+
- Run \`${COLOR_GREEN}npm start${COLOR_RESET}\` to start the application
29+
"
30+
31+
# Set terminal prompt
32+
export PS1="\[${COLOR_BLUE}\]devspace\[${COLOR_RESET}\] ./\W \[${COLOR_BLUE}\]\\$\[${COLOR_RESET}\] "
33+
if [ -z "$BASH" ]; then export PS1="$ "; fi
34+
35+
# Include project's bin/ folder in PATH
36+
export PATH="./bin:$PATH"
37+
38+
# Open shell
39+
bash --norc
40+
devspace-start

0 commit comments

Comments
 (0)