-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gabriel Saratura
committed
Jun 20, 2024
1 parent
f8fc834
commit 6253e25
Showing
26 changed files
with
1,412 additions
and
33 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
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,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 | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,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"` | ||
} |
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 |
---|---|---|
|
@@ -28,5 +28,7 @@ func init() { | |
&XVSHNPostgreSQLList{}, | ||
&VSHNRedis{}, | ||
&VSHNRedisList{}, | ||
&VSHNMariaDB{}, | ||
&VSHNMariaDBList{}, | ||
) | ||
} |
Oops, something went wrong.