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

Layered operator #272

Merged
merged 173 commits into from Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
cfb83b2
yaml/configMap default configuration
gazarenkov Nov 28, 2023
c952470
Merge remote-tracking branch 'upstream/main' into status2
gazarenkov Nov 28, 2023
9563358
fix make test
gazarenkov Nov 28, 2023
46f0e7f
Merge remote-tracking branch 'upstream/main' into status2
gazarenkov Nov 30, 2023
99b4e54
fix with new objects
gazarenkov Nov 30, 2023
cffa417
fix with new objects
gazarenkov Nov 30, 2023
2bf0716
config small fixes
gazarenkov Nov 30, 2023
47ba2f9
fix for https://github.com/janus-idp/operator/issues/51
gazarenkov Nov 30, 2023
5882f62
Merge branch 'main' of https://github.com/janus-idp/operator into sta…
gazarenkov Dec 2, 2023
4863874
Merge branch 'main' of https://github.com/janus-idp/operator into doc
gazarenkov Dec 6, 2023
4bdb1a0
fix for https://github.com/janus-idp/operator/issues/58
gazarenkov Dec 6, 2023
971a50c
init next (design improvement)
gazarenkov Dec 7, 2023
93d3de7
initial model
gazarenkov Dec 12, 2023
6da447e
initial model
gazarenkov Dec 12, 2023
8d8b84c
initial
gazarenkov Dec 13, 2023
f6a37c0
Merge remote-tracking branch 'upstream/main' into next
gazarenkov Dec 13, 2023
ac60557
initial
gazarenkov Dec 13, 2023
eb5f305
initial
gazarenkov Dec 15, 2023
19d923d
format and license
gazarenkov Dec 15, 2023
267a166
factory and pswd generator
gazarenkov Dec 17, 2023
20fbc03
delete onCreate handler
gazarenkov Dec 18, 2023
089f56c
support configmapfiles, dynamic-plugins
gazarenkov Dec 19, 2023
a1a671a
initial model test framework
gazarenkov Dec 19, 2023
a138de1
configurations
gazarenkov Dec 26, 2023
48a88ab
more comments and tests
gazarenkov Dec 28, 2023
8436faa
add more tests, remove old logic of object creation
gazarenkov Jan 4, 2024
18119c6
add more tests, remove old logic of object creation
gazarenkov Jan 5, 2024
7f937ba
add support of keys, integration tests passed
gazarenkov Jan 8, 2024
bb311a7
add support of keys, integration tests passed
gazarenkov Jan 8, 2024
63254a0
fix npe
gazarenkov Jan 8, 2024
3ddc1a6
cm envs
gazarenkov Jan 9, 2024
a8546da
Merge remote-tracking branch 'upstream/main' into next
gazarenkov Jan 9, 2024
e01826c
tmp
gazarenkov Jan 9, 2024
f413fc4
maintain images env var
gazarenkov Jan 9, 2024
6df33bd
fix lint
gazarenkov Jan 9, 2024
14dfdc6
remove unused params in status
gazarenkov Jan 9, 2024
9517959
fix make release-build
gazarenkov Jan 10, 2024
e24518d
fix default images
gazarenkov Jan 11, 2024
90acacd
several fixes
gazarenkov Jan 11, 2024
e9e115e
fix route.Spec.To.Name
gazarenkov Jan 11, 2024
2bd9697
fix image env vars
gazarenkov Jan 11, 2024
aca67ba
fix dynamic plugins
gazarenkov Jan 12, 2024
fd2e042
Merge remote-tracking branch 'upstream/main' into next
gazarenkov Jan 12, 2024
3a58242
fix
gazarenkov Jan 12, 2024
6c5cb9d
dynamic-plugins test
gazarenkov Jan 15, 2024
2c44c4e
remove ownership of depl, ss, service
gazarenkov Jan 15, 2024
245c6c1
DbSecret and Route
gazarenkov Jan 22, 2024
3877ae9
clean up
gazarenkov Jan 22, 2024
2dceb0d
make test
gazarenkov Jan 22, 2024
da7d4cd
Merge remote-tracking branch 'upstream/main' into next
gazarenkov Jan 23, 2024
ee7654e
clean db
gazarenkov Jan 24, 2024
dcd9d92
Merge remote-tracking branch 'upstream/main' into next
gazarenkov Jan 25, 2024
98255bb
status
gazarenkov Jan 25, 2024
6debb33
Merge remote-tracking branch 'upstream/main' into next
gazarenkov Jan 25, 2024
0d4552d
fix gosec
gazarenkov Jan 25, 2024
b087290
cleanup
gazarenkov Jan 26, 2024
52c9b87
route fix
gazarenkov Jan 26, 2024
abfd664
patch and route
gazarenkov Jan 29, 2024
a6d4d79
fix lint
gazarenkov Jan 29, 2024
169732b
fix
gazarenkov Feb 1, 2024
e40d734
working...
gazarenkov Feb 5, 2024
69cbc81
temp
gazarenkov Feb 7, 2024
896c21a
refactor runtime
gazarenkov Feb 8, 2024
157f98c
temp
gazarenkov Feb 9, 2024
017ccf7
temp
gazarenkov Feb 10, 2024
29b713c
tmp
gazarenkov Feb 12, 2024
50d9c2d
temp
gazarenkov Feb 20, 2024
da0509a
dbsecret
gazarenkov Feb 22, 2024
d8d68fa
fix
gazarenkov Feb 26, 2024
a9ecc07
fix
gazarenkov Feb 27, 2024
a8dca90
operator-script
gazarenkov Feb 27, 2024
0ec603d
fix
gazarenkov Feb 28, 2024
0e3135b
test
gazarenkov Mar 5, 2024
cf13c40
fix
gazarenkov Mar 5, 2024
428859f
rename module
gazarenkov Mar 7, 2024
4e189d5
types
gazarenkov Mar 7, 2024
6e112c5
ctrl test fixed
gazarenkov Mar 8, 2024
2097441
ctrl test fixed
gazarenkov Mar 8, 2024
71c5fe9
fix
gazarenkov Mar 8, 2024
246064c
container permissions
gazarenkov Mar 11, 2024
9a7d5aa
chore: gosec check is looking for a build stage, so give it one (#163)
nickboldt Jan 29, 2024
d2d5f96
chore: only generate PR previews and next... (#161)
nickboldt Jan 29, 2024
2f4c3e9
no-op to test if new PR check will skip... (#164)
nickboldt Jan 29, 2024
31e29a3
chore: multiline env var; explicitly check diff against HEAD~1 (#167)
nickboldt Jan 29, 2024
2218fa3
chore: skip the golang build if there's no... (#168)
nickboldt Jan 29, 2024
9817300
chore: use multiline github env; check HEAD~1 for diff; reorder regex…
nickboldt Jan 29, 2024
49616e5
chore: no auth needed to run tests (#171)
nickboldt Jan 29, 2024
6d4dbfe
move env.CHANGES check to substages as that's where env is defined (#…
nickboldt Jan 29, 2024
30dd487
bump to latest actions (node 16 -> 20) (#172)
nickboldt Jan 29, 2024
7b9c6a1
chore: move commit check into the same job as the build as it seems e…
nickboldt Jan 29, 2024
15daa4e
chore: fix: remove dep on other job (#175)
nickboldt Jan 29, 2024
7d96f67
chore: move commit check into the same job as the build as it seems e…
nickboldt Jan 29, 2024
ddf9b7f
Security mitigation: remove secret get from RBAC (#160)
jianrongzhang89 Jan 30, 2024
167874a
Code cleanup: remove unused clientset
jianrongzhang89 Jan 30, 2024
c3d2834
chore: label every new issue with jira label (#181)
kadel Jan 31, 2024
68b2cc1
chore: bump csv to 1.2 in main
nickboldt Feb 1, 2024
e9cfde0
chore: RHIDP-855 tweak csv/operator/subscription descriptions
nickboldt Feb 5, 2024
903b8c1
Add instructions for installing CI Builds and move install scripts he…
rm3l Feb 6, 2024
0bb142b
chore: RHIDP-855 rename the operator to append 'Operator' on it; rela…
nickboldt Feb 6, 2024
b6f0110
Documentation for security mitigation (#182)
jianrongzhang89 Feb 8, 2024
c683ecb
Add script and docs for air-gapped/restricted env setup (#183)
nickboldt Feb 8, 2024
61e8283
Fix sonarlint vulnerabilities (initial) (#185)
gazarenkov Feb 12, 2024
84d7218
Avoid hardcoded images (#187)
gazarenkov Feb 13, 2024
da211c0
Port latest changes (automountServiceAccountToken and ephemeral stora…
rm3l Feb 13, 2024
9b5bdd8
Fix service raw configuration (#203)
gazarenkov Feb 16, 2024
caadc50
Set `VERSION` to `0.1.0-dev` in Makefile for `main` branch (#207)
rm3l Feb 16, 2024
228172a
Fix tags for images built for main and release branches (#208)
rm3l Feb 16, 2024
14668bf
Replace operator API group janus-idp.io with rhdh.redhat.com (#201)
jianrongzhang89 Feb 17, 2024
e6dab7e
Add warning note in install docs about OpenShift clusters with hosted…
rm3l Feb 17, 2024
680d818
Fix diff computation for PR container builds
rm3l Feb 17, 2024
d9b076f
Fix generated CSV (#212)
rm3l Feb 20, 2024
d6686ff
Set `VERSION` to `0.2.0` in Makefile for `main` branch (#213)
rm3l Feb 20, 2024
00f56bf
Fix typo (#214)
masayag Feb 20, 2024
c02120a
update dependencies (#215)
kim-tsao Feb 21, 2024
50d3c41
[ci skip] chore: enable renovate for dockerfile and golang updates (#…
nickboldt Feb 21, 2024
333b9f0
chore(deps): update actions/cache action to v4 (#220)
renovate[bot] Feb 21, 2024
c7ba44c
chore(deps): update docker/login-action action to v3 (#223)
renovate[bot] Feb 21, 2024
29f7904
chore(deps): update actions/github-script action to v7 (#222)
renovate[bot] Feb 21, 2024
ab42ffe
bump dockerfiles per renovate bot PR #219 (#224)
nickboldt Feb 21, 2024
71460b2
chore: enable digest pinning and major updates in dockerfiles; attemp…
nickboldt Feb 22, 2024
3ab0b87
Update renovate.json - remove non-working code (#227)
nickboldt Feb 22, 2024
ca782d6
Update renovate.json - don't pin digests in dockerfile as it creates …
nickboldt Feb 22, 2024
4744fa3
chore(deps): pin dependencies (#228)
renovate[bot] Feb 22, 2024
72d133c
chore(deps): update github/codeql-action digest to 47b3d88 (#234)
renovate[bot] Feb 26, 2024
99c7dea
feat(seamless) chore: add `skipranges` and `replaces` logic TODOs to …
nickboldt Feb 26, 2024
38b1ff6
Add E2E tests using our examples against real clusters (#204)
rm3l Feb 26, 2024
dda51d9
chore(deps): pin actions/checkout action to b4ffde6 (#235)
renovate[bot] Feb 26, 2024
f1bbe11
chore(deps): update docker/setup-buildx-action digest to 0d103c3 (#239)
renovate[bot] Feb 27, 2024
39cab1d
fix: increase default size of the dynamic-plugins-root volume from 1G…
rm3l Feb 27, 2024
1bfb4ce
chore: RHIDP-1105 fix bundle annotations to be version agnostic; tran…
nickboldt Feb 27, 2024
5e87394
Generate deployment manifest (#242)
gazarenkov Feb 28, 2024
265b62f
chore: RHIDP-1105 switch annotations.yaml back to use fast channels; …
nickboldt Feb 28, 2024
5fab29b
chore(deps): update actions/cache digest to ab5e6d0 (#248)
renovate[bot] Mar 2, 2024
6714198
chore(deps): update github/codeql-action digest to 8a470fd (#247)
renovate[bot] Mar 2, 2024
0ea1ad9
Auto-push bundle manifests changes to PR branch if needed (#195)
rm3l Mar 6, 2024
98165f5
chore(CI): Fix PR Bundle diff checker GH workflow
rm3l Mar 6, 2024
48f030c
chore(deps): pin dependencies (#249)
renovate[bot] Mar 6, 2024
4684eda
fix(deps): update k8s.io/utils digest to e7106e6 (#232)
renovate[bot] Mar 6, 2024
2a5b99a
chore(deps): update docker/build-push-action digest to af5a7ed (#250)
renovate[bot] Mar 8, 2024
f675802
fix(deps): update k8s.io/utils digest to 4693a02 (#253)
renovate[bot] Mar 11, 2024
a786b66
layered
gazarenkov Mar 13, 2024
2cda2c1
layered
gazarenkov Mar 17, 2024
53e7603
chore(deps): update actions/checkout digest to 9bb5618 (#255)
renovate[bot] Mar 12, 2024
7b01131
chore(deps): update actions/checkout digest to b4ffde6 (#256)
renovate[bot] Mar 12, 2024
4cdc82d
chore(deps): update github/codeql-action digest to 3ab4101 (#257)
renovate[bot] Mar 12, 2024
3df1099
Bump Ginkgo to v2.16.0 (#251)
rm3l Mar 13, 2024
4b06b33
chore(deps): update docker/login-action digest to e92390c (#258)
renovate[bot] Mar 13, 2024
791c842
chore(deps): update docker/build-push-action digest to 2cdde99 (#259)
renovate[bot] Mar 14, 2024
3782e36
chore(deps): update docker/setup-buildx-action digest to 2b51285 (#260)
renovate[bot] Mar 14, 2024
6702639
fix(deps): update all non-major dependencies (#233)
renovate[bot] Mar 14, 2024
9258f9f
fix(deps): update github.com/openshift/api digest to 4caef7f (#229)
renovate[bot] Mar 14, 2024
d9ecb8e
gomod
gazarenkov Mar 17, 2024
4a95038
gomod
gazarenkov Mar 17, 2024
a58257d
nextv2
gazarenkov Mar 20, 2024
f6de7ae
Merge remote-tracking branch 'upstream/main' into nextv2
gazarenkov Mar 20, 2024
3bdb65c
Regenerate bundle manifests
github-actions[bot] Mar 20, 2024
a39b42f
fix lint
gazarenkov Mar 20, 2024
63b4944
Merge remote-tracking branch 'upstream/main' into nextv2
gazarenkov Mar 20, 2024
0f339b9
Merge remote-tracking branch 'origin/nextv2' into nextv2
gazarenkov Mar 20, 2024
0d4ea58
Merge remote-tracking branch 'origin/main' into nextv2
gazarenkov Mar 20, 2024
eab0ffe
fix lint
gazarenkov Mar 20, 2024
0f15e00
fix sonar issues
gazarenkov Mar 23, 2024
d2dd31e
fix minor sonar issues
gazarenkov Mar 23, 2024
56e8f77
fix e2e tests
gazarenkov Apr 1, 2024
a6506ae
fix e2e and add external db secret test
gazarenkov Apr 1, 2024
e84d054
small fixes
gazarenkov Apr 1, 2024
ee299e8
small fixes
gazarenkov Apr 1, 2024
fd77255
Merge remote-tracking branch 'upstream/main' into nextv2
gazarenkov Apr 1, 2024
da2b990
merge
gazarenkov Apr 1, 2024
e6c56ce
Regenerate bundle manifests
github-actions[bot] Apr 1, 2024
ab6b1bd
Update examples/rhdh-cr-with-app-configs.yaml
gazarenkov Apr 3, 2024
9f9829d
Update Makefile
gazarenkov Apr 3, 2024
73f77d0
Update Makefile
rm3l Apr 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 12 additions & 5 deletions Makefile
gazarenkov marked this conversation as resolved.
Show resolved Hide resolved
Expand Up @@ -131,6 +131,12 @@ test: manifests generate fmt vet envtest ## Run tests. We need LOCALBIN=$(LOCALB
mkdir -p $(LOCALBIN)/default-config && cp config/manager/$(CONF_DIR)/* $(LOCALBIN)/default-config
LOCALBIN=$(LOCALBIN) KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $(PKGS) -coverprofile cover.out

.PHONY: integration-test
integration-test: ginkgo manifests generate fmt vet envtest ## Run integration_tests. We need LOCALBIN=$(LOCALBIN) to get correct default-config path
mkdir -p $(LOCALBIN)/default-config && cp config/manager/$(CONF_DIR)/* $(LOCALBIN)/default-config
LOCALBIN=$(LOCALBIN) KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" $(GINKGO) -v -r integration_tests


##@ Build

.PHONY: build
Expand Down Expand Up @@ -195,6 +201,12 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/default | kubectl apply -f -

.PHONY: deployment-manifest
deployment-manifest: manifests kustomize ## Generate manifest to deploy operator.
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/default > rhdh-operator-${VERSION}.yaml
@echo "Generated operator script rhdh-operator-${VERSION}.yaml"

.PHONY: undeploy
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
Expand Down Expand Up @@ -402,9 +414,4 @@ show-img:
show-container-engine:
@echo -n $(CONTAINER_ENGINE)

.PHONY: deployment-manifest
deployment-manifest: manifests kustomize ## Generate manifest to deploy operator.
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/default > rhdh-operator-${VERSION}.yaml
@echo "Generated operator script rhdh-operator-${VERSION}.yaml"

2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -62,7 +62,7 @@ Output:

## License

Copyright 2023 Red Hat Inc..
Copyright 2023 Red Hat Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
58 changes: 41 additions & 17 deletions api/v1alpha1/backstage_types.go
Expand Up @@ -16,27 +16,38 @@ package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
)

// Constants for status conditions
type BackstageConditionReason string

type BackstageConditionType string

const (
// TODO: RuntimeConditionRunning string = "RuntimeRunning"
ConditionDeployed string = "Deployed"
DeployOK string = "DeployOK"
DeployFailed string = "DeployFailed"
DeployInProgress string = "DeployInProgress"
BackstageConditionTypeDeployed BackstageConditionType = "Deployed"

BackstageConditionReasonDeployed BackstageConditionReason = "Deployed"
BackstageConditionReasonFailed BackstageConditionReason = "DeployFailed"
BackstageConditionReasonInProgress BackstageConditionReason = "DeployInProgress"
)

// BackstageSpec defines the desired state of Backstage
type BackstageSpec struct {
// Configuration for Backstage. Optional.
Application *Application `json:"application,omitempty"`

// Raw Runtime Objects configuration. For Advanced scenarios.
RawRuntimeConfig RuntimeConfig `json:"rawRuntimeConfig,omitempty"`
// Raw Runtime RuntimeObjects configuration. For Advanced scenarios.
RawRuntimeConfig *RuntimeConfig `json:"rawRuntimeConfig,omitempty"`

// Configuration for database access. Optional.
Database Database `json:"database,omitempty"`
Database *Database `json:"database,omitempty"`
}

type RuntimeConfig struct {
// Name of ConfigMap containing Backstage runtime objects configuration
BackstageConfigName string `json:"backstageConfig,omitempty"`
// Name of ConfigMap containing LocalDb (PostgreSQL) runtime objects configuration
LocalDbConfigName string `json:"localDbConfig,omitempty"`
}

type Database struct {
Expand Down Expand Up @@ -98,7 +109,7 @@ type Application struct {

// Image Pull Secrets to use in all containers (including Init Containers)
// +optional
ImagePullSecrets *[]string `json:"imagePullSecrets,omitempty"`
ImagePullSecrets []string `json:"imagePullSecrets,omitempty"`
Copy link
Member

@rm3l rm3l Mar 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be a potential breaking change. How would we distinguish between "this field is set to an empty list in the CR" vs "this field is not set in the CR"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ImagePullSecrets []string is not defined it contains nil pointer
If ImagePullSecrets []string is initialized with empty array it contains pointer to empty slice with len:0 and cap:0

So, yes we can distinguish just checking ImagePullSecrets == nil
Is it what you're asking about?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ImagePullSecrets []string is not defined it contains nil pointer If ImagePullSecrets []string is initialized with empty array it contains pointer to empty slice with len:0 and cap:0

So, yes we can distinguish just checking ImagePullSecrets == nil Is it what you're asking about?

It is just that, as it is, the way it is iterated upon in this PR (https://github.com/gazarenkov/janus-idp-operator/blob/e6c56cecebf4f76748e8c80903059593e7fd78a8/pkg/model/deployment.go#L188-L191) will never allow CR users to explicitly set this list to an empty list.

This used to work previously (see

if backstage.Spec.Application.ImagePullSecrets != nil { // use image pull secrets from the CR spec
deployment.Spec.Template.Spec.ImagePullSecrets = nil
if len(*backstage.Spec.Application.ImagePullSecrets) > 0 {
for _, imagePullSecret := range *backstage.Spec.Application.ImagePullSecrets {
deployment.Spec.Template.Spec.ImagePullSecrets = append(deployment.Spec.Template.Spec.ImagePullSecrets, v1.LocalObjectReference{
Name: imagePullSecret,
), i.e., if I explicitly set imagePullSecrets: [] in my CR, the resulting Deployment won't have any pull secrets defined, and if I don't set imagePullSecrets in the CR, it will inherit those coming from the operator/raw config.

But this can be tackled in a separate issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, got it, indeed, if imagePullSecrets: [] it is logically to clean defaults, should not be difficult will make an issue for it.


// Route configuration. Used for OpenShift only.
Route *Route `json:"route,omitempty"`
Expand Down Expand Up @@ -177,13 +188,6 @@ type Env struct {
Value string `json:"value"`
}

type RuntimeConfig struct {
// Name of ConfigMap containing Backstage runtime objects configuration
BackstageConfigName string `json:"backstageConfig,omitempty"`
// Name of ConfigMap containing LocalDb (PostgreSQL) runtime objects configuration
LocalDbConfigName string `json:"localDbConfig,omitempty"`
}

// BackstageStatus defines the observed state of Backstage
type BackstageStatus struct {
// Conditions is the list of conditions describing the state of the runtime
Expand Down Expand Up @@ -268,3 +272,23 @@ type TLS struct {
func init() {
SchemeBuilder.Register(&Backstage{}, &BackstageList{})
}

// IsLocalDbEnabled returns true if Local database is configured and enabled
func (s *BackstageSpec) IsLocalDbEnabled() bool {
if s.Database == nil {
return true
}
return ptr.Deref(s.Database.EnableLocalDb, true)
}

// IsRouteEnabled returns value of Application.Route.Enabled if defined or true by default
func (s *BackstageSpec) IsRouteEnabled() bool {
if s.Application != nil && s.Application.Route != nil {
return ptr.Deref(s.Application.Route.Enabled, true)
}
return true
}

func (s *BackstageSpec) IsAuthSecretSpecified() bool {
return s.Database != nil && s.Database.AuthSecretName != ""
}
20 changes: 12 additions & 8 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

95 changes: 60 additions & 35 deletions bundle/manifests/backstage-default-config_v1_configmap.yaml
@@ -1,28 +1,33 @@
apiVersion: v1
data:
backend-auth-configmap.yaml: |
app-config.yaml: |-
apiVersion: v1
kind: ConfigMap
metadata:
name: # placeholder for '<cr-name>-backend-auth'
name: my-backstage-config-cm1 # placeholder for <bs>-default-appconfig
data:
"app-config.backend-auth.default.yaml": |
default.app-config.yaml: |
backend:
database:
connection:
password: ${POSTGRES_PASSWORD}
user: ${POSTGRES_USER}
auth:
keys:
# This is a default value, which you should change by providing your own app-config
- secret: "pl4s3Ch4ng3M3"
db-secret.yaml: |
db-secret.yaml: |-
apiVersion: v1
kind: Secret
metadata:
name: # placeholder for 'backstage-psql-secret-<cr-name>'
stringData:
"POSTGRES_PASSWORD": "rl4s3Fh4ng3M4" # default value, change to your own value
"POSTGRES_PORT": "5432"
"POSTGRES_USER": "postgres"
"POSTGRESQL_ADMIN_PASSWORD": "rl4s3Fh4ng3M4" # default value, change to your own value
"POSTGRES_HOST": "" # set to your Postgres DB host. If the local DB is deployed, set to 'backstage-psql-<cr-name>'
name: postgres-secrets # will be replaced
type: Opaque
#stringData:
# POSTGRES_PASSWORD:
# POSTGRES_PORT: "5432"
# POSTGRES_USER: postgres
# POSTGRESQL_ADMIN_PASSWORD: admin123
# POSTGRES_HOST: bs1-db-service #placeholder <crname>-db-service
db-service-hl.yaml: |
apiVersion: v1
kind: Service
Expand All @@ -44,7 +49,7 @@ data:
rhdh.redhat.com/app: backstage-psql-cr1 # placeholder for 'backstage-psql-<cr-name>'
ports:
- port: 5432
db-statefulset.yaml: |
db-statefulset.yaml: |-
apiVersion: apps/v1
kind: StatefulSet
metadata:
Expand All @@ -62,6 +67,10 @@ data:
rhdh.redhat.com/app: backstage-psql-cr1 # placeholder for 'backstage-psql-<cr-name>'
name: backstage-db-cr1 # placeholder for 'backstage-psql-<cr-name>'
spec:
# fsGroup does not work for Openshift
# AKS/EKS does not work w/o it
#securityContext:
# fsGroup: 26
automountServiceAccountToken: false
## https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/
## The optional .spec.persistentVolumeClaimRetentionPolicy field controls if and how PVCs are deleted during the lifecycle of a StatefulSet.
Expand All @@ -77,13 +86,12 @@ data:
value: /var/lib/pgsql/data
- name: PGDATA
value: /var/lib/pgsql/data/userdata
envFrom:
- secretRef:
name: <POSTGRESQL_SECRET> # will be replaced with 'backstage-psql-secrets-<cr-name>'
# image will be replaced by the value of the `RELATED_IMAGE_postgresql` env var, if set
image: quay.io/fedora/postgresql-15:latest
image: quay.io/fedora/postgresql-15:latest # will be replaced with the actual image
imagePullPolicy: IfNotPresent
securityContext:
# runAsUser:26 does not work for Openshift but looks work for AKS/EKS
# runAsUser: 26
runAsGroup: 0
runAsNonRoot: true
allowPrivilegeEscalation: false
seccompProfile:
Expand Down Expand Up @@ -134,8 +142,6 @@ data:
- mountPath: /var/lib/pgsql/data
name: data
restartPolicy: Always
securityContext: {}
serviceAccount: default
serviceAccountName: default
volumes:
- emptyDir:
Expand All @@ -160,7 +166,7 @@ data:
apiVersion: apps/v1
kind: Deployment
metadata:
name: # placeholder for 'backstage-<cr-name>'
name: backstage # placeholder for 'backstage-<cr-name>'
spec:
replicas: 1
selector:
Expand All @@ -172,6 +178,11 @@ data:
rhdh.redhat.com/app: # placeholder for 'backstage-<cr-name>'
spec:
automountServiceAccountToken: false
# if securityContext not present in AKS/EKS, the error is like this:
#Error: EACCES: permission denied, open '/dynamic-plugins-root/backstage-plugin-scaffolder-backend-module-github-dynamic-0.2.2.tgz'
# fsGroup doesn not work for Openshift
#securityContext:
# fsGroup: 1001
volumes:
- ephemeral:
volumeClaimTemplate:
Expand All @@ -187,18 +198,19 @@ data:
defaultMode: 420
optional: true
secretName: dynamic-plugins-npmrc

initContainers:
- command:
- name: install-dynamic-plugins
command:
- ./install-dynamic-plugins.sh
- /dynamic-plugins-root
image: quay.io/janus-idp/backstage-showcase:latest # will be replaced with the actual image quay.io/janus-idp/backstage-showcase:next
imagePullPolicy: IfNotPresent
securityContext:
runAsNonRoot: true
allowPrivilegeEscalation: false
env:
- name: NPM_CONFIG_USERCONFIG
value: /opt/app-root/src/.npmrc.dynamic-plugins
# image will be replaced by the value of the `RELATED_IMAGE_backstage` env var, if set
image: quay.io/janus-idp/backstage-showcase:latest
imagePullPolicy: IfNotPresent
name: install-dynamic-plugins
volumeMounts:
- mountPath: /dynamic-plugins-root
name: dynamic-plugins-root
Expand All @@ -208,6 +220,9 @@ data:
subPath: .npmrc
workingDir: /opt/app-root/src
resources:
requests:
cpu: 250m
memory: 256Mi
limits:
cpu: 1000m
memory: 2.5Gi
Expand All @@ -220,6 +235,9 @@ data:
args:
- "--config"
- "dynamic-plugins-root/app-config.dynamic-plugins.yaml"
securityContext:
runAsNonRoot: true
allowPrivilegeEscalation: false
readinessProbe:
failureThreshold: 3
httpGet:
Expand All @@ -246,24 +264,22 @@ data:
env:
- name: APP_CONFIG_backend_listen_port
value: "7007"
envFrom:
- secretRef:
name: <POSTGRESQL_SECRET> # will be replaced with 'backstage-psql-secrets-<cr-name>'
# - secretRef:
# name: backstage-secrets
volumeMounts:
- mountPath: /opt/app-root/src/dynamic-plugins-root
name: dynamic-plugins-root
resources:
requests:
cpu: 250m
memory: 256Mi
limits:
cpu: 1000m
memory: 2.5Gi
ephemeral-storage: 5Gi
dynamic-plugins-configmap.yaml: |-
dynamic-plugins.yaml: |-
apiVersion: v1
kind: ConfigMap
metadata:
name: # placeholder for '<cr-name>-dynamic-plugins'
name: default-dynamic-plugins # must be the same as (deployment.yaml).spec.template.spec.volumes.name.dynamic-plugins-conf.configMap.name
data:
"dynamic-plugins.yaml": |
includes:
Expand All @@ -273,7 +289,7 @@ data:
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: # placeholder for 'backstage-<cr-name>'
name: route # placeholder for 'backstage-<cr-name>'
spec:
port:
targetPort: http-backend
Expand All @@ -284,11 +300,20 @@ data:
to:
kind: Service
name: # placeholder for 'backstage-<cr-name>'
secret-envs.yaml: |
apiVersion: v1
kind: Secret
metadata:
name: backend-auth-secret
stringData:
# generated with the command below (from https://janus-idp.io/docs/auth/service-to-service-auth/#setup):
# node -p 'require("crypto").randomBytes(24).toString("base64")'
BACKEND_SECRET: "R2FxRVNrcmwzYzhhN3l0V1VRcnQ3L1pLT09WaVhDNUEK" # notsecret
service.yaml: |-
apiVersion: v1
kind: Service
metadata:
name: # placeholder for 'backstage-<cr-name>'
name: backstage # placeholder for 'backstage-<cr-name>'
spec:
type: ClusterIP
selector:
Expand Down