Skip to content

Commit

Permalink
Merge pull request #199 from RedHatInsights/add-replica-control
Browse files Browse the repository at this point in the history
[RHCLOUD-35554] - Add replica control on deployments
  • Loading branch information
adamrdrew authored Oct 17, 2024
2 parents eb8a6b1 + f1d2dcd commit 43500a0
Show file tree
Hide file tree
Showing 12 changed files with 773 additions and 177 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM registry.access.redhat.com/ubi8/go-toolset:1.21 as base
FROM registry.access.redhat.com/ubi8/go-toolset:1.21.13 as base

WORKDIR /workspace

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ build-template: manifests kustomize controller-gen
$(KUSTOMIZE) build config/deployment-template | ./manifest2template.py > deploy.yml

manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./api/..." output:crd:artifacts:config=config/crd/bases

generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/frontend_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ type FrontendSpec struct {
ServiceTiles []*ServiceTile `json:"serviceTiles,omitempty" yaml:"serviceTiles,omitempty"`
// Data for the available widgets for the resource
WidgetRegistry []*WidgetEntry `json:"widgetRegistry,omitempty" yaml:"widgetRegistry,omitempty"`
Replicas *int32 `json:"replicas,omitempty" yaml:"replicas,omitempty"`
}

var ReconciliationSuccessful = "ReconciliationSuccessful"
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.

2 changes: 1 addition & 1 deletion build/Dockerfile.pr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.access.redhat.com/ubi8/go-toolset:1.21
FROM registry.access.redhat.com/ubi8/go-toolset:1.21.13
USER 0
RUN dnf install -y openssh-clients git podman make which go jq python3
RUN mkdir /root/go -p
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/cloud.redhat.com_frontends.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ spec:
- title
type: object
type: array
replicas:
format: int32
type: integer
searchEntries:
description: The search index partials for the resource
items:
Expand Down
7 changes: 7 additions & 0 deletions controllers/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,13 @@ func (r *FrontendReconciliation) createFrontendDeployment(annotationHashes []map
labeler := utils.GetCustomLabeler(labels, nn, r.Frontend)
labeler(d)

// Set the replicas if specified, otherwise default to 1
if r.Frontend.Spec.Replicas != nil {
d.Spec.Replicas = r.Frontend.Spec.Replicas
} else {
d.Spec.Replicas = utils.Int32Ptr(1)
}

populateVolumes(d, r.Frontend, r.FrontendEnvironment)
populateContainer(d, r.Frontend, r.FrontendEnvironment)
r.populateEnvVars(d, r.FrontendEnvironment)
Expand Down
3 changes: 3 additions & 0 deletions deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,9 @@ objects:
- title
type: object
type: array
replicas:
format: int32
type: integer
searchEntries:
description: The search index partials for the resource
items:
Expand Down
Loading

0 comments on commit 43500a0

Please sign in to comment.