|
| 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 | +} |
0 commit comments