-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add backup retention and geo redundant backup configurability (#1051)
add backup retention and georedundancy for psql and mysql
- Loading branch information
Showing
32 changed files
with
400 additions
and
813 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
"github.com/Azure/azure-service-operator/api/v1alpha2" | ||
"sigs.k8s.io/controller-runtime/pkg/conversion" | ||
) | ||
|
||
func (src *PostgreSQLServer) ConvertTo(dstRaw conversion.Hub) error { | ||
dst := dstRaw.(*v1alpha2.PostgreSQLServer) | ||
|
||
// ObjectMeta | ||
dst.ObjectMeta = src.ObjectMeta | ||
|
||
// Spec | ||
dst.Spec.ResourceGroup = src.Spec.ResourceGroup | ||
dst.Spec.Location = src.Spec.Location | ||
dst.Spec.Sku = v1alpha2.AzureDBsSQLSku{ | ||
Name: src.Spec.Sku.Name, | ||
Tier: v1alpha2.SkuTier(src.Spec.Sku.Tier), | ||
Capacity: src.Spec.Sku.Capacity, | ||
Size: src.Spec.Sku.Size, | ||
Family: src.Spec.Sku.Family, | ||
} | ||
|
||
dst.Spec.ServerVersion = v1alpha2.ServerVersion(src.Spec.ServerVersion) | ||
dst.Spec.SSLEnforcement = v1alpha2.SslEnforcementEnum(src.Spec.SSLEnforcement) | ||
dst.Spec.CreateMode = src.Spec.CreateMode | ||
dst.Spec.ReplicaProperties = v1alpha2.ReplicaProperties(src.Spec.ReplicaProperties) | ||
dst.Spec.KeyVaultToStoreSecrets = src.Spec.KeyVaultToStoreSecrets | ||
|
||
// New Spec | ||
dst.Spec.StorageProfile = nil | ||
|
||
// Status | ||
dst.Status = v1alpha2.ASOStatus(src.Status) | ||
|
||
return nil | ||
} | ||
|
||
func (dst *PostgreSQLServer) ConvertFrom(srcRaw conversion.Hub) error { | ||
src := srcRaw.(*v1alpha2.PostgreSQLServer) | ||
|
||
// ObjectMeta | ||
dst.ObjectMeta = src.ObjectMeta | ||
|
||
// Spec | ||
dst.Spec.ResourceGroup = src.Spec.ResourceGroup | ||
dst.Spec.Location = src.Spec.Location | ||
dst.Spec.Sku = AzureDBsSQLSku{ | ||
Name: src.Spec.Sku.Name, | ||
Tier: SkuTier(src.Spec.Sku.Tier), | ||
Capacity: src.Spec.Sku.Capacity, | ||
Size: src.Spec.Sku.Size, | ||
Family: src.Spec.Sku.Family, | ||
} | ||
dst.Spec.ServerVersion = ServerVersion(src.Spec.ServerVersion) | ||
dst.Spec.SSLEnforcement = SslEnforcementEnum(src.Spec.SSLEnforcement) | ||
dst.Spec.CreateMode = src.Spec.CreateMode | ||
dst.Spec.ReplicaProperties = ReplicaProperties(src.Spec.ReplicaProperties) | ||
dst.Spec.KeyVaultToStoreSecrets = src.Spec.KeyVaultToStoreSecrets | ||
|
||
// Status | ||
dst.Status = ASOStatus(src.Status) | ||
|
||
return nil | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
logf "sigs.k8s.io/controller-runtime/pkg/log" | ||
) | ||
|
||
// log is for logging in this package. | ||
var postgresqlserverlog = logf.Log.WithName("postgresqlserver-resource") | ||
|
||
func (r *PostgreSQLServer) SetupWebhookWithManager(mgr ctrl.Manager) error { | ||
return ctrl.NewWebhookManagedBy(mgr). | ||
For(r). | ||
Complete() | ||
} | ||
|
||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
package v1alpha2 | ||
|
||
func (*PostgreSQLServer) Hub() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
package v1alpha2 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! | ||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. | ||
|
||
// PostgreSQLServerSpec defines the desired state of PostgreSQLServer | ||
type PostgreSQLServerSpec struct { | ||
Location string `json:"location"` | ||
ResourceGroup string `json:"resourceGroup,omitempty"` | ||
Sku AzureDBsSQLSku `json:"sku,omitempty"` | ||
ServerVersion ServerVersion `json:"serverVersion,omitempty"` | ||
SSLEnforcement SslEnforcementEnum `json:"sslEnforcement,omitempty"` | ||
KeyVaultToStoreSecrets string `json:"keyVaultToStoreSecrets,omitempty"` | ||
CreateMode string `json:"createMode,omitempty"` | ||
StorageProfile *PSQLStorageProfile `json:"storageProfile,omitempty"` | ||
ReplicaProperties ReplicaProperties `json:"replicaProperties,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:storageversion | ||
|
||
// PostgreSQLServer is the Schema for the postgresqlservers API | ||
// +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=".status.provisioned" | ||
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.message" | ||
type PostgreSQLServer struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec PostgreSQLServerSpec `json:"spec,omitempty"` | ||
Status ASOStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// PostgreSQLServerList contains a list of PostgreSQLServer | ||
type PostgreSQLServerList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []PostgreSQLServer `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&PostgreSQLServer{}, &PostgreSQLServerList{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
package v1alpha2 | ||
|
||
import ( | ||
"github.com/Azure/azure-sdk-for-go/services/mysql/mgmt/2017-12-01/mysql" | ||
psql "github.com/Azure/azure-sdk-for-go/services/postgresql/mgmt/2017-12-01/postgresql" | ||
) | ||
|
||
type AzureDBsSQLSku struct { | ||
// Name - The name of the sku, typically, tier + family + cores, e.g. B_Gen4_1, GP_Gen5_8. | ||
Name string `json:"name,omitempty"` | ||
// Tier - The tier of the particular SKU, e.g. Basic. Possible values include: 'Basic', 'GeneralPurpose', 'MemoryOptimized' | ||
Tier SkuTier `json:"tier,omitempty"` | ||
// Capacity - The scale up/out capacity, representing server's compute units. | ||
Capacity int32 `json:"capacity,omitempty"` | ||
// Size - The size code, to be interpreted by resource as appropriate. | ||
Size string `json:"size,omitempty"` | ||
// Family - The family of hardware. | ||
Family string `json:"family,omitempty"` | ||
} | ||
|
||
// ServerVersion enumerates the values for server version. | ||
type ServerVersion string | ||
|
||
const ( | ||
// NineFullStopFive ... | ||
NineFullStopFive ServerVersion = "9.5" | ||
// NineFullStopSix ... | ||
NineFullStopSix ServerVersion = "9.6" | ||
// OneOne ... | ||
OneOne ServerVersion = "11" | ||
// OneZero ... | ||
OneZero ServerVersion = "10" | ||
// OneZeroFullStopTwo ... | ||
OneZeroFullStopTwo ServerVersion = "10.2" | ||
// OneZeroFullStopZero ... | ||
OneZeroFullStopZero ServerVersion = "10.0" | ||
) | ||
|
||
type SkuTier string | ||
|
||
const ( | ||
// Basic ... | ||
PSQLBasic SkuTier = "Basic" | ||
// GeneralPurpose ... | ||
PSQLGeneralPurpose SkuTier = "GeneralPurpose" | ||
// MemoryOptimized ... | ||
PSQLMemoryOptimized SkuTier = "MemoryOptimized" | ||
) | ||
|
||
type SslEnforcementEnum string | ||
|
||
const ( | ||
// SslEnforcementEnumDisabled ... | ||
SslEnforcementEnumDisabled SslEnforcementEnum = "Disabled" | ||
// SslEnforcementEnumEnabled ... | ||
SslEnforcementEnumEnabled SslEnforcementEnum = "Enabled" | ||
) | ||
|
||
type MySQLStorageProfile struct { | ||
// BackupRetentionDays - Backup retention days for the server. | ||
BackupRetentionDays *int32 `json:"backupRetentionDays,omitempty"` | ||
// GeoRedundantBackup - Enable Geo-redundant or not for server backup. Possible values include: 'Enabled', 'Disabled' | ||
GeoRedundantBackup mysql.GeoRedundantBackup `json:"geoRedundantBackup,omitempty"` | ||
// StorageMB - Max storage allowed for a server. | ||
StorageMB *int32 `json:"storageMB,omitempty"` | ||
// StorageAutogrow - Enable Storage Auto Grow. Possible values include: 'StorageAutogrowEnabled', 'StorageAutogrowDisabled' | ||
StorageAutogrow mysql.StorageAutogrow `json:"storageAutogrow,omitempty"` | ||
} | ||
|
||
type PSQLStorageProfile struct { | ||
// BackupRetentionDays - Backup retention days for the server. | ||
BackupRetentionDays *int32 `json:"backupRetentionDays,omitempty"` | ||
// GeoRedundantBackup - Enable Geo-redundant or not for server backup. Possible values include: 'Enabled', 'Disabled' | ||
GeoRedundantBackup psql.GeoRedundantBackup `json:"geoRedundantBackup,omitempty"` | ||
// StorageMB - Max storage allowed for a server. | ||
StorageMB *int32 `json:"storageMB,omitempty"` | ||
// StorageAutogrow - Enable Storage Auto Grow. Possible values include: 'StorageAutogrowEnabled', 'StorageAutogrowDisabled' | ||
StorageAutogrow psql.StorageAutogrow `json:"storageAutogrow,omitempty"` | ||
} | ||
|
||
type ReplicaProperties struct { | ||
SourceServerId string `json:"sourceServerId,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.