Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vshn mariadb backups #11

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apis/appcat/v1/appcat_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
// +kubebuilder:rbac:groups="apiextensions.crossplane.io",resources=compositions,verbs=get;list;watch
// +kubebuilder:rbac:groups="stackgres.io",resources=sgbackups,verbs=get;list;watch
// +kubebuilder:rbac:groups="k8up.io",resources=snapshots,verbs=get;list;watch
// +kubebuilder:rbac:groups="vshn.appcat.vshn.io",resources=vshnredis;xvshnpostgresqls,verbs=get;list;watch
// +kubebuilder:rbac:groups="vshn.appcat.vshn.io",resources=vshnredis;xvshnpostgresqls;vshnmariadbs;,verbs=get;list;watch

var (
// OfferedValue is the label value to identify AppCat services
Expand Down
2 changes: 2 additions & 0 deletions apis/appcat/v1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&VSHNPostgresBackupList{},
&VSHNRedisBackup{},
&VSHNRedisBackupList{},
&VSHNMariaDBBackup{},
&VSHNMariaDBBackupList{},
)
metav1.AddToGroupVersion(scheme, GroupVersion)
return nil
Expand Down
72 changes: 72 additions & 0 deletions apis/appcat/v1/vshn_mariadb_backup_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package v1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/apiserver-runtime/pkg/builder/resource"
)

// VSHNMariaDBBackup needs to implement the builder resource interface
var _ resource.Object = &VSHNMariaDBBackup{}
var _ resource.ObjectList = &VSHNMariaDBBackupList{}

// +kubebuilder:object:root=true

type VSHNMariaDBBackup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Status VSHNMariaDBBackupStatus `json:"status,omitempty"`
}

type VSHNMariaDBBackupStatus struct {
ID string `json:"id,omitempty"`
Date metav1.Time `json:"date,omitempty"`
Instance string `json:"instance,omitempty"`
}

// +kubebuilder:object:root=true

type VSHNMariaDBBackupList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`

Items []VSHNMariaDBBackup `json:"items,omitempty"`
}

// GetGroupVersionResource returns the GroupVersionResource for this resource.
// The resource should be the all lowercase and pluralized kind
func (in *VSHNMariaDBBackup) GetGroupVersionResource() schema.GroupVersionResource {
return schema.GroupVersionResource{
Group: GroupVersion.Group,
Version: GroupVersion.Version,
Resource: "vshnmariadbbackups",
}
}

func (in *VSHNMariaDBBackup) GetObjectMeta() *metav1.ObjectMeta {
return &in.ObjectMeta
}

// IsStorageVersion returns true if the object is also the internal version -- i.e. is the type defined for the API group or an alias to this object.
// If false, the resource is expected to implement MultiVersionObject interface.
func (in *VSHNMariaDBBackup) IsStorageVersion() bool {
return true
}

func (in *VSHNMariaDBBackup) NamespaceScoped() bool {
return true
}

func (in *VSHNMariaDBBackup) New() runtime.Object {
return &VSHNMariaDBBackup{}
}

func (in *VSHNMariaDBBackup) NewList() runtime.Object {
return &VSHNMariaDBBackupList{}
}

func (in *VSHNMariaDBBackupList) GetListMeta() *metav1.ListMeta {
return &in.ListMeta
}
2 changes: 2 additions & 0 deletions apis/appcat/v1/vshn_postgres_backup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ var (
Timing = "timing"
// End holds field path name end
End = "end"
// Start holds field path name start
Start = "start"
)

// VSHNPostgreSQLName represents the name of a VSHNPostgreSQL
Expand Down
74 changes: 74 additions & 0 deletions apis/appcat/v1/zz_generated.deepcopy.go

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

130 changes: 130 additions & 0 deletions apis/vshn/v1/dbaas_vshn_mariadb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package v1

import (
v1 "github.com/vshn/appcat-apiserver/apis/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// Workaround to make nested defaulting work.
// kubebuilder is unable to set a {} default
//go:generate yq -i e ../../generated/vshn.appcat.vshn.io_vshnmariadbs.yaml --expression "with(.spec.versions[]; .schema.openAPIV3Schema.properties.spec.properties.parameters.default={})"
//go:generate yq -i e ../../generated/vshn.appcat.vshn.io_vshnmariadbs.yaml --expression "with(.spec.versions[]; .schema.openAPIV3Schema.properties.spec.properties.parameters.properties.size.default={})"
//go:generate yq -i e ../../generated/vshn.appcat.vshn.io_vshnmariadbs.yaml --expression "with(.spec.versions[]; .schema.openAPIV3Schema.properties.spec.properties.parameters.properties.service.default={})"
//go:generate yq -i e ../../generated/vshn.appcat.vshn.io_vshnmariadbs.yaml --expression "with(.spec.versions[]; .schema.openAPIV3Schema.properties.spec.properties.parameters.properties.tls.default={})"
//go:generate yq -i e ../../generated/vshn.appcat.vshn.io_vshnmariadbs.yaml --expression "with(.spec.versions[]; .schema.openAPIV3Schema.properties.spec.properties.parameters.properties.backup.default={})"

// +kubebuilder:object:root=true

// VSHNMariaDB is the API for creating MariaDB clusters.
type VSHNMariaDB struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// Spec defines the desired state of a VSHNMariaDB.
Spec VSHNMariaDBSpec `json:"spec"`

// Status reflects the observed state of a VSHNMariaDB.
Status VSHNMariaDBStatus `json:"status,omitempty"`
}

// +kubebuilder:object:generate=true
// +kubebuilder:object:root=true
type VSHNMariaDBList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`

Items []VSHNMariaDB `json:"items,omitempty"`
}

// VSHNMariaDBSpec defines the desired state of a VSHNMariaDB.
type VSHNMariaDBSpec struct {
// Parameters are the configurable fields of a VSHNMariaDB.
Parameters VSHNMariaDBParameters `json:"parameters,omitempty"`

// WriteConnectionSecretToRef references a secret to which the connection details will be written.
WriteConnectionSecretToRef v1.LocalObjectReference `json:"writeConnectionSecretToRef,omitempty"`
}

// VSHNMariaDBParameters are the configurable fields of a VSHNMariaDB.
type VSHNMariaDBParameters struct {
// Service contains MariaDB DBaaS specific properties
Service VSHNMariaDBServiceSpec `json:"service,omitempty"`

// Size contains settings to control the sizing of a service.
Size VSHNMariaDBSizeSpec `json:"size,omitempty"`

// Scheduling contains settings to control the scheduling of an instance.
Scheduling VSHNDBaaSSchedulingSpec `json:"scheduling,omitempty"`

// TLS contains settings to control tls traffic of a service.
TLS VSHNMariaDBTLSSpec `json:"tls,omitempty"`

// Backup contains settings to control how the instance should get backed up.
Backup K8upBackupSpec `json:"backup,omitempty"`

// Restore contains settings to control the restore of an instance.
Restore K8upRestoreSpec `json:"restore,omitempty"`

// Maintenance contains settings to control the maintenance of an instance.
Maintenance VSHNDBaaSMaintenanceScheduleSpec `json:"maintenance,omitempty"`
}

// VSHNMariaDBServiceSpec contains MariaDB DBaaS specific properties
type VSHNMariaDBServiceSpec struct {
// +kubebuilder:validation:Enum="6.2";"7.0"
// +kubebuilder:default="7.0"

// Version contains supported version of MariaDB.
// Multiple versions are supported. The latest version "7.0" is the default version.
Version string `json:"version,omitempty"`

// MariaDBSettings contains additional MariaDB settings.
MariaDBSettings string `json:"MariaDBSettings,omitempty"`
}

// VSHNMariaDBSizeSpec contains settings to control the sizing of a service.
type VSHNMariaDBSizeSpec struct {

// CPURequests defines the requests amount of Kubernetes CPUs for an instance.
CPURequests string `json:"cpuRequests,omitempty"`

// CPULimits defines the limits amount of Kubernetes CPUs for an instance.
CPULimits string `json:"cpuLimits,omitempty"`

// MemoryRequests defines the requests amount of memory in units of bytes for an instance.
MemoryRequests string `json:"memoryRequests,omitempty"`

// MemoryLimits defines the limits amount of memory in units of bytes for an instance.
MemoryLimits string `json:"memoryLimits,omitempty"`

// Disk defines the amount of disk space for an instance.
Disk string `json:"disk,omitempty"`

// Plan is the name of the resource plan that defines the compute resources.
Plan string `json:"plan,omitempty"`
}

// VSHNMariaDBTLSSpec contains settings to control tls traffic of a service.
type VSHNMariaDBTLSSpec struct {
// +kubebuilder:default=true

// TLSEnabled enables TLS traffic for the service
TLSEnabled bool `json:"enabled,omitempty"`

// +kubebuilder:default=true
// TLSAuthClients enables client authentication requirement
TLSAuthClients bool `json:"authClients,omitempty"`
}

// VSHNMariaDBStatus reflects the observed state of a VSHNMariaDB.
type VSHNMariaDBStatus struct {
// MariaDBConditions contains the status conditions of the backing object.
NamespaceConditions []v1.Condition `json:"namespaceConditions,omitempty"`
SelfSignedIssuerConditions []v1.Condition `json:"selfSignedIssuerConditions,omitempty"`
LocalCAConditions []v1.Condition `json:"localCAConditions,omitempty"`
CaCertificateConditions []v1.Condition `json:"caCertificateConditions,omitempty"`
ServerCertificateConditions []v1.Condition `json:"serverCertificateConditions,omitempty"`
ClientCertificateConditions []v1.Condition `json:"clientCertificateConditions,omitempty"`
// InstanceNamespace contains the name of the namespace where the instance resides
InstanceNamespace string `json:"instanceNamespace,omitempty"`
}
2 changes: 2 additions & 0 deletions apis/vshn/v1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ func init() {
&XVSHNPostgreSQLList{},
&VSHNRedis{},
&VSHNRedisList{},
&VSHNMariaDB{},
&VSHNMariaDBList{},
)
}
Loading
Loading