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

Add support for controlling replicas for all frontends in an environment #231

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions api/v1alpha1/frontendenvironment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

3 changes: 3 additions & 0 deletions config/crd/bases/cloud.redhat.com_frontendenvironments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion controllers/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/antora/modules/ROOT/pages/api_reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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__ | | |
|===


Expand Down Expand Up @@ -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 + | |
|===


Expand Down
8 changes: 8 additions & 0 deletions tests/e2e/default-replicas/00-create-namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: test-default-replicas
spec:
finalizers:
- kubernetes
33 changes: 33 additions & 0 deletions tests/e2e/default-replicas/01-create-resources.yaml
Original file line number Diff line number Diff line change
@@ -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

37 changes: 37 additions & 0 deletions tests/e2e/default-replicas/02-assert.yaml
Original file line number Diff line number Diff line change
@@ -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
Loading