Skip to content

Commit

Permalink
Adding support for HPA
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmayja committed Aug 6, 2024
1 parent 03662f3 commit ea60954
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion api/v1/aerospikecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,8 @@ type AerospikeClusterStatus struct { //nolint:govet // for readability
Pods map[string]AerospikePodStatus `json:"pods" patchStrategy:"strategic"`

// Phase denotes the current phase of Aerospike cluster operation.
Phase AerospikeClusterPhase `json:"phase,omitempty"`
Phase AerospikeClusterPhase `json:"phase,omitempty"`
Selector string `json:"selector"`
}

// AerospikeNetworkType specifies the type of network address to use.
Expand Down Expand Up @@ -921,6 +922,7 @@ type AerospikePodStatus struct { //nolint:govet // for readability
// +kubebuilder:printcolumn:name="HostNetwork",type=boolean,JSONPath=`.spec.podSpec.hostNetwork`
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase"
//+kubebuilder:subresource:scale:specpath=.spec.size,statuspath=.status.size,selectorpath=.status.selector

// AerospikeCluster is the schema for the AerospikeCluster API
// +operator-sdk:csv:customresourcedefinitions:displayName="Aerospike Cluster",resources={{Service, v1},{Pod,v1},{StatefulSet,v1}}
Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/asdb.aerospike.com_aerospikeclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18282,6 +18282,8 @@ spec:
type: integer
type: object
type: object
selector:
type: string
size:
description: Aerospike cluster size
format: int32
Expand Down Expand Up @@ -18893,11 +18895,17 @@ spec:
- skipWorkDirValidate
- skipXdrDlogFileValidate
type: object
required:
- selector
type: object
type: object
served: true
storage: true
subresources:
scale:
labelSelectorPath: .status.selector
specReplicasPath: .spec.size
statusReplicasPath: .status.size
status: {}
- additionalPrinterColumns:
- jsonPath: .spec.size
Expand Down
4 changes: 4 additions & 0 deletions controllers/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
k8sRuntime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
Expand Down Expand Up @@ -428,6 +429,9 @@ func (r *SingleClusterReconciler) updateStatus() error {
newAeroCluster.Status.IsReadinessProbeEnabled = clusterReadinessEnable
}

selector := labels.SelectorFromSet(utils.LabelsForAerospikeCluster(newAeroCluster.Name))
newAeroCluster.Status.Selector = selector.String()

err = r.patchStatus(newAeroCluster)
if err != nil {
return fmt.Errorf("error updating status: %w", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18282,6 +18282,8 @@ spec:
type: integer
type: object
type: object
selector:
type: string
size:
description: Aerospike cluster size
format: int32
Expand Down Expand Up @@ -18893,11 +18895,17 @@ spec:
- skipWorkDirValidate
- skipXdrDlogFileValidate
type: object
required:
- selector
type: object
type: object
served: true
storage: true
subresources:
scale:
labelSelectorPath: .status.selector
specReplicasPath: .spec.size
statusReplicasPath: .status.size
status: {}
- additionalPrinterColumns:
- jsonPath: .spec.size
Expand Down

0 comments on commit ea60954

Please sign in to comment.