Skip to content
This repository has been archived by the owner on Aug 19, 2024. It is now read-only.

Update CRD with meaningful set of parameters #56

Merged
merged 31 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9a77e34
Add tests highlighting the expectations
rm3l Dec 4, 2023
7e25267
Update CRD with the structure discussed in [1]
rm3l Dec 4, 2023
a6a79b6
Handle Number of Replicas, Image and Image Pull Secret fields
rm3l Dec 4, 2023
7a7d527
Handle Env and EnvFrom fields to set environment variables
rm3l Dec 4, 2023
6a6959f
Handle Volumes and Volume Mounts for app-configs, dynamic plugins con…
rm3l Dec 4, 2023
b7947b7
Fix Backend Auth Secret handling
rm3l Dec 4, 2023
d07e568
handle PostgreSQL field
rm3l Dec 4, 2023
1cfa417
Update sample YAML manifest
rm3l Dec 4, 2023
f1b4304
Simplify types to make them more legible
rm3l Dec 5, 2023
97d7234
Inject Env and EnvFrom into the main Deployment containers, not init …
rm3l Dec 5, 2023
524712a
Fix JSON tag of `postgresql.enabled field
rm3l Dec 5, 2023
df83d84
Rename Ref struct into ObjectRef
rm3l Dec 5, 2023
32fdcc6
Use simple boolean over struct for controlling the creation of the lo…
rm3l Dec 6, 2023
175a001
Allow only ConfigMaps for app-configs
rm3l Dec 6, 2023
5c51402
Similar to app-configs, allow only a ConfigMap for dynamic plugins co…
rm3l Dec 6, 2023
2508e37
Rename ConfigMapNames into ConfigMapRefs
rm3l Dec 6, 2023
edaedb8
Rename backendAuthSecretRef into backendAuthSecretKeyRef
rm3l Dec 6, 2023
d7f0986
Use standard Kubernetes types for Env and EnvFrom
rm3l Dec 6, 2023
3289792
fixup! Allow only ConfigMaps for app-configs
rm3l Dec 6, 2023
ef2082a
Update CRD based on our latest discussions in [1]
rm3l Dec 8, 2023
2555452
Update test cases
rm3l Dec 8, 2023
5251892
Update bundle manifests
rm3l Dec 8, 2023
faf4333
Remove the need for the backendAuthSecret CRD field
rm3l Dec 10, 2023
7d63241
Drop backendAuthSecret field in CRD
rm3l Dec 11, 2023
6e879a4
Update example CR with app-configs
rm3l Dec 11, 2023
b76cee1
Update bundle manifests
rm3l Dec 11, 2023
2de7367
Add example using RHDH image
rm3l Dec 11, 2023
8d90c3d
Do not use pointer for SkipLocalDb field
rm3l Dec 11, 2023
4091c05
Simplify example for RHDH as much as possible
rm3l Dec 11, 2023
ff0060f
Rename `SkipLocalDb` into `EnableLocalDb`
rm3l Dec 11, 2023
2b18848
Update bundle manifests
rm3l Dec 11, 2023
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
160 changes: 116 additions & 44 deletions api/v1alpha1/backstage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,67 +25,139 @@ const (

// BackstageSpec defines the desired state of Backstage
type BackstageSpec struct {
// References to existing app-configs Config objects.
// Configuration for Backstage. Optional.
Application *Application `json:"application,omitempty"`

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

// Control the creation of a local PostgreSQL DB. Set to false if using for example an external Database for Backstage.
// To use an external Database, you can provide your own app-config file (see the AppConfig field in the Application structure)
// containing references to the Database connection information,
// which might be supplied as environment variables (see the ExtraEnvs field) or extra-configuration files
// (see the ExtraFiles field in the Application structure).
// +optional
//+kubebuilder:default=true
EnableLocalDb *bool `json:"enableLocalDb,omitempty"`
}

type Application struct {
// References to existing app-configs ConfigMap objects, that will be mounted as files in the specified mount path.
// Each element can be a reference to any ConfigMap or Secret,
// and will be mounted inside the main application container under a dedicated directory containing the ConfigMap
// or Secret name. Additionally, each file will be passed as a `--config /path/to/secret_or_configmap/key` to the
// and will be mounted inside the main application container under a specified mount directory.
// Additionally, each file will be passed as a `--config /mount/path/to/configmap/key` to the
// main container args in the order of the entries defined in the AppConfigs list.
// But bear in mind that for a single AppConfig element containing several files,
// the order in which those files will be appended to the container args, the main container args cannot be guaranteed.
// So if you want to pass multiple app-config files, it is recommended to pass one ConfigMap/Secret per app-config file.
AppConfigs []AppConfigRef `json:"appConfigs,omitempty"`

// Optional Backend Auth Secret Name. A new one will be generated if not set.
// This Secret is used to set an environment variable named 'APP_CONFIG_backend_auth_keys' in the
// main container, which takes precedence over any 'backend.auth.keys' field defined
// in default or custom application configuration files.
// This is required for service-to-service auth and is shared by all backend plugins.
BackendAuthSecretRef *BackendAuthSecretRef `json:"backendAuthSecretRef,omitempty"`

// Reference to an existing configuration object for Dynamic Plugins.
// This can be a reference to any ConfigMap or Secret,
// but the object must have an existing key named: 'dynamic-plugins.yaml'
DynamicPluginsConfig *DynamicPluginsConfigRef `json:"dynamicPluginsConfig,omitempty"`

// Raw Runtime Objects configuration
RawRuntimeConfig RuntimeConfig `json:"rawRuntimeConfig,omitempty"`
// But bear in mind that for a single ConfigMap element containing several filenames,
// the order in which those files will be appended to the main container args cannot be guaranteed.
// So if you want to pass multiple app-config files, it is recommended to pass one ConfigMap per app-config file.
// +optional
AppConfig *AppConfig `json:"appConfig,omitempty"`

// Reference to an existing ConfigMap for Dynamic Plugins.
// A new one will be generated with the default config if not set.
// The ConfigMap object must have an existing key named: 'dynamic-plugins.yaml'.
// +optional
DynamicPluginsConfigMapName string `json:"dynamicPluginsConfigMapName,omitempty"`

// References to existing Config objects to use as extra config files.
// They will be mounted as files in the specified mount path.
// Each element can be a reference to any ConfigMap or Secret.
// +optional
ExtraFiles *ExtraFiles `json:"extraFiles,omitempty"`

// Extra environment variables
// +optional
ExtraEnvs *ExtraEnvs `json:"extraEnvs,omitempty"`

//+kubebuilder:default=false
SkipLocalDb bool `json:"skipLocalDb,omitempty"`
// Number of desired replicas to set in the Backstage Deployment.
// Defaults to 1.
// +optional
//+kubebuilder:default=1
Replicas *int32 `json:"replicas,omitempty"`

// Image to use in all containers (including Init Containers)
// +optional
Image *string `json:"image,omitempty"`

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

type AppConfigRef struct {
// Name of an existing App Config object
//+kubebuilder:validation:Required
Name string `json:"name"`
type AppConfig struct {
// Mount path for all app-config files listed in the ConfigMapRefs field
// +optional
// +kubebuilder:default=/opt/app-root/src
MountPath string `json:"mountPath,omitempty"`

// List of ConfigMaps storing the app-config files. Will be mounted as files under the MountPath specified.
// For each item in this array, if a key is not specified, it means that all keys in the ConfigMap will be mounted as files.
// Otherwise, only the specified key will be mounted as a file.
// Bear in mind not to put sensitive data in those ConfigMaps. Instead, your app-config content can reference
// environment variables (which you can set with the ExtraEnvs field) and/or include extra files (see the ExtraFiles field).
// More details on https://backstage.io/docs/conf/writing/.
// +optional
ConfigMaps []ObjectKeyRef `json:"configMaps,omitempty"`
}

// Type of the existing App Config object, either ConfigMap or Secret
//+kubebuilder:validation:Required
//+kubebuilder:validation:Enum=ConfigMap;Secret
Kind string `json:"kind"`
type ExtraFiles struct {
// Mount path for all extra configuration files listed in the Items field
// +optional
// +kubebuilder:default=/opt/app-root/src
MountPath string `json:"mountPath,omitempty"`

// List of references to ConfigMaps objects mounted as extra files under the MountPath specified.
// For each item in this array, if a key is not specified, it means that all keys in the ConfigMap will be mounted as files.
// Otherwise, only the specified key will be mounted as a file.
// +optional
ConfigMaps []ObjectKeyRef `json:"configMaps,omitempty"`

// List of references to Secrets objects mounted as extra files under the MountPath specified.
// For each item in this array, if a key is not specified, it means that all keys in the Secret will be mounted as files.
// Otherwise, only the specified key will be mounted as a file.
// +optional
Secrets []ObjectKeyRef `json:"secrets,omitempty"`
}

type DynamicPluginsConfigRef struct {
// Name of the Dynamic Plugins config object
// +kubebuilder:validation:Required
Name string `json:"name"`
type ExtraEnvs struct {
// List of references to ConfigMaps objects to inject as additional environment variables.
// For each item in this array, if a key is not specified, it means that all keys in the ConfigMap will be injected as additional environment variables.
// Otherwise, only the specified key will be injected as an additional environment variable.
// +optional
ConfigMaps []ObjectKeyRef `json:"configMaps,omitempty"`

// Type of the Dynamic Plugins config object, either ConfigMap or Secret
//+kubebuilder:validation:Required
//+kubebuilder:validation:Enum=ConfigMap;Secret
Kind string `json:"kind"`
// List of references to Secrets objects to inject as additional environment variables.
// For each item in this array, if a key is not specified, it means that all keys in the Secret will be injected as additional environment variables.
// Otherwise, only the specified key will be injected as environment variable.
// +optional
Secrets []ObjectKeyRef `json:"secrets,omitempty"`

// List of name and value pairs to add as environment variables.
// +optional
Envs []Env `json:"envs,omitempty"`
}

type BackendAuthSecretRef struct {
// Name of the secret to use for the backend auth
type ObjectKeyRef struct {
// Name of the object
// We support only ConfigMaps and Secrets.
//+kubebuilder:validation:Required
Name string `json:"name"`

// Key in the secret to use for the backend auth. Default value is: backend-secret
//+kubebuilder:default=backend-secret
// Key in the object
// +optional
Key string `json:"key,omitempty"`
}

type Env struct {
// Name of the environment variable
//+kubebuilder:validation:Required
Name string `json:"name"`

// Value of the environment variable
//+kubebuilder:validation:Required
Value string `json:"value"`
}

type RuntimeConfig struct {
// Name of ConfigMap containing Backstage runtime objects configuration
BackstageConfigName string `json:"backstageConfig,omitempty"`
Expand Down
150 changes: 125 additions & 25 deletions api/v1alpha1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=backstage-operator
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.25.0
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.32.0
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3

Expand Down
Loading