Skip to content

Commit

Permalink
Merge pull request #445 from raptorsun/single-instance
Browse files Browse the repository at this point in the history
OLS-466: make console UI deployment replica configurable
  • Loading branch information
openshift-merge-bot[bot] authored Oct 9, 2024
2 parents 6131f37 + 6671964 commit f16a432
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 4 deletions.
6 changes: 6 additions & 0 deletions api/v1alpha1/olsconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ type ConsoleContainerConfig struct {
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Node Selector",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:nodeSelector"}
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
// Defines the number of desired Console pods. Default: "1"
// +kubebuilder:default=1
// +kubebuilder:validation:Minimum=0
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Number of replicas",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:podCount"}
// +optional
Replicas *int32 `json:"replicas,omitempty"`
}

// +kubebuilder:validation:Enum=redis
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.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ metadata:
]
capabilities: Basic Install
console.openshift.io/operator-monitoring-default: "true"
createdAt: "2024-08-30T09:59:16Z"
createdAt: "2024-10-03T09:25:52Z"
features.operators.openshift.io/cnf: "false"
features.operators.openshift.io/cni: "false"
features.operators.openshift.io/csi: "false"
Expand Down Expand Up @@ -165,6 +165,11 @@ spec:
path: ols.deployment.console.nodeSelector
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:nodeSelector
- description: 'Defines the number of desired Console pods. Default: "1"'
displayName: Number of replicas
path: ols.deployment.console.replicas
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:podCount
- displayName: Resource Requirements
path: ols.deployment.console.resources
x-descriptors:
Expand Down
7 changes: 7 additions & 0 deletions bundle/manifests/ols.openshift.io_olsconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,13 @@ spec:
additionalProperties:
type: string
type: object
replicas:
default: 1
description: 'Defines the number of desired Console pods.
Default: "1"'
format: int32
minimum: 0
type: integer
resources:
description: ResourceRequirements describes the compute
resource requirements.
Expand Down
7 changes: 7 additions & 0 deletions config/crd/bases/ols.openshift.io_olsconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,13 @@ spec:
additionalProperties:
type: string
type: object
replicas:
default: 1
description: 'Defines the number of desired Console pods.
Default: "1"'
format: int32
minimum: 0
type: integer
resources:
description: ResourceRequirements describes the compute
resource requirements.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ spec:
path: ols.deployment.console.nodeSelector
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:nodeSelector
- description: 'Defines the number of desired Console pods. Default: "1"'
displayName: Number of replicas
path: ols.deployment.console.replicas
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:podCount
- displayName: Resource Requirements
path: ols.deployment.console.resources
x-descriptors:
Expand Down
3 changes: 1 addition & 2 deletions internal/controller/ols_console_ui_assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ func (r *OLSConfigReconciler) generateConsoleUIService(cr *olsv1alpha1.OLSConfig
}

func (r *OLSConfigReconciler) generateConsoleUIDeployment(cr *olsv1alpha1.OLSConfig) (*appsv1.Deployment, error) {
replicas := int32(2)
val_true := true
volumeDefaultMode := int32(420)
resources := getConsoleUIResources(cr)
Expand All @@ -112,7 +111,7 @@ func (r *OLSConfigReconciler) generateConsoleUIDeployment(cr *olsv1alpha1.OLSCon
Labels: generateConsoleUILabels(),
},
Spec: appsv1.DeploymentSpec{
Replicas: &replicas,
Replicas: cr.Spec.OLSConfig.DeploymentConfig.ConsoleContainer.Replicas,
Selector: &metav1.LabelSelector{
MatchLabels: generateConsoleUILabels(),
},
Expand Down
4 changes: 3 additions & 1 deletion internal/controller/ols_console_ui_assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ var _ = Describe("Console UI assets", func() {
})

It("should generate the console UI deployment", func() {
var replicas int32 = 2
cr.Spec.OLSConfig.DeploymentConfig.ConsoleContainer.Replicas = &replicas
dep, err := r.generateConsoleUIDeployment(cr)
Expect(err).NotTo(HaveOccurred())
Expect(dep.Name).To(Equal(ConsoleUIDeploymentName))
Expand All @@ -79,7 +81,7 @@ var _ = Describe("Console UI assets", func() {
}))
Expect(dep.Spec.Template.Spec.Tolerations).To(BeNil())
Expect(dep.Spec.Template.Spec.NodeSelector).To(BeNil())

Expect(dep.Spec.Replicas).To(Equal(cr.Spec.OLSConfig.DeploymentConfig.ConsoleContainer.Replicas))
})

It("should generate the console UI plugin", func() {
Expand Down

0 comments on commit f16a432

Please sign in to comment.