Skip to content

Commit a609317

Browse files
authored
Merge pull request #11 from vshn/mariadb-backup
Add vshn mariadb backups
2 parents f8fc834 + 6253e25 commit a609317

26 files changed

+1412
-33
lines changed

apis/appcat/v1/appcat_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
// +kubebuilder:rbac:groups="apiextensions.crossplane.io",resources=compositions,verbs=get;list;watch
1919
// +kubebuilder:rbac:groups="stackgres.io",resources=sgbackups,verbs=get;list;watch
2020
// +kubebuilder:rbac:groups="k8up.io",resources=snapshots,verbs=get;list;watch
21-
// +kubebuilder:rbac:groups="vshn.appcat.vshn.io",resources=vshnredis;xvshnpostgresqls,verbs=get;list;watch
21+
// +kubebuilder:rbac:groups="vshn.appcat.vshn.io",resources=vshnredis;xvshnpostgresqls;vshnmariadbs;,verbs=get;list;watch
2222

2323
var (
2424
// OfferedValue is the label value to identify AppCat services

apis/appcat/v1/register.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
3131
&VSHNPostgresBackupList{},
3232
&VSHNRedisBackup{},
3333
&VSHNRedisBackupList{},
34+
&VSHNMariaDBBackup{},
35+
&VSHNMariaDBBackupList{},
3436
)
3537
metav1.AddToGroupVersion(scheme, GroupVersion)
3638
return nil
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package v1
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
"k8s.io/apimachinery/pkg/runtime"
6+
"k8s.io/apimachinery/pkg/runtime/schema"
7+
"sigs.k8s.io/apiserver-runtime/pkg/builder/resource"
8+
)
9+
10+
// VSHNMariaDBBackup needs to implement the builder resource interface
11+
var _ resource.Object = &VSHNMariaDBBackup{}
12+
var _ resource.ObjectList = &VSHNMariaDBBackupList{}
13+
14+
// +kubebuilder:object:root=true
15+
16+
type VSHNMariaDBBackup struct {
17+
metav1.TypeMeta `json:",inline"`
18+
metav1.ObjectMeta `json:"metadata,omitempty"`
19+
20+
Status VSHNMariaDBBackupStatus `json:"status,omitempty"`
21+
}
22+
23+
type VSHNMariaDBBackupStatus struct {
24+
ID string `json:"id,omitempty"`
25+
Date metav1.Time `json:"date,omitempty"`
26+
Instance string `json:"instance,omitempty"`
27+
}
28+
29+
// +kubebuilder:object:root=true
30+
31+
type VSHNMariaDBBackupList struct {
32+
metav1.TypeMeta `json:",inline"`
33+
metav1.ListMeta `json:"metadata,omitempty"`
34+
35+
Items []VSHNMariaDBBackup `json:"items,omitempty"`
36+
}
37+
38+
// GetGroupVersionResource returns the GroupVersionResource for this resource.
39+
// The resource should be the all lowercase and pluralized kind
40+
func (in *VSHNMariaDBBackup) GetGroupVersionResource() schema.GroupVersionResource {
41+
return schema.GroupVersionResource{
42+
Group: GroupVersion.Group,
43+
Version: GroupVersion.Version,
44+
Resource: "vshnmariadbbackups",
45+
}
46+
}
47+
48+
func (in *VSHNMariaDBBackup) GetObjectMeta() *metav1.ObjectMeta {
49+
return &in.ObjectMeta
50+
}
51+
52+
// 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.
53+
// If false, the resource is expected to implement MultiVersionObject interface.
54+
func (in *VSHNMariaDBBackup) IsStorageVersion() bool {
55+
return true
56+
}
57+
58+
func (in *VSHNMariaDBBackup) NamespaceScoped() bool {
59+
return true
60+
}
61+
62+
func (in *VSHNMariaDBBackup) New() runtime.Object {
63+
return &VSHNMariaDBBackup{}
64+
}
65+
66+
func (in *VSHNMariaDBBackup) NewList() runtime.Object {
67+
return &VSHNMariaDBBackupList{}
68+
}
69+
70+
func (in *VSHNMariaDBBackupList) GetListMeta() *metav1.ListMeta {
71+
return &in.ListMeta
72+
}

apis/appcat/v1/vshn_postgres_backup_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ var (
2323
Timing = "timing"
2424
// End holds field path name end
2525
End = "end"
26+
// Start holds field path name start
27+
Start = "start"
2628
)
2729

2830
// VSHNPostgreSQLName represents the name of a VSHNPostgreSQL

apis/appcat/v1/zz_generated.deepcopy.go

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/vshn/v1/dbaas_vshn_mariadb.go

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
package v1
2+
3+
import (
4+
v1 "github.com/vshn/appcat-apiserver/apis/v1"
5+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
6+
)
7+
8+
// Workaround to make nested defaulting work.
9+
// kubebuilder is unable to set a {} default
10+
//go:generate yq -i e ../../generated/vshn.appcat.vshn.io_vshnmariadbs.yaml --expression "with(.spec.versions[]; .schema.openAPIV3Schema.properties.spec.properties.parameters.default={})"
11+
//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={})"
12+
//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={})"
13+
//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={})"
14+
//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={})"
15+
16+
// +kubebuilder:object:root=true
17+
18+
// VSHNMariaDB is the API for creating MariaDB clusters.
19+
type VSHNMariaDB struct {
20+
metav1.TypeMeta `json:",inline"`
21+
metav1.ObjectMeta `json:"metadata,omitempty"`
22+
23+
// Spec defines the desired state of a VSHNMariaDB.
24+
Spec VSHNMariaDBSpec `json:"spec"`
25+
26+
// Status reflects the observed state of a VSHNMariaDB.
27+
Status VSHNMariaDBStatus `json:"status,omitempty"`
28+
}
29+
30+
// +kubebuilder:object:generate=true
31+
// +kubebuilder:object:root=true
32+
type VSHNMariaDBList struct {
33+
metav1.TypeMeta `json:",inline"`
34+
metav1.ListMeta `json:"metadata,omitempty"`
35+
36+
Items []VSHNMariaDB `json:"items,omitempty"`
37+
}
38+
39+
// VSHNMariaDBSpec defines the desired state of a VSHNMariaDB.
40+
type VSHNMariaDBSpec struct {
41+
// Parameters are the configurable fields of a VSHNMariaDB.
42+
Parameters VSHNMariaDBParameters `json:"parameters,omitempty"`
43+
44+
// WriteConnectionSecretToRef references a secret to which the connection details will be written.
45+
WriteConnectionSecretToRef v1.LocalObjectReference `json:"writeConnectionSecretToRef,omitempty"`
46+
}
47+
48+
// VSHNMariaDBParameters are the configurable fields of a VSHNMariaDB.
49+
type VSHNMariaDBParameters struct {
50+
// Service contains MariaDB DBaaS specific properties
51+
Service VSHNMariaDBServiceSpec `json:"service,omitempty"`
52+
53+
// Size contains settings to control the sizing of a service.
54+
Size VSHNMariaDBSizeSpec `json:"size,omitempty"`
55+
56+
// Scheduling contains settings to control the scheduling of an instance.
57+
Scheduling VSHNDBaaSSchedulingSpec `json:"scheduling,omitempty"`
58+
59+
// TLS contains settings to control tls traffic of a service.
60+
TLS VSHNMariaDBTLSSpec `json:"tls,omitempty"`
61+
62+
// Backup contains settings to control how the instance should get backed up.
63+
Backup K8upBackupSpec `json:"backup,omitempty"`
64+
65+
// Restore contains settings to control the restore of an instance.
66+
Restore K8upRestoreSpec `json:"restore,omitempty"`
67+
68+
// Maintenance contains settings to control the maintenance of an instance.
69+
Maintenance VSHNDBaaSMaintenanceScheduleSpec `json:"maintenance,omitempty"`
70+
}
71+
72+
// VSHNMariaDBServiceSpec contains MariaDB DBaaS specific properties
73+
type VSHNMariaDBServiceSpec struct {
74+
// +kubebuilder:validation:Enum="6.2";"7.0"
75+
// +kubebuilder:default="7.0"
76+
77+
// Version contains supported version of MariaDB.
78+
// Multiple versions are supported. The latest version "7.0" is the default version.
79+
Version string `json:"version,omitempty"`
80+
81+
// MariaDBSettings contains additional MariaDB settings.
82+
MariaDBSettings string `json:"MariaDBSettings,omitempty"`
83+
}
84+
85+
// VSHNMariaDBSizeSpec contains settings to control the sizing of a service.
86+
type VSHNMariaDBSizeSpec struct {
87+
88+
// CPURequests defines the requests amount of Kubernetes CPUs for an instance.
89+
CPURequests string `json:"cpuRequests,omitempty"`
90+
91+
// CPULimits defines the limits amount of Kubernetes CPUs for an instance.
92+
CPULimits string `json:"cpuLimits,omitempty"`
93+
94+
// MemoryRequests defines the requests amount of memory in units of bytes for an instance.
95+
MemoryRequests string `json:"memoryRequests,omitempty"`
96+
97+
// MemoryLimits defines the limits amount of memory in units of bytes for an instance.
98+
MemoryLimits string `json:"memoryLimits,omitempty"`
99+
100+
// Disk defines the amount of disk space for an instance.
101+
Disk string `json:"disk,omitempty"`
102+
103+
// Plan is the name of the resource plan that defines the compute resources.
104+
Plan string `json:"plan,omitempty"`
105+
}
106+
107+
// VSHNMariaDBTLSSpec contains settings to control tls traffic of a service.
108+
type VSHNMariaDBTLSSpec struct {
109+
// +kubebuilder:default=true
110+
111+
// TLSEnabled enables TLS traffic for the service
112+
TLSEnabled bool `json:"enabled,omitempty"`
113+
114+
// +kubebuilder:default=true
115+
// TLSAuthClients enables client authentication requirement
116+
TLSAuthClients bool `json:"authClients,omitempty"`
117+
}
118+
119+
// VSHNMariaDBStatus reflects the observed state of a VSHNMariaDB.
120+
type VSHNMariaDBStatus struct {
121+
// MariaDBConditions contains the status conditions of the backing object.
122+
NamespaceConditions []v1.Condition `json:"namespaceConditions,omitempty"`
123+
SelfSignedIssuerConditions []v1.Condition `json:"selfSignedIssuerConditions,omitempty"`
124+
LocalCAConditions []v1.Condition `json:"localCAConditions,omitempty"`
125+
CaCertificateConditions []v1.Condition `json:"caCertificateConditions,omitempty"`
126+
ServerCertificateConditions []v1.Condition `json:"serverCertificateConditions,omitempty"`
127+
ClientCertificateConditions []v1.Condition `json:"clientCertificateConditions,omitempty"`
128+
// InstanceNamespace contains the name of the namespace where the instance resides
129+
InstanceNamespace string `json:"instanceNamespace,omitempty"`
130+
}

apis/vshn/v1/groupversion_info.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,7 @@ func init() {
2828
&XVSHNPostgreSQLList{},
2929
&VSHNRedis{},
3030
&VSHNRedisList{},
31+
&VSHNMariaDB{},
32+
&VSHNMariaDBList{},
3133
)
3234
}

0 commit comments

Comments
 (0)