Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure other than Backstage container to mount PVC volume to #582

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
rollback rhdh config
Signed-off-by: gazarenkov <[email protected]>
gazarenkov committed Dec 19, 2024

Verified

This commit was signed with the committer’s verified signature.
gazarenkov Gennady Azarenkov
commit 1faa96eae0f77133df8d708142fc53805beae131
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ metadata:
categories: Developer Tools
certified: "true"
containerImage: registry-proxy.engineering.redhat.com/rh-osbs/rhdh-rhdh-rhel9-operator:1.3
createdAt: "2024-12-18T09:01:35Z"
createdAt: "2024-12-19T17:20:07Z"
description: Red Hat Developer Hub is a Red Hat supported version of Backstage.
It comes with pre-built plug-ins and configuration settings, supports use of
an external database, and can help streamline the process of setting up a self-managed
18 changes: 16 additions & 2 deletions bundle/rhdh/manifests/rhdh-default-config_v1_configmap.yaml
Original file line number Diff line number Diff line change
@@ -174,6 +174,15 @@ data:
#securityContext:
# fsGroup: 1001
volumes:
- ephemeral:
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
name: dynamic-plugins-root
- name: dynamic-plugins-npmrc
secret:
defaultMode: 420
@@ -190,7 +199,7 @@ data:
- name: install-dynamic-plugins
command:
- ./install-dynamic-plugins.sh
- /opt/app-root/src/dynamic-plugins-root
- /dynamic-plugins-root
# image will be replaced by the value of the `RELATED_IMAGE_backstage` env var, if set
image: quay.io/rhdh/rhdh-hub-rhel9:next
imagePullPolicy: IfNotPresent
@@ -201,11 +210,13 @@ data:
type: RuntimeDefault
capabilities:
drop:
- ALL
- ALL
env:
- name: NPM_CONFIG_USERCONFIG
value: /opt/app-root/src/.npmrc.dynamic-plugins
volumeMounts:
- mountPath: /dynamic-plugins-root
name: dynamic-plugins-root
- mountPath: /opt/app-root/src/.npmrc.dynamic-plugins
name: dynamic-plugins-npmrc
readOnly: true
@@ -286,6 +297,9 @@ data:
env:
- name: APP_CONFIG_backend_listen_port
value: "7007"
volumeMounts:
- mountPath: /opt/app-root/src/dynamic-plugins-root
name: dynamic-plugins-root
resources:
requests:
cpu: 250m
18 changes: 16 additions & 2 deletions config/profile/rhdh/default-config/deployment.yaml
Original file line number Diff line number Diff line change
@@ -19,6 +19,15 @@ spec:
#securityContext:
# fsGroup: 1001
volumes:
- ephemeral:
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
name: dynamic-plugins-root
- name: dynamic-plugins-npmrc
secret:
defaultMode: 420
@@ -35,7 +44,7 @@ spec:
- name: install-dynamic-plugins
command:
- ./install-dynamic-plugins.sh
- /opt/app-root/src/dynamic-plugins-root
- /dynamic-plugins-root
# image will be replaced by the value of the `RELATED_IMAGE_backstage` env var, if set
image: quay.io/rhdh/rhdh-hub-rhel9:next
imagePullPolicy: IfNotPresent
@@ -46,11 +55,13 @@ spec:
type: RuntimeDefault
capabilities:
drop:
- ALL
- ALL
env:
- name: NPM_CONFIG_USERCONFIG
value: /opt/app-root/src/.npmrc.dynamic-plugins
volumeMounts:
- mountPath: /dynamic-plugins-root
name: dynamic-plugins-root
- mountPath: /opt/app-root/src/.npmrc.dynamic-plugins
name: dynamic-plugins-npmrc
readOnly: true
@@ -131,6 +142,9 @@ spec:
env:
- name: APP_CONFIG_backend_listen_port
value: "7007"
volumeMounts:
- mountPath: /opt/app-root/src/dynamic-plugins-root
name: dynamic-plugins-root
resources:
requests:
cpu: 250m
38 changes: 20 additions & 18 deletions integration_tests/rhdh-config_test.go
Original file line number Diff line number Diff line change
@@ -45,18 +45,18 @@ var _ = When("create default rhdh", func() {
_, initCont := model.DynamicPluginsInitContainer(deploy.Spec.Template.Spec.InitContainers)

g.Expect(initCont.VolumeMounts).To(HaveLen(5))
g.Expect(initCont.VolumeMounts[4].MountPath).To(Equal("/opt/app-root/src/dynamic-plugins-root"))
g.Expect(initCont.VolumeMounts[4].SubPath).To(BeEmpty())
g.Expect(initCont.VolumeMounts[0].MountPath).To(Equal("/opt/app-root/src/.npmrc.dynamic-plugins"))
g.Expect(initCont.VolumeMounts[0].SubPath).To(Equal(".npmrc"))
g.Expect(initCont.VolumeMounts[1].MountPath).To(Equal("/opt/app-root/src/.config/containers"))
g.Expect(initCont.VolumeMounts[2].MountPath).To(Equal("/opt/app-root/src/.npm/_cacache"))
g.Expect(initCont.VolumeMounts[2].SubPath).To(BeEmpty())
g.Expect(initCont.VolumeMounts[3].MountPath).To(Equal("/opt/app-root/src/dynamic-plugins.yaml"))
g.Expect(initCont.VolumeMounts[3].SubPath).To(Equal("dynamic-plugins.yaml"))
g.Expect(initCont.VolumeMounts[3].Name).
g.Expect(initCont.VolumeMounts[0].MountPath).To(Equal("/dynamic-plugins-root"))
g.Expect(initCont.VolumeMounts[0].SubPath).To(BeEmpty())
g.Expect(initCont.VolumeMounts[1].MountPath).To(Equal("/opt/app-root/src/.npmrc.dynamic-plugins"))
g.Expect(initCont.VolumeMounts[1].SubPath).To(Equal(".npmrc"))
g.Expect(initCont.VolumeMounts[2].MountPath).To(Equal("/opt/app-root/src/.config/containers"))
g.Expect(initCont.VolumeMounts[3].MountPath).To(Equal("/opt/app-root/src/.npm/_cacache"))
g.Expect(initCont.VolumeMounts[3].SubPath).To(BeEmpty())
g.Expect(initCont.VolumeMounts[4].MountPath).To(Equal("/opt/app-root/src/dynamic-plugins.yaml"))
g.Expect(initCont.VolumeMounts[4].SubPath).To(Equal("dynamic-plugins.yaml"))
g.Expect(initCont.VolumeMounts[4].Name).
To(Equal(utils.GenerateVolumeNameFromCmOrSecret(model.DynamicPluginsDefaultName(backstageName))))
g.Expect(initCont.VolumeMounts[3].SubPath).To(Equal(model.DynamicPluginsFile))
g.Expect(initCont.VolumeMounts[4].SubPath).To(Equal(model.DynamicPluginsFile))

g.Expect(initCont.Env[0].Name).To(Equal("NPM_CONFIG_USERCONFIG"))
g.Expect(initCont.Env[0].Value).To(Equal("/opt/app-root/src/.npmrc.dynamic-plugins"))
@@ -71,10 +71,10 @@ var _ = When("create default rhdh", func() {
g.Expect(mainCont.Args[3]).To(Equal("/opt/app-root/src/default.app-config.yaml"))

g.Expect(mainCont.VolumeMounts).To(HaveLen(2))
g.Expect(mainCont.VolumeMounts[1].MountPath).To(Equal("/opt/app-root/src/dynamic-plugins-root"))
g.Expect(mainCont.VolumeMounts[1].SubPath).To(BeEmpty())
g.Expect(mainCont.VolumeMounts[0].MountPath).To(Equal("/opt/app-root/src/default.app-config.yaml"))
g.Expect(mainCont.VolumeMounts[0].SubPath).To(Equal("default.app-config.yaml"))
g.Expect(mainCont.VolumeMounts[0].MountPath).To(Equal("/opt/app-root/src/dynamic-plugins-root"))
g.Expect(mainCont.VolumeMounts[0].SubPath).To(BeEmpty())
g.Expect(mainCont.VolumeMounts[1].MountPath).To(Equal("/opt/app-root/src/default.app-config.yaml"))
g.Expect(mainCont.VolumeMounts[1].SubPath).To(Equal("default.app-config.yaml"))

//g.Expect(mainCont.VolumeMounts[3].MountPath).To(Equal(fmt.Sprintf("/opt/app-root/src/backstage-%s-dynamic-plugins", backstageName)))

@@ -85,7 +85,10 @@ var _ = When("create default rhdh", func() {

It("replaces dynamic-plugins-root volume", func() {

// This test relies on the fact that RHDH default deployment config contains dynamic-plugins-root volume
// This test relies on the fact that RHDH default config for deployment contains
// volumes:
// - ephemeral:
// name: dynamic-plugins-root
// and check if it replaced with one defined in spec.deployment

ctx := context.Background()
@@ -96,7 +99,6 @@ var _ = When("create default rhdh", func() {
Expect(err).To(Not(HaveOccurred()))

backstageName := createAndReconcileBackstage(ctx, ns, bs2.Spec, "")
volumeName := model.PvcsName(backstageName, "dynamic-plugins-root")

Eventually(func(g Gomega) {
By("getting the Deployment ")
@@ -107,7 +109,7 @@ var _ = When("create default rhdh", func() {
var bsvolume *corev1.Volume
for _, v := range deploy.Spec.Template.Spec.Volumes {

if v.Name == volumeName {
if v.Name == "dynamic-plugins-root" {
bsvolume = &v
break
}