diff --git a/api/v1alpha1/frontendenvironment_types.go b/api/v1alpha1/frontendenvironment_types.go index c746ca0d..921d4453 100644 --- a/api/v1alpha1/frontendenvironment_types.go +++ b/api/v1alpha1/frontendenvironment_types.go @@ -97,6 +97,8 @@ type FrontendEnvironmentSpec struct { TargetNamespaces []string `json:"targetNamespaces,omitempty" yaml:"targetNamespaces,omitempty"` // For the ChromeUI to render additional global components ServiceCategories *[]FrontendServiceCategory `json:"serviceCategories,omitempty" yaml:"serviceCategories,omitempty"` + + DefaultReplicas *int32 `json:"defaultReplicas,omitempty" yaml:"defaultReplicas,omitempty"` } type MonitoringConfig struct { diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 9ff5aa8b..21d24ba1 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -496,6 +496,11 @@ func (in *FrontendEnvironmentSpec) DeepCopyInto(out *FrontendEnvironmentSpec) { } } } + if in.DefaultReplicas != nil { + in, out := &in.DefaultReplicas, &out.DefaultReplicas + *out = new(int32) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FrontendEnvironmentSpec. diff --git a/config/crd/bases/cloud.redhat.com_frontendenvironments.yaml b/config/crd/bases/cloud.redhat.com_frontendenvironments.yaml index a6a6a5ba..4afd1b9d 100644 --- a/config/crd/bases/cloud.redhat.com_frontendenvironments.yaml +++ b/config/crd/bases/cloud.redhat.com_frontendenvironments.yaml @@ -60,6 +60,9 @@ spec: description: The name of the secret we will use to get the akamai credentials type: string + defaultReplicas: + format: int32 + type: integer enableAkamaiCacheBust: description: Enable Akamai Cache Bust type: boolean diff --git a/controllers/reconcile.go b/controllers/reconcile.go index 4071ee35..c6abd143 100644 --- a/controllers/reconcile.go +++ b/controllers/reconcile.go @@ -408,7 +408,11 @@ func (r *FrontendReconciliation) createFrontendDeployment(annotationHashes []map if r.Frontend.Spec.Replicas != nil { d.Spec.Replicas = r.Frontend.Spec.Replicas } else { - d.Spec.Replicas = utils.Int32Ptr(1) + if r.FrontendEnvironment.Spec.DefaultReplicas != nil { + d.Spec.Replicas = r.FrontendEnvironment.Spec.DefaultReplicas + } else { + d.Spec.Replicas = utils.Int32Ptr(1) + } } populateVolumes(d, r.Frontend, r.FrontendEnvironment) diff --git a/deploy.yml b/deploy.yml index b4713810..f3e8287f 100644 --- a/deploy.yml +++ b/deploy.yml @@ -263,6 +263,9 @@ objects: description: The name of the secret we will use to get the akamai credentials type: string + defaultReplicas: + format: int32 + type: integer enableAkamaiCacheBust: description: Enable Akamai Cache Bust type: boolean diff --git a/docs/antora/modules/ROOT/pages/api_reference.adoc b/docs/antora/modules/ROOT/pages/api_reference.adoc index 5746dee5..e6bc36ed 100644 --- a/docs/antora/modules/ROOT/pages/api_reference.adoc +++ b/docs/antora/modules/ROOT/pages/api_reference.adoc @@ -463,6 +463,7 @@ do this in epehemeral environments but not in production + | | | *`targetNamespaces`* __string array__ | List of namespaces that should receive a copy of the frontend configuration as a config map + By configurations we mean the fed-modules.json, navigation files, etc. + | | | *`serviceCategories`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-frontendservicecategory[$$FrontendServiceCategory$$]__ | For the ChromeUI to render additional global components + | | +| *`defaultReplicas`* __integer__ | | | |=== @@ -618,6 +619,7 @@ FrontendSpec defines the desired state of Frontend | *`serviceTiles`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-servicetile[$$ServiceTile$$] array__ | Data for the all services dropdown + | | | *`widgetRegistry`* __xref:{anchor_prefix}-github-com-redhatinsights-frontend-operator-api-v1alpha1-widgetentry[$$WidgetEntry$$] array__ | Data for the available widgets for the resource + | | | *`replicas`* __integer__ | | | +| *`feoConfigEnabled`* __boolean__ | Injects configuration from application when enabled + | | |=== diff --git a/tests/e2e/default-replicas/00-create-namespace.yaml b/tests/e2e/default-replicas/00-create-namespace.yaml new file mode 100644 index 00000000..82d0f1ef --- /dev/null +++ b/tests/e2e/default-replicas/00-create-namespace.yaml @@ -0,0 +1,8 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: test-default-replicas +spec: + finalizers: + - kubernetes diff --git a/tests/e2e/default-replicas/01-create-resources.yaml b/tests/e2e/default-replicas/01-create-resources.yaml new file mode 100644 index 00000000..48db4fac --- /dev/null +++ b/tests/e2e/default-replicas/01-create-resources.yaml @@ -0,0 +1,33 @@ +--- +apiVersion: cloud.redhat.com/v1alpha1 +kind: FrontendEnvironment +metadata: + name: test-default-replicas-environment +spec: + generateNavJSON: false + ssl: false + hostname: foo.redhat.com + sso: https://sso.foo.redhat.com + defaultReplicas: 3 +--- +apiVersion: cloud.redhat.com/v1alpha1 +kind: Frontend +metadata: + name: chrome + namespace: test-default-replicas +spec: + API: + versions: + - v1 + frontend: + paths: + - / + deploymentRepo: https://github.com/RedHatInsights/insights-chrome + envName: test-default-replicas-environment + image: quay.io/cloudservices/insights-chrome-frontend:720317c + module: + config: + ssoUrl: 'https://' + manifestLocation: /apps/chrome/js/fed-mods.json + title: Chrome + diff --git a/tests/e2e/default-replicas/02-assert.yaml b/tests/e2e/default-replicas/02-assert.yaml new file mode 100644 index 00000000..59dd5e68 --- /dev/null +++ b/tests/e2e/default-replicas/02-assert.yaml @@ -0,0 +1,37 @@ +--- +kind: Deployment +apiVersion: apps/v1 +metadata: + name: chrome-frontend + namespace: test-default-replicas + labels: + frontend: chrome + ownerReferences: + - apiVersion: cloud.redhat.com/v1alpha1 + kind: Frontend + name: chrome +spec: + replicas: 3 + selector: + matchLabels: + frontend: chrome + template: + spec: + volumes: + - name: config + configMap: + name: test-default-replicas-environment + defaultMode: 420 + containers: + - name: fe-image + image: 'quay.io/cloudservices/insights-chrome-frontend:720317c' + ports: + - name: web + containerPort: 80 + protocol: TCP + - name: metrics + containerPort: 9000 + protocol: TCP + volumeMounts: + - name: config + mountPath: /opt/app-root/src/build/stable/operator-generated \ No newline at end of file