2.2. Automated Operator features
You can use the Operator to automate several key processes to effectively configure your Backstage application.
2.2.1. Metadata generation 复制链接链接已复制到粘贴板!
The Operator automatically generates specific metadata values for all default resources at runtime to ensure your Backstage application functions properly.
For all the default resources, metadata.name is generated according to the rules defined in the Default Configuration files, particularly the Resource name column. For example, Backstage Custom Resource (CR) named mybackstage creates Kubernetes Deployment resource called backstage-mybackstage.
The following metadata is generated for each resource:
deployment.yaml-
spec.selector.matchLabels[rhdh.redhat.com/app] = backstage-{cr-name} -
spec.template.metadata.labels[rhdh.redhat.com/app] = backstage-{cr-name}
-
service.yaml-
spec.selector[rhdh.redhat.com/app] = backstage-{cr-name}
-
db-statefulset.yaml-
spec.selector.matchLabels[rhdh.redhat.com/app] = backstage-psql-{cr-name} -
spec.template.metadata.labels[rhdh.redhat.com/app] = backstage-psql-{cr-name}
-
db-service.yaml-
spec.selector[rhdh.redhat.com/app] = backstage-psql-{cr-name}
-
2.2.2. Multiple resources 复制链接链接已复制到粘贴板!
You can define and create multiple resources of the same type in a single YAML file. This is applicable to any resource type that is a list in the resource table. To define multiple resources, use the --- delimiter to separate each resource definition.
For example, adding the following code snip to pvcs.yaml creates two PersistentVolumeClaims (PVCs) called backstage-{cr-name}-myclaim1 and backstage-{cr-name}-myclaim2 and mounts them to the Backstage container accordingly.
Example creating multiple PVCs
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: myclaim1
...
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: myclaim2
...
2.2.3. Default base URLs 复制链接链接已复制到粘贴板!
The Operator automatically sets the base URLs for your Backstage application in the default app-config ConfigMap known as backstage-appconfig-{CR_name}. The Operator does so based on your Route parameters and the OpenShift cluster ingress domain.
The Operator follows these rules to set the base URLs for your application:
- If the cluster is not OpenShift, the Operator makes no changes.
-
If you explicitly set the
spec.application.route.enabledfield in your Custom Resource (CR) tofalse, no changes are made. -
If you define
spec.application.route.hostin the Backstage CR, the base URLs are set tohttps://<spec.application.route.host>. -
If you specify the
spec.application.route.subdomainin the Backstage CR, the base URLs are set tohttps://<spec.application.route.subdomain>.<cluster_ingress_domain>. -
If no custom host or subdomain is provided, the Operator sets the base URLs to
https://backstage-{cr_name}-<namespace>.<cluster_ingress_domain>, which is the default domain for the created Route resource.
The Operator updates the following base URLs in the default app-config ConfigMap:
-
app.baseUrl -
backend.baseUrl -
backend.cors.origin
You can perform these actions on a best-effort basis and only on OpenShift. During an error or on non-OpenShift clusters, you can still override these defaults by providing a custom app-config ConfigMap.