Skip to content

Commit

Permalink
Added logic for provisioning On-premises Cassandra cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
testisnullus committed Oct 4, 2023
1 parent ffc2a11 commit a2ea2a6
Show file tree
Hide file tree
Showing 176 changed files with 33,083 additions and 7,738 deletions.
5 changes: 0 additions & 5 deletions apis/clusterresources/v1beta1/postgresqluser_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ type ClusterInfo struct {
Event string `json:"event,omitempty"`
}

type NamespacedName struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

Expand Down
5 changes: 5 additions & 0 deletions apis/clusterresources/v1beta1/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@ type SecretReference struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
}

type NamespacedName struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
}
18 changes: 16 additions & 2 deletions apis/clusters/v1beta1/cassandra_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ type CassandraRestoreFrom struct {

// CassandraSpec defines the desired state of Cassandra
type CassandraSpec struct {
RestoreFrom *CassandraRestoreFrom `json:"restoreFrom,omitempty"`
OnPremisesSpec *CassandraOnPremisesSpec `json:"onPremisesSpec,omitempty"`
RestoreFrom *CassandraRestoreFrom `json:"restoreFrom,omitempty"`
Cluster `json:",inline"`
DataCentres []*CassandraDataCentre `json:"dataCentres,omitempty"`
LuceneEnabled bool `json:"luceneEnabled,omitempty"`
Expand All @@ -67,6 +68,19 @@ type CassandraSpec struct {
ResizeSettings []*ResizeSettings `json:"resizeSettings,omitempty"`
}

type CassandraOnPremisesSpec struct {
DeleteDisksWithVM bool `json:"deleteDisksWithVM,omitempty"`
StorageClassName string `json:"storageClassName"`
OSDiskSize string `json:"OSDiskSize"`
DataDiskSize string `json:"dataDiskSize"`
SSHGatewayCPU int64 `json:"sshGatewayCPU"`
SSHGatewayMemory string `json:"sshGatewayMemory"`
NodeCPU int64 `json:"nodeCPU"`
NodeMemory string `json:"nodeMemory"`
OSImageURL string `json:"osImageURL"`
CloudInitScriptNamespacedName *NamespacedName `json:"cloudInitScriptNamespacedName"`
}

// CassandraStatus defines the observed state of Cassandra
type CassandraStatus struct {
ClusterStatus `json:",inline"`
Expand Down Expand Up @@ -141,7 +155,7 @@ func (c *Cassandra) NewBackupSpec(startTimestamp int) *clusterresourcesv1beta1.C
return &clusterresourcesv1beta1.ClusterBackup{
TypeMeta: ctrl.TypeMeta{
Kind: models.ClusterBackupKind,
APIVersion: models.ClusterresourcesV1beta1APIVersion,
APIVersion: models.ClusterResourcesV1beta1APIVersion,
},
ObjectMeta: ctrl.ObjectMeta{
Name: models.SnapshotUploadPrefix + c.Status.ID + "-" + strconv.Itoa(startTimestamp),
Expand Down
2 changes: 1 addition & 1 deletion apis/clusters/v1beta1/opensearch_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ func (os *OpenSearch) NewBackupSpec(startTimestamp int) *clusterresourcesv1beta1
return &clusterresourcesv1beta1.ClusterBackup{
TypeMeta: ctrl.TypeMeta{
Kind: models.ClusterBackupKind,
APIVersion: models.ClusterresourcesV1beta1APIVersion,
APIVersion: models.ClusterResourcesV1beta1APIVersion,
},
ObjectMeta: ctrl.ObjectMeta{
Name: models.SnapshotUploadPrefix + os.Status.ID + "-" + strconv.Itoa(startTimestamp),
Expand Down
2 changes: 1 addition & 1 deletion apis/clusters/v1beta1/postgresql_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (pg *PostgreSQL) NewBackupSpec(startTimestamp int) *clusterresourcesv1beta1
return &clusterresourcesv1beta1.ClusterBackup{
TypeMeta: ctrl.TypeMeta{
Kind: models.ClusterBackupKind,
APIVersion: models.ClusterresourcesV1beta1APIVersion,
APIVersion: models.ClusterResourcesV1beta1APIVersion,
},
ObjectMeta: ctrl.ObjectMeta{
Name: models.PgBackupPrefix + pg.Status.ID + "-" + strconv.Itoa(startTimestamp),
Expand Down
2 changes: 1 addition & 1 deletion apis/clusters/v1beta1/redis_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (r *Redis) NewBackupSpec(startTimestamp int) *clusterresourcesv1beta1.Clust
return &clusterresourcesv1beta1.ClusterBackup{
TypeMeta: ctrl.TypeMeta{
Kind: models.ClusterBackupKind,
APIVersion: models.ClusterresourcesV1beta1APIVersion,
APIVersion: models.ClusterResourcesV1beta1APIVersion,
},
ObjectMeta: ctrl.ObjectMeta{
Name: models.SnapshotUploadPrefix + r.Status.ID + "-" + strconv.Itoa(startTimestamp),
Expand Down
55 changes: 55 additions & 0 deletions apis/clusters/v1beta1/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,61 @@ type privateLinkStatus struct {
EndPointServiceName string `json:"endPointServiceName,omitempty"`
}

type NamespacedName struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
}

type Gateway struct {
ID string `json:"id,omitempty"`
ClusterDataCentre string `json:"clusterDataCentre,omitempty"`
ClusterID string `json:"clusterId,omitempty"`
PublicAddress string `json:"publicAddress,omitempty"`
PrivateAddress string `json:"privateAddress,omitempty"`
NatID string `json:"natId,omitempty"`
NatPublicAddress string `json:"natPublicAddress,omitempty"`
NatPrivateAddress string `json:"natPrivateAddress,omitempty"`
NodeAgentVersion string `json:"nodeAgentVersion,omitempty"`
SSHMarkedForDeletion string `json:"sshMarkedForDeletion,omitempty"`
SSHReplaces string `json:"sshReplaces,omitempty"`
NatMarkedForDeletion string `json:"natMarkedForDeletion,omitempty"`
Rack string `json:"rack,omitempty"`
RackID string `json:"rackId,omitempty"`
SSHAWSID string `json:"sshAWSId,omitempty"`
}

type OnPremiseNode struct {
ID string `json:"id,omitempty"`
ClusterDataCentre string `json:"clusterDataCentre,omitempty"`
AccountID string `json:"accountId,omitempty"`
Status string `json:"status,omitempty"`
PublicAddress string `json:"publicAddress,omitempty"`
PrivateAddress string `json:"privateAddress,omitempty"`
Provider string `json:"provider,omitempty"`
Size string `json:"size,omitempty"`
DeferredReason string `json:"deferredReason,omitempty"`
MarkedForDeletion string `json:"markedForDeletion,omitempty"`
NodeAgentStartDate string `json:"nodeAgentStartDate,omitempty"`
ChargifyDateLastBilled string `json:"chargifyDateLastBilled,omitempty"`
LastOSUpdate string `json:"lastOSUpdate,omitempty"`
Replaces string `json:"replaces,omitempty"`
Rack string `json:"rack,omitempty"`
RackID string `json:"rackId,omitempty"`
DataCentre string `json:"dataCentre,omitempty"`
ForceStart bool `json:"forceStart,omitempty"`
BundleStartEnabled bool `json:"bundleStartEnabled,omitempty"`
ClusterID string `json:"clusterId,omitempty"`
EphemeralStorageDiskCount int `json:"ephemeralStorageDiskCount,omitempty"`
PersistentStorageDiskCount int `json:"persistentStorageDiskCount,omitempty"`
CacheDiskQuota int `json:"cacheDiskQuota,omitempty"`
FailureReason string `json:"failureReason,omitempty"`
NodeAgentVersion string `json:"nodeAgentVersion,omitempty"`
OSVersionID string `json:"osVersionId,omitempty"`
OSBuildID string `json:"osBuildId,omitempty"`
DiskQuota int `json:"diskQuota,omitempty"`
InstanceStore bool `json:"instanceStore,omitempty"`
}

type PrivateLinkStatuses []*privateLinkStatus

func (p1 PrivateLinkStatuses) Equal(p2 PrivateLinkStatuses) bool {
Expand Down
70 changes: 70 additions & 0 deletions apis/clusters/v1beta1/zz_generated.deepcopy.go

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

43 changes: 43 additions & 0 deletions config/crd/bases/clusters.instaclustr.com_cassandras.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,49 @@ spec:
name:
description: Name [ 3 .. 32 ] characters.
type: string
onPremisesSpec:
properties:
OSDiskSize:
type: string
cloudInitScriptNamespacedName:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
dataDiskSize:
type: string
deleteDisksWithVM:
type: boolean
nodeCPU:
format: int64
type: integer
nodeMemory:
type: string
osImageURL:
type: string
sshGatewayCPU:
format: int64
type: integer
sshGatewayMemory:
type: string
storageClassName:
type: string
required:
- OSDiskSize
- cloudInitScriptNamespacedName
- dataDiskSize
- nodeCPU
- nodeMemory
- osImageURL
- sshGatewayCPU
- sshGatewayMemory
- storageClassName
type: object
passwordAndUserAuth:
type: boolean
pciCompliance:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (r *AWSEndpointServicePrincipalReconciler) handleCreate(ctx context.Context
err = json.Unmarshal(b, &principal.Status)
if err != nil {
l.Error(err, "failed to parse an AWS endpoint service principal resource response from Instaclustr")
r.EventRecorder.Eventf(principal, models.Warning, models.ConvertionFailed,
r.EventRecorder.Eventf(principal, models.Warning, models.ConversionFailed,
"Failed to parse an AWS endpoint service principal resource response from Instaclustr. Reason: %v", err,
)

Expand Down
2 changes: 1 addition & 1 deletion controllers/clusterresources/clusterbackup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func (r *ClusterBackupReconciler) Reconcile(ctx context.Context, req ctrl.Reques
)

r.EventRecorder.Eventf(
backup, models.Warning, models.ConvertionFailed,
backup, models.Warning, models.ConversionFailed,
"Start timestamp annotation convertion to int is failed. Reason: %v",
err,
)
Expand Down
2 changes: 1 addition & 1 deletion controllers/clusterresources/postgresqluser_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ func (r *PostgreSQLUserReconciler) createPostgreSQLFirewallRule(
firewallRule := &clusterresourcesv1beta1.ClusterNetworkFirewallRule{
TypeMeta: ctrl.TypeMeta{
Kind: models.ClusterNetworkFirewallRuleKind,
APIVersion: models.ClusterresourcesV1beta1APIVersion,
APIVersion: models.ClusterResourcesV1beta1APIVersion,
},
ObjectMeta: ctrl.ObjectMeta{
Name: firewallRuleName,
Expand Down
4 changes: 2 additions & 2 deletions controllers/clusters/cadence_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (r *CadenceReconciler) HandleCreateCluster(
logger.Error(err, "Cannot convert Cadence cluster manifest to API spec",
"cluster manifest", cadence.Spec)

r.EventRecorder.Eventf(cadence, models.Warning, models.ConvertionFailed,
r.EventRecorder.Eventf(cadence, models.Warning, models.ConversionFailed,
"Cluster convertion from the Instaclustr API to k8s resource is failed. Reason: %v", err)

return models.ReconcileRequeue
Expand Down Expand Up @@ -267,7 +267,7 @@ func (r *CadenceReconciler) HandleUpdateCluster(
"cluster ID", cadence.Status.ID,
)

r.EventRecorder.Eventf(cadence, models.Warning, models.ConvertionFailed,
r.EventRecorder.Eventf(cadence, models.Warning, models.ConversionFailed,
"Cluster convertion from the Instaclustr API to k8s resource is failed. Reason: %v", err)

return models.ReconcileRequeue
Expand Down
Loading

0 comments on commit a2ea2a6

Please sign in to comment.