diff --git a/PROJECT b/PROJECT index af4dfb44..01749b66 100644 --- a/PROJECT +++ b/PROJECT @@ -11,19 +11,6 @@ plugins: projectName: mariadb-operator repo: github.com/openstack-k8s-operators/mariadb-operator resources: -- api: - crdVersion: v1 - namespaced: true - controller: true - domain: openstack.org - group: mariadb - kind: MariaDB - path: github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1 - version: v1beta1 - webhooks: - defaulting: true - validation: true - webhookVersion: v1 - api: crdVersion: v1 namespaced: true diff --git a/api/bases/mariadb.openstack.org_mariadbs.yaml b/api/bases/mariadb.openstack.org_mariadbs.yaml deleted file mode 100644 index 5d4b845e..00000000 --- a/api/bases/mariadb.openstack.org_mariadbs.yaml +++ /dev/null @@ -1,129 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.11.1 - creationTimestamp: null - name: mariadbs.mariadb.openstack.org -spec: - group: mariadb.openstack.org - names: - kind: MariaDB - listKind: MariaDBList - plural: mariadbs - singular: mariadb - scope: Namespaced - versions: - - additionalPrinterColumns: - - description: Status - jsonPath: .status.conditions[0].status - name: Status - type: string - - description: Message - jsonPath: .status.conditions[0].message - name: Message - type: string - name: v1beta1 - schema: - openAPIV3Schema: - description: MariaDB is the Schema for the mariadbs API - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: MariaDBSpec defines the desired state of MariaDB - properties: - adoptionRedirect: - description: Adoption configuration - properties: - host: - description: MariaDB host to redirect to (IP or name) - type: string - type: object - containerImage: - description: ContainerImage - Container Image URL (will be set to - environmental default if empty) - type: string - secret: - description: Secret containing a RootPassword - type: string - storageClass: - description: Storage class to host the mariadb databases - type: string - storageRequest: - description: Storage size allocated for the mariadb databases - type: string - required: - - containerImage - - secret - - storageClass - - storageRequest - type: object - status: - description: MariaDBStatus defines the observed state of MariaDB - properties: - conditions: - description: Conditions - items: - description: Condition defines an observation of a API resource - operational state. - properties: - lastTransitionTime: - description: Last time the condition transitioned from one status - to another. This should be when the underlying condition changed. - If that is not known, then using the time when the API field - changed is acceptable. - format: date-time - type: string - message: - description: A human readable message indicating details about - the transition. - type: string - reason: - description: The reason for the condition's last transition - in CamelCase. - type: string - severity: - description: Severity provides a classification of Reason code, - so the current situation is immediately understandable and - could act accordingly. It is meant for situations where Status=False - and it should be indicated if it is just informational, warning - (next reconciliation might fix it) or an error (e.g. DB create - issue and no actions to automatically resolve the issue can/should - be done). For conditions where Status=Unknown or Status=True - the Severity should be SeverityNone. - type: string - status: - description: Status of the condition, one of True, False, Unknown. - type: string - type: - description: Type of condition in CamelCase. - type: string - required: - - lastTransitionTime - - status - - type - type: object - type: array - dbInitHash: - description: db init completed - type: string - required: - - dbInitHash - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/api/v1beta1/galera_types.go b/api/v1beta1/galera_types.go index da3abaec..251df8b9 100644 --- a/api/v1beta1/galera_types.go +++ b/api/v1beta1/galera_types.go @@ -18,14 +18,24 @@ package v1beta1 import ( condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" + "github.com/openstack-k8s-operators/lib-common/modules/common/util" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) const ( // CustomServiceConfigFile name of the additional mariadb config file CustomServiceConfigFile = "galera_custom.cnf.in" + + // GaleraContainerImage is the fall-back container image for Galera + GaleraContainerImage = "quay.io/podified-antelope-centos9/openstack-mariadb:current-podified" ) +// AdoptionRedirectSpec defines redirection to a different DB instance during Adoption +type AdoptionRedirectSpec struct { + // MariaDB host to redirect to (IP or name) + Host string `json:"host,omitempty"` +} + // GaleraSpec defines the desired state of Galera type GaleraSpec struct { // Name of the secret to look for password keys @@ -130,3 +140,13 @@ func (instance Galera) RbacNamespace() string { func (instance Galera) RbacResourceName() string { return "galera-" + instance.Name } + +// SetupDefaults - initializes any CRD field defaults based on environment variables (the defaulting mechanism itself is implemented via webhooks) +func SetupDefaults() { + // Acquire environmental defaults and initialize Keystone defaults with them + galeraDefaults := GaleraDefaults{ + ContainerImageURL: util.GetEnvVar("RELATED_IMAGE_MARIADB_IMAGE_URL_DEFAULT", GaleraContainerImage), + } + + SetupGaleraDefaults(galeraDefaults) +} diff --git a/api/v1beta1/galera_webhook.go b/api/v1beta1/galera_webhook.go index a0b8050a..36bbdd47 100644 --- a/api/v1beta1/galera_webhook.go +++ b/api/v1beta1/galera_webhook.go @@ -26,6 +26,13 @@ import ( // log is for logging in this package. var galeralog = logf.Log.WithName("galera-resource") +// GaleraDefaults - +type GaleraDefaults struct { + ContainerImageURL string +} + +var galeraDefaults GaleraDefaults + // SetupWebhookWithManager sets up the webhook with the Manager func (r *Galera) SetupWebhookWithManager(mgr ctrl.Manager) error { return ctrl.NewWebhookManagedBy(mgr). @@ -47,7 +54,7 @@ func (r *Galera) Default() { // Default - set defaults for this MariaDB spec func (spec *GaleraSpec) Default() { if spec.ContainerImage == "" { - spec.ContainerImage = mariaDBDefaults.ContainerImageURL + spec.ContainerImage = galeraDefaults.ContainerImageURL } } @@ -79,3 +86,9 @@ func (r *Galera) ValidateDelete() error { // TODO(user): fill in your validation logic upon object deletion. return nil } + +// SetupGaleraDefaults - initialize MariaDB spec defaults for use with either internal or external webhooks +func SetupGaleraDefaults(defaults GaleraDefaults) { + galeraDefaults = defaults + galeralog.Info("Galera defaults initialized", "defaults", defaults) +} diff --git a/api/v1beta1/mariadb_types.go b/api/v1beta1/mariadb_types.go deleted file mode 100644 index 64452400..00000000 --- a/api/v1beta1/mariadb_types.go +++ /dev/null @@ -1,121 +0,0 @@ -/* -Copyright 2022. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1beta1 - -import ( - condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" - "github.com/openstack-k8s-operators/lib-common/modules/common/util" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -const ( - // Container image fall-back defaults - - // MariaDBContainerImage is the fall-back container image for MariaDB/Galera - MariaDBContainerImage = "quay.io/podified-antelope-centos9/openstack-mariadb:current-podified" -) - -// MariaDBSpec defines the desired state of MariaDB -type MariaDBSpec struct { - // Secret containing a RootPassword - // +kubebuilder:validation:Required - Secret string `json:"secret"` - // Storage class to host the mariadb databases - // +kubebuilder:validation:Required - StorageClass string `json:"storageClass"` - // Storage size allocated for the mariadb databases - // +kubebuilder:validation:Required - StorageRequest string `json:"storageRequest"` - // ContainerImage - Container Image URL (will be set to environmental default if empty) - // +kubebuilder:validation:Required - ContainerImage string `json:"containerImage"` - // Adoption configuration - // +kubebuilder:validation:Optional - AdoptionRedirect AdoptionRedirectSpec `json:"adoptionRedirect,omitempty"` -} - -// AdoptionRedirectSpec defines redirection to a different DB instance during Adoption -type AdoptionRedirectSpec struct { - // MariaDB host to redirect to (IP or name) - Host string `json:"host,omitempty"` -} - -// MariaDBStatus defines the observed state of MariaDB -type MariaDBStatus struct { - // db init completed - DbInitHash string `json:"dbInitHash"` - - // Conditions - Conditions condition.Conditions `json:"conditions,omitempty" optional:"true"` -} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status -//+kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[0].status",description="Status" -//+kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.conditions[0].message",description="Message" - -// MariaDB is the Schema for the mariadbs API -type MariaDB struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec MariaDBSpec `json:"spec,omitempty"` - Status MariaDBStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// MariaDBList contains a list of MariaDB -type MariaDBList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []MariaDB `json:"items"` -} - -func init() { - SchemeBuilder.Register(&MariaDB{}, &MariaDBList{}) -} - -// IsReady - returns true if service is ready to serve requests -func (instance MariaDB) IsReady() bool { - return instance.Status.Conditions.IsTrue(condition.DeploymentReadyCondition) -} - -// RbacConditionsSet - set the conditions for the rbac object -func (instance MariaDB) RbacConditionsSet(c *condition.Condition) { - instance.Status.Conditions.Set(c) -} - -// RbacNamespace - return the namespace -func (instance MariaDB) RbacNamespace() string { - return instance.Namespace -} - -// RbacResourceName - return the name to be used for rbac objects (serviceaccount, role, rolebinding) -func (instance MariaDB) RbacResourceName() string { - return "mariadb-" + instance.Name -} - -// SetupDefaults - initializes any CRD field defaults based on environment variables (the defaulting mechanism itself is implemented via webhooks) -func SetupDefaults() { - // Acquire environmental defaults and initialize Keystone defaults with them - mariaDBDefaults := MariaDBDefaults{ - ContainerImageURL: util.GetEnvVar("RELATED_IMAGE_MARIADB_IMAGE_URL_DEFAULT", MariaDBContainerImage), - } - - SetupMariaDBDefaults(mariaDBDefaults) -} diff --git a/api/v1beta1/mariadb_webhook.go b/api/v1beta1/mariadb_webhook.go deleted file mode 100644 index 1fad9a50..00000000 --- a/api/v1beta1/mariadb_webhook.go +++ /dev/null @@ -1,94 +0,0 @@ -/* -Copyright 2022. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1beta1 - -import ( - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/webhook" -) - -// MariaDBDefaults - -type MariaDBDefaults struct { - ContainerImageURL string -} - -var mariaDBDefaults MariaDBDefaults - -// log is for logging in this package. -var mariadblog = logf.Log.WithName("mariadb-resource") - -// SetupMariaDBDefaults - initialize MariaDB spec defaults for use with either internal or external webhooks -func SetupMariaDBDefaults(defaults MariaDBDefaults) { - mariaDBDefaults = defaults - mariadblog.Info("MariaDB defaults initialized", "defaults", defaults) -} - -// SetupWebhookWithManager sets up the webhook with the Manager -func (r *MariaDB) SetupWebhookWithManager(mgr ctrl.Manager) error { - return ctrl.NewWebhookManagedBy(mgr). - For(r). - Complete() -} - -//+kubebuilder:webhook:path=/mutate-mariadb-openstack-org-v1beta1-mariadb,mutating=true,failurePolicy=fail,sideEffects=None,groups=mariadb.openstack.org,resources=mariadbs,verbs=create;update,versions=v1beta1,name=mmariadb.kb.io,admissionReviewVersions=v1 - -var _ webhook.Defaulter = &MariaDB{} - -// Default implements webhook.Defaulter so a webhook will be registered for the type -func (r *MariaDB) Default() { - mariadblog.Info("default", "name", r.Name) - - r.Spec.Default() -} - -// Default - set defaults for this MariaDB spec -func (spec *MariaDBSpec) Default() { - if spec.ContainerImage == "" { - spec.ContainerImage = mariaDBDefaults.ContainerImageURL - } -} - -// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. -//+kubebuilder:webhook:path=/validate-mariadb-openstack-org-v1beta1-mariadb,mutating=false,failurePolicy=fail,sideEffects=None,groups=mariadb.openstack.org,resources=mariadbs,verbs=create;update,versions=v1beta1,name=vmariadb.kb.io,admissionReviewVersions=v1 - -var _ webhook.Validator = &MariaDB{} - -// ValidateCreate implements webhook.Validator so a webhook will be registered for the type -func (r *MariaDB) ValidateCreate() error { - mariadblog.Info("validate create", "name", r.Name) - - // TODO(user): fill in your validation logic upon object creation. - return nil -} - -// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type -func (r *MariaDB) ValidateUpdate(old runtime.Object) error { - mariadblog.Info("validate update", "name", r.Name) - - // TODO(user): fill in your validation logic upon object update. - return nil -} - -// ValidateDelete implements webhook.Validator so a webhook will be registered for the type -func (r *MariaDB) ValidateDelete() error { - mariadblog.Info("validate delete", "name", r.Name) - - // TODO(user): fill in your validation logic upon object deletion. - return nil -} diff --git a/api/v1beta1/webhook_suite_test.go b/api/v1beta1/webhook_suite_test.go index 711fabcf..70821d72 100644 --- a/api/v1beta1/webhook_suite_test.go +++ b/api/v1beta1/webhook_suite_test.go @@ -99,9 +99,6 @@ var _ = BeforeSuite(func() { }) Expect(err).NotTo(HaveOccurred()) - err = (&MariaDB{}).SetupWebhookWithManager(mgr) - Expect(err).NotTo(HaveOccurred()) - err = (&Galera{}).SetupWebhookWithManager(mgr) Expect(err).NotTo(HaveOccurred()) diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index eb1cd555..575c84a9 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -110,6 +110,21 @@ func (in *GaleraAttributes) DeepCopy() *GaleraAttributes { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GaleraDefaults) DeepCopyInto(out *GaleraDefaults) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GaleraDefaults. +func (in *GaleraDefaults) DeepCopy() *GaleraDefaults { + if in == nil { + return nil + } + out := new(GaleraDefaults) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GaleraList) DeepCopyInto(out *GaleraList) { *out = *in @@ -199,33 +214,6 @@ func (in *GaleraStatus) DeepCopy() *GaleraStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MariaDB) DeepCopyInto(out *MariaDB) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MariaDB. -func (in *MariaDB) DeepCopy() *MariaDB { - if in == nil { - return nil - } - out := new(MariaDB) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *MariaDB) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MariaDBAccount) DeepCopyInto(out *MariaDBAccount) { *out = *in @@ -424,88 +412,3 @@ func (in *MariaDBDatabaseStatus) DeepCopy() *MariaDBDatabaseStatus { in.DeepCopyInto(out) return out } - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MariaDBDefaults) DeepCopyInto(out *MariaDBDefaults) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MariaDBDefaults. -func (in *MariaDBDefaults) DeepCopy() *MariaDBDefaults { - if in == nil { - return nil - } - out := new(MariaDBDefaults) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MariaDBList) DeepCopyInto(out *MariaDBList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]MariaDB, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MariaDBList. -func (in *MariaDBList) DeepCopy() *MariaDBList { - if in == nil { - return nil - } - out := new(MariaDBList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *MariaDBList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MariaDBSpec) DeepCopyInto(out *MariaDBSpec) { - *out = *in - out.AdoptionRedirect = in.AdoptionRedirect -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MariaDBSpec. -func (in *MariaDBSpec) DeepCopy() *MariaDBSpec { - if in == nil { - return nil - } - out := new(MariaDBSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MariaDBStatus) DeepCopyInto(out *MariaDBStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make(condition.Conditions, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MariaDBStatus. -func (in *MariaDBStatus) DeepCopy() *MariaDBStatus { - if in == nil { - return nil - } - out := new(MariaDBStatus) - in.DeepCopyInto(out) - return out -} diff --git a/config/crd/bases/mariadb.openstack.org_mariadbs.yaml b/config/crd/bases/mariadb.openstack.org_mariadbs.yaml deleted file mode 100644 index 5d4b845e..00000000 --- a/config/crd/bases/mariadb.openstack.org_mariadbs.yaml +++ /dev/null @@ -1,129 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.11.1 - creationTimestamp: null - name: mariadbs.mariadb.openstack.org -spec: - group: mariadb.openstack.org - names: - kind: MariaDB - listKind: MariaDBList - plural: mariadbs - singular: mariadb - scope: Namespaced - versions: - - additionalPrinterColumns: - - description: Status - jsonPath: .status.conditions[0].status - name: Status - type: string - - description: Message - jsonPath: .status.conditions[0].message - name: Message - type: string - name: v1beta1 - schema: - openAPIV3Schema: - description: MariaDB is the Schema for the mariadbs API - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: MariaDBSpec defines the desired state of MariaDB - properties: - adoptionRedirect: - description: Adoption configuration - properties: - host: - description: MariaDB host to redirect to (IP or name) - type: string - type: object - containerImage: - description: ContainerImage - Container Image URL (will be set to - environmental default if empty) - type: string - secret: - description: Secret containing a RootPassword - type: string - storageClass: - description: Storage class to host the mariadb databases - type: string - storageRequest: - description: Storage size allocated for the mariadb databases - type: string - required: - - containerImage - - secret - - storageClass - - storageRequest - type: object - status: - description: MariaDBStatus defines the observed state of MariaDB - properties: - conditions: - description: Conditions - items: - description: Condition defines an observation of a API resource - operational state. - properties: - lastTransitionTime: - description: Last time the condition transitioned from one status - to another. This should be when the underlying condition changed. - If that is not known, then using the time when the API field - changed is acceptable. - format: date-time - type: string - message: - description: A human readable message indicating details about - the transition. - type: string - reason: - description: The reason for the condition's last transition - in CamelCase. - type: string - severity: - description: Severity provides a classification of Reason code, - so the current situation is immediately understandable and - could act accordingly. It is meant for situations where Status=False - and it should be indicated if it is just informational, warning - (next reconciliation might fix it) or an error (e.g. DB create - issue and no actions to automatically resolve the issue can/should - be done). For conditions where Status=Unknown or Status=True - the Severity should be SeverityNone. - type: string - status: - description: Status of the condition, one of True, False, Unknown. - type: string - type: - description: Type of condition in CamelCase. - type: string - required: - - lastTransitionTime - - status - - type - type: object - type: array - dbInitHash: - description: db init completed - type: string - required: - - dbInitHash - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 4a94488b..cd85fc90 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -3,7 +3,6 @@ # It should be run by config/default resources: - bases/mariadb.openstack.org_galeras.yaml -- bases/mariadb.openstack.org_mariadbs.yaml - bases/mariadb.openstack.org_mariadbdatabases.yaml - bases/mariadb.openstack.org_mariadbaccounts.yaml #+kubebuilder:scaffold:crdkustomizeresource @@ -12,7 +11,6 @@ patchesStrategicMerge: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD #- patches/webhook_in_galeras.yaml -#- patches/webhook_in_mariadbs.yaml #- patches/webhook_in_mariadbdatabases.yaml #- patches/webhook_in_mariadbaccounts.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch @@ -20,7 +18,6 @@ patchesStrategicMerge: # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD #- patches/cainjection_in_galeras.yaml -#- patches/cainjection_in_mariadbs.yaml #- patches/cainjection_in_mariadbdatabases.yaml #- patches/cainjection_in_mariadbaccounts.yaml #+kubebuilder:scaffold:crdkustomizecainjectionpatch diff --git a/config/crd/patches/cainjection_in_mariadbs.yaml b/config/crd/patches/cainjection_in_mariadbs.yaml deleted file mode 100644 index bec637dc..00000000 --- a/config/crd/patches/cainjection_in_mariadbs.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) - name: mariadbs.mariadb.openstack.org diff --git a/config/crd/patches/webhook_in_mariadbs.yaml b/config/crd/patches/webhook_in_mariadbs.yaml deleted file mode 100644 index 7d5ef5d7..00000000 --- a/config/crd/patches/webhook_in_mariadbs.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: mariadbs.mariadb.openstack.org -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1 diff --git a/config/manifests/bases/mariadb-operator.clusterserviceversion.yaml b/config/manifests/bases/mariadb-operator.clusterserviceversion.yaml index 9c6a27b7..78fab284 100644 --- a/config/manifests/bases/mariadb-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/mariadb-operator.clusterserviceversion.yaml @@ -29,11 +29,6 @@ spec: kind: MariaDBDatabase name: mariadbdatabases.mariadb.openstack.org version: v1beta1 - - description: MariaDB is the Schema for the mariadbs API - displayName: Maria DB - kind: MariaDB - name: mariadbs.mariadb.openstack.org - version: v1beta1 description: MariaDB Operator displayName: MariaDB Operator install: diff --git a/config/rbac/mariadb_editor_role.yaml b/config/rbac/mariadb_editor_role.yaml deleted file mode 100644 index 840cb3ff..00000000 --- a/config/rbac/mariadb_editor_role.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# permissions for end users to edit mariadbs. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: mariadb-editor-role -rules: -- apiGroups: - - mariadb.openstack.org - resources: - - mariadbs - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - mariadb.openstack.org - resources: - - mariadbs/status - verbs: - - get diff --git a/config/rbac/mariadb_viewer_role.yaml b/config/rbac/mariadb_viewer_role.yaml deleted file mode 100644 index 01c1b879..00000000 --- a/config/rbac/mariadb_viewer_role.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# permissions for end users to view mariadbs. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: mariadb-viewer-role -rules: -- apiGroups: - - mariadb.openstack.org - resources: - - mariadbs - verbs: - - get - - list - - watch -- apiGroups: - - mariadb.openstack.org - resources: - - mariadbs/status - verbs: - - get diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index d8dbef82..3cd2733f 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -213,33 +213,6 @@ rules: - get - patch - update -- apiGroups: - - mariadb.openstack.org - resources: - - mariadbs - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - mariadb.openstack.org - resources: - - mariadbs/finalizers - verbs: - - update -- apiGroups: - - mariadb.openstack.org - resources: - - mariadbs/status - verbs: - - get - - list - - patch - - update - apiGroups: - rbac.authorization.k8s.io resources: diff --git a/config/samples/kustomization.yaml b/config/samples/kustomization.yaml index cb8e4142..b83a11b9 100644 --- a/config/samples/kustomization.yaml +++ b/config/samples/kustomization.yaml @@ -1,6 +1,5 @@ ## Append samples you want in your CSV to this file as resources ## resources: -- mariadb_v1beta1_mariadb.yaml - mariadb_v1beta1_mariadbdatabase.yaml - mariadb_v1beta1_galera.yaml - mariadb_v1beta1_mariadbaccount.yaml diff --git a/config/samples/mariadb_v1beta1_mariadb.yaml b/config/samples/mariadb_v1beta1_mariadb.yaml deleted file mode 100644 index 5efed2d0..00000000 --- a/config/samples/mariadb_v1beta1_mariadb.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: mariadb.openstack.org/v1beta1 -kind: MariaDB -metadata: - name: openstack -spec: - secret: osp-secret - storageClass: local-storage - storageRequest: 500M diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml index cc9ba7d6..6e1cbb13 100644 --- a/config/webhook/manifests.yaml +++ b/config/webhook/manifests.yaml @@ -25,26 +25,6 @@ webhooks: resources: - galeras sideEffects: None -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: webhook-service - namespace: system - path: /mutate-mariadb-openstack-org-v1beta1-mariadb - failurePolicy: Fail - name: mmariadb.kb.io - rules: - - apiGroups: - - mariadb.openstack.org - apiVersions: - - v1beta1 - operations: - - CREATE - - UPDATE - resources: - - mariadbs - sideEffects: None --- apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration @@ -72,23 +52,3 @@ webhooks: resources: - galeras sideEffects: None -- admissionReviewVersions: - - v1 - clientConfig: - service: - name: webhook-service - namespace: system - path: /validate-mariadb-openstack-org-v1beta1-mariadb - failurePolicy: Fail - name: vmariadb.kb.io - rules: - - apiGroups: - - mariadb.openstack.org - apiVersions: - - v1beta1 - operations: - - CREATE - - UPDATE - resources: - - mariadbs - sideEffects: None diff --git a/controllers/galera_controller.go b/controllers/galera_controller.go index 59d1b28a..13270a91 100644 --- a/controllers/galera_controller.go +++ b/controllers/galera_controller.go @@ -280,7 +280,7 @@ func assertPodsAttributesValidity(helper *helper.Helper, instance *mariadbv1.Gal // +kubebuilder:rbac:groups=apps,resources=statefulsets/status,verbs=get;list;watch // RBAC for pods -// +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch +// +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch;create;update;patch;delete; // +kubebuilder:rbac:groups=core,resources=pods/exec,verbs=create // RBAC for services and endpoints @@ -299,6 +299,8 @@ func assertPodsAttributesValidity(helper *helper.Helper, instance *mariadbv1.Gal // +kubebuilder:rbac:groups="security.openshift.io",resourceNames=anyuid,resources=securitycontextconstraints,verbs=use // +kubebuilder:rbac:groups="",resources=pods,verbs=create;delete;get;list;patch;update;watch +// +kubebuilder:rbac:groups=core,resources=persistentvolumeclaims,verbs=get;list;watch;create;update;delete; + // Reconcile - Galera func (r *GaleraReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, _err error) { log := GetLog(ctx, "galera") @@ -678,7 +680,7 @@ func (r *GaleraReconciler) SetupWithManager(mgr ctrl.Manager) error { // used by both MariaDBDatabaseReconciler and MariaDBAccountReconciler // this will later return only Galera objects, so as a lookup it's part of the galera controller -func GetDatabaseObject(clientObj client.Client, ctx context.Context, name string, namespace string) (client.Object, error) { +func GetDatabaseObject(clientObj client.Client, ctx context.Context, name string, namespace string) (*databasev1beta1.Galera, error) { dbGalera := &databasev1beta1.Galera{ ObjectMeta: metav1.ObjectMeta{ @@ -690,28 +692,10 @@ func GetDatabaseObject(clientObj client.Client, ctx context.Context, name string objectKey := client.ObjectKeyFromObject(dbGalera) err := clientObj.Get(ctx, objectKey, dbGalera) - if err != nil && !k8s_errors.IsNotFound(err) { - return nil, err - } - if err != nil { - // Try to fetch MariaDB when Galera is not used - dbMariadb := &databasev1beta1.MariaDB{ - ObjectMeta: metav1.ObjectMeta{ - Name: name, - Namespace: namespace, - }, - } - - objectKey = client.ObjectKeyFromObject(dbMariadb) - - err = clientObj.Get(ctx, objectKey, dbMariadb) - if err != nil { - return nil, err - } - - return dbMariadb, nil + return nil, err + } else { + return dbGalera, err } - return dbGalera, nil } diff --git a/controllers/mariadb_controller.go b/controllers/mariadb_controller.go deleted file mode 100644 index ab208ba8..00000000 --- a/controllers/mariadb_controller.go +++ /dev/null @@ -1,380 +0,0 @@ -/* - - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package controllers - -import ( - "context" - "fmt" - "time" - - corev1 "k8s.io/api/core/v1" - rbacv1 "k8s.io/api/rbac/v1" - k8s_errors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/api/resource" - "k8s.io/apimachinery/pkg/runtime" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - - condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" - configmap "github.com/openstack-k8s-operators/lib-common/modules/common/configmap" - env "github.com/openstack-k8s-operators/lib-common/modules/common/env" - helper "github.com/openstack-k8s-operators/lib-common/modules/common/helper" - job "github.com/openstack-k8s-operators/lib-common/modules/common/job" - labels "github.com/openstack-k8s-operators/lib-common/modules/common/labels" - common_rbac "github.com/openstack-k8s-operators/lib-common/modules/common/rbac" - util "github.com/openstack-k8s-operators/lib-common/modules/common/util" - databasev1beta1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" - mariadb "github.com/openstack-k8s-operators/mariadb-operator/pkg/mariadb" - "k8s.io/client-go/kubernetes" -) - -// MariaDBReconciler reconciles a MariaDB object -type MariaDBReconciler struct { - Client client.Client - Kclient kubernetes.Interface - Scheme *runtime.Scheme -} - -// +kubebuilder:rbac:groups=mariadb.openstack.org,resources=mariadbs,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=mariadb.openstack.org,resources=mariadbs/status,verbs=get;update;patch -// +kubebuilder:rbac:groups=mariadb.openstack.org,resources=mariadbs/finalizers,verbs=update -// +kubebuilder:rbac:groups=core,resources=services,verbs=get;list;watch;create;update;delete; -// +kubebuilder:rbac:groups=core,resources=endpoints,verbs=get;list;watch;create;update;delete; -// +kubebuilder:rbac:groups=core,resources=configmaps,verbs=get;list;watch;create;update;delete; -// +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch;create;update;patch;delete; -// +kubebuilder:rbac:groups=core,resources=persistentvolumeclaims,verbs=get;list;watch;create;update;delete; -// +kubebuilder:rbac:groups=batch,resources=jobs,verbs=get;list;watch;create;update;delete; -// +kubebuilder:rbac:groups="",resources=serviceaccounts,verbs=get;list;watch;create;update -// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=roles,verbs=get;list;watch;create;update -// +kubebuilder:rbac:groups="rbac.authorization.k8s.io",resources=rolebindings,verbs=get;list;watch;create;update -// +kubebuilder:rbac:groups="security.openshift.io",resourceNames=anyuid,resources=securitycontextconstraints,verbs=use -// +kubebuilder:rbac:groups="",resources=pods,verbs=create;delete;get;list;patch;update;watch - -// Reconcile reconcile mariadb API requests -func (r *MariaDBReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, _err error) { - log := GetLog(ctx, "MariaDBR") - - // Fetch the MariaDB instance - instance := &databasev1beta1.MariaDB{} - err := r.Client.Get(ctx, req.NamespacedName, instance) - if err != nil { - if k8s_errors.IsNotFound(err) { - return ctrl.Result{}, nil - } - return ctrl.Result{}, err - } - - // - // initialize status - // - if instance.Status.Conditions == nil { - instance.Status.Conditions = condition.Conditions{} - // initialize conditions used later as Status=Unknown - cl := condition.CreateList( - condition.UnknownCondition(condition.ExposeServiceReadyCondition, condition.InitReason, condition.ExposeServiceReadyInitMessage), - condition.UnknownCondition(condition.ServiceConfigReadyCondition, condition.InitReason, condition.ServiceConfigReadyInitMessage), - condition.UnknownCondition(databasev1beta1.MariaDBInitializedCondition, condition.InitReason, databasev1beta1.MariaDBInitializedInitMessage), - condition.UnknownCondition(condition.DeploymentReadyCondition, condition.InitReason, condition.DeploymentReadyInitMessage), - condition.UnknownCondition(condition.ServiceAccountReadyCondition, condition.InitReason, condition.ServiceAccountReadyInitMessage), - condition.UnknownCondition(condition.RoleReadyCondition, condition.InitReason, condition.RoleReadyInitMessage), - condition.UnknownCondition(condition.RoleBindingReadyCondition, condition.InitReason, condition.RoleBindingReadyInitMessage), - ) - - instance.Status.Conditions.Init(&cl) - - // Register overall status immediately to have an early feedback e.g. in the cli - if err := r.Client.Status().Update(ctx, instance); err != nil { - return ctrl.Result{}, err - } - } - - helper, err := helper.NewHelper( - instance, - r.Client, - r.Kclient, - r.Scheme, - log, - ) - if err != nil { - return ctrl.Result{}, err - } - - // Always patch the instance status when exiting this function so we can persist any changes. - defer func() { - // update the Ready condition based on the sub conditions - if instance.Status.Conditions.AllSubConditionIsTrue() { - instance.Status.Conditions.MarkTrue( - condition.ReadyCondition, condition.ReadyMessage) - } else { - // something is not ready so reset the Ready condition - instance.Status.Conditions.MarkUnknown( - condition.ReadyCondition, condition.InitReason, condition.ReadyInitMessage) - // and recalculate it based on the state of the rest of the conditions - instance.Status.Conditions.Set( - instance.Status.Conditions.Mirror(condition.ReadyCondition)) - } - err := helper.PatchInstance(ctx, instance) - if err != nil { - _err = err - return - } - }() - - rbacRules := []rbacv1.PolicyRule{ - { - APIGroups: []string{"security.openshift.io"}, - ResourceNames: []string{"anyuid"}, - Resources: []string{"securitycontextconstraints"}, - Verbs: []string{"use"}, - }, - { - APIGroups: []string{""}, - Resources: []string{"pods"}, - Verbs: []string{"create", "get", "list", "watch", "update", "patch", "delete"}, - }, - } - rbacResult, err := common_rbac.ReconcileRbac(ctx, helper, instance, rbacRules) - if err != nil { - return rbacResult, err - } else if (rbacResult != ctrl.Result{}) { - return rbacResult, nil - } - - // PVC - // TODO: Add PVC condition handling? We don't currently in other operators that have PVC concerns, though - pvc := mariadb.Pvc(instance) - op, err := controllerutil.CreateOrPatch(ctx, r.Client, pvc, func() error { - - pvc.Spec.Resources.Requests = corev1.ResourceList{ - corev1.ResourceStorage: resource.MustParse(instance.Spec.StorageRequest), - } - - pvc.Spec.StorageClassName = &instance.Spec.StorageClass - pvc.Spec.AccessModes = []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce} - - err := controllerutil.SetOwnerReference(instance, pvc, r.Client.Scheme()) - if err != nil { - return err - } - return nil - }) - if err != nil { - return ctrl.Result{}, err - } - if op != controllerutil.OperationResultNone { - log.Info("", "Kind", instance.Kind, "Name", instance.Name, "database PVC", pvc.Name, "operation:", string(op)) - return ctrl.Result{RequeueAfter: time.Duration(5) * time.Second}, err - } - - // Service - service := mariadb.Service(instance) - op, err = controllerutil.CreateOrPatch(ctx, r.Client, service, func() error { - err := controllerutil.SetControllerReference(instance, service, r.Scheme) - if err != nil { - return err - } - return nil - }) - if err != nil { - instance.Status.Conditions.Set(condition.FalseCondition( - condition.ExposeServiceReadyCondition, - condition.ErrorReason, - condition.SeverityWarning, - condition.ExposeServiceReadyErrorMessage, - err.Error())) - return ctrl.Result{}, err - } - if op != controllerutil.OperationResultNone { - log.Info("Service successfully reconciled", "service", service.Name, "operation:", string(op)) - } - - // Endpoints - endpoints := mariadb.Endpoints(instance) - if endpoints != nil { - op, err = controllerutil.CreateOrPatch(ctx, r.Client, endpoints, func() error { - err := controllerutil.SetControllerReference(instance, endpoints, r.Scheme) - if err != nil { - return err - } - return nil - }) - if err != nil { - instance.Status.Conditions.Set(condition.FalseCondition( - condition.ExposeServiceReadyCondition, - condition.ErrorReason, - condition.SeverityWarning, - condition.ExposeServiceReadyErrorMessage, - err.Error())) - return ctrl.Result{}, err - } - if op != controllerutil.OperationResultNone { - log.Info("Endpoints successfully reconciled", "endpoint", endpoints.Name, "operation", string(op)) - } - } - - instance.Status.Conditions.MarkTrue(condition.ExposeServiceReadyCondition, condition.ExposeServiceReadyMessage) - - // Generate the config maps for the various services - configMapVars := make(map[string]env.Setter) - err = r.generateServiceConfigMaps(ctx, helper, instance, &configMapVars) - if err != nil { - instance.Status.Conditions.Set(condition.FalseCondition( - condition.ServiceConfigReadyCondition, - condition.ErrorReason, - condition.SeverityWarning, - condition.ServiceConfigReadyErrorMessage, - err.Error())) - return ctrl.Result{}, fmt.Errorf("error calculating configmap hash: %w", err) - } - mergedMapVars := env.MergeEnvs([]corev1.EnvVar{}, configMapVars) - configHash := "" - for _, hashEnv := range mergedMapVars { - configHash = configHash + hashEnv.Value - } - - instance.Status.Conditions.MarkTrue(condition.ServiceConfigReadyCondition, condition.ServiceConfigReadyMessage) - - // Define a new Job object - jobDef := mariadb.DbInitJob(instance) - - job := job.NewJob( - jobDef, - "dbinit", - false, - time.Duration(5)*time.Second, - instance.Status.DbInitHash, - ) - - ctrlResult, err := job.DoJob( - ctx, - helper, - ) - if (ctrlResult != ctrl.Result{}) { - instance.Status.Conditions.Set(condition.FalseCondition( - databasev1beta1.MariaDBInitializedCondition, - condition.RequestedReason, - condition.SeverityInfo, - databasev1beta1.MariaDBInitializedRunningMessage)) - return ctrlResult, nil - } - if err != nil { - instance.Status.Conditions.Set(condition.FalseCondition( - databasev1beta1.MariaDBInitializedCondition, - condition.ErrorReason, - condition.SeverityWarning, - databasev1beta1.MariaDBInitializedErrorMessage, - err.Error())) - return ctrl.Result{}, err - } - if job.HasChanged() { - instance.Status.DbInitHash = job.GetHash() - if err := r.Client.Status().Update(ctx, instance); err != nil { - return ctrl.Result{}, err - } - log.Info("Job hash added", "Job", jobDef.Name, "status", instance.Status.DbInitHash) - } - - instance.Status.Conditions.MarkTrue(databasev1beta1.MariaDBInitializedCondition, databasev1beta1.MariaDBInitializedReadyMessage) - - // Pod - pod := mariadb.Pod(instance, configHash) - - op, err = controllerutil.CreateOrPatch(ctx, r.Client, pod, func() error { - pod.Spec.Containers[0].Image = instance.Spec.ContainerImage - err := controllerutil.SetControllerReference(instance, pod, r.Scheme) - if err != nil { - return err - } - return nil - }) - - if err != nil { - instance.Status.Conditions.Set(condition.FalseCondition( - condition.DeploymentReadyCondition, - condition.ErrorReason, - condition.SeverityWarning, - condition.DeploymentReadyErrorMessage, - err.Error())) - return ctrl.Result{}, err - } - - if op != controllerutil.OperationResultNone { - instance.Status.Conditions.Set(condition.FalseCondition( - condition.DeploymentReadyCondition, - condition.RequestedReason, - condition.SeverityInfo, - condition.DeploymentReadyRunningMessage)) - - log.Info("Pod successfully reconciled", "pod", pod.Name, "operation", string(op)) - } - - if pod.Status.Phase == corev1.PodRunning { - instance.Status.Conditions.MarkTrue(condition.DeploymentReadyCondition, condition.DeploymentReadyMessage) - } - - return ctrl.Result{}, nil -} - -func (r *MariaDBReconciler) generateServiceConfigMaps( - ctx context.Context, - h *helper.Helper, - instance *databasev1beta1.MariaDB, - envVars *map[string]env.Setter, -) error { - cmLabels := labels.GetLabels(instance, labels.GetGroupLabel(mariadb.ServiceName), map[string]string{}) - templateParameters := make(map[string]interface{}) - // TODO: We probably need to make this configurable. - templateParameters["DbMaxTimeout"] = 60 - - // ConfigMaps for mariadb - cms := []util.Template{ - // ScriptsConfigMap - { - Name: "mariadb-" + instance.Name, - Namespace: instance.Namespace, - Type: util.TemplateTypeScripts, - InstanceType: instance.Kind, - AdditionalTemplate: map[string]string{}, - ConfigOptions: templateParameters, - Labels: cmLabels, - }, - } - - err := configmap.EnsureConfigMaps(ctx, h, instance, cms, envVars) - - if err != nil { - // FIXME error conditions here - return err - } - - return nil -} - -// SetupWithManager - -func (r *MariaDBReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&databasev1beta1.MariaDB{}). - Owns(&corev1.Service{}). - Owns(&corev1.ConfigMap{}). - Owns(&corev1.PersistentVolumeClaim{}). - Owns(&corev1.Pod{}). - Owns(&corev1.ServiceAccount{}). - Owns(&rbacv1.Role{}). - Owns(&rbacv1.RoleBinding{}). - Complete(r) -} diff --git a/controllers/mariadbaccount_controller.go b/controllers/mariadbaccount_controller.go index bb035644..72e62b45 100644 --- a/controllers/mariadbaccount_controller.go +++ b/controllers/mariadbaccount_controller.go @@ -222,7 +222,7 @@ func (r *MariaDBAccountReconciler) reconcileCreate( // referenced by the MariaDBDatabase which will lead us to the hostname // and container image to target - db, err := r.getDatabaseObject(ctx, mariadbDatabase, instance) + dbGalera, err := r.getDatabaseObject(ctx, mariadbDatabase, instance) if err != nil { log.Error(err, "Error getting database object") @@ -239,34 +239,16 @@ func (r *MariaDBAccountReconciler) reconcileCreate( var dbInstance, dbAdminSecret, dbContainerImage, serviceAccountName string - dbGalera, isGalera := db.(*databasev1beta1.Galera) - dbMariadb, isMariaDB := db.(*databasev1beta1.MariaDB) - - if isGalera { - if !dbGalera.Status.Bootstrapped { - log.Info("DB bootstrap not complete. Requeue...") - return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil - } - - dbInstance = dbGalera.Name - dbAdminSecret = dbGalera.Spec.Secret - dbContainerImage = dbGalera.Spec.ContainerImage - serviceAccountName = dbGalera.RbacResourceName() - } else if isMariaDB { - if dbMariadb.Status.DbInitHash == "" { - log.Info("DB initialization not complete. Requeue...") - return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil - } - - dbInstance = dbMariadb.Name - dbAdminSecret = dbMariadb.Spec.Secret - dbContainerImage = dbMariadb.Spec.ContainerImage - serviceAccountName = dbMariadb.RbacResourceName() - } else { - log.Error(err, "no mariadb or galera, should not be here") - return ctrl.Result{}, err + if !dbGalera.Status.Bootstrapped { + log.Info("DB bootstrap not complete. Requeue...") + return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil } + dbInstance = dbGalera.Name + dbAdminSecret = dbGalera.Spec.Secret + dbContainerImage = dbGalera.Spec.ContainerImage + serviceAccountName = dbGalera.RbacResourceName() + instance.Status.Conditions.MarkTrue( databasev1beta1.MariaDBServerReadyCondition, databasev1beta1.MariaDBServerReadyMessage, @@ -416,7 +398,7 @@ func (r *MariaDBAccountReconciler) reconcileDelete( // referenced by the MariaDBDatabase which will lead us to the hostname // and container image to target - db, err := r.getDatabaseObject(ctx, mariadbDatabase, instance) + dbGalera, err := r.getDatabaseObject(ctx, mariadbDatabase, instance) if err != nil { log.Error(err, "Error getting database object") @@ -443,34 +425,16 @@ func (r *MariaDBAccountReconciler) reconcileDelete( var dbInstance, dbAdminSecret, dbContainerImage, serviceAccountName string - dbGalera, isGalera := db.(*databasev1beta1.Galera) - dbMariadb, isMariaDB := db.(*databasev1beta1.MariaDB) - - if isGalera { - if !dbGalera.Status.Bootstrapped { - log.Info("DB bootstrap not complete. Requeue...") - return ctrl.Result{RequeueAfter: time.Second * 10}, nil - } - - dbInstance = dbGalera.Name - dbAdminSecret = dbGalera.Spec.Secret - dbContainerImage = dbGalera.Spec.ContainerImage - serviceAccountName = dbGalera.RbacResourceName() - } else if isMariaDB { - if dbMariadb.Status.DbInitHash == "" { - log.Info("DB initialization not complete. Requeue...") - return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil - } - - dbInstance = dbMariadb.Name - dbAdminSecret = dbMariadb.Spec.Secret - dbContainerImage = dbMariadb.Spec.ContainerImage - serviceAccountName = dbMariadb.RbacResourceName() - } else { - log.Error(err, "no mariadb or galera, should not be here") - return ctrl.Result{}, err + if !dbGalera.Status.Bootstrapped { + log.Info("DB bootstrap not complete. Requeue...") + return ctrl.Result{RequeueAfter: time.Second * 10}, nil } + dbInstance = dbGalera.Name + dbAdminSecret = dbGalera.Spec.Secret + dbContainerImage = dbGalera.Spec.ContainerImage + serviceAccountName = dbGalera.RbacResourceName() + instance.Status.Conditions.MarkTrue( databasev1beta1.MariaDBServerReadyCondition, databasev1beta1.MariaDBServerReadyMessage, @@ -524,7 +488,7 @@ func (r *MariaDBAccountReconciler) reconcileDelete( } // getDatabaseObject - returns either a Galera or MariaDB object (and an associated client.Object interface) -func (r *MariaDBAccountReconciler) getDatabaseObject(ctx context.Context, mariaDBDatabase *databasev1beta1.MariaDBDatabase, instance *databasev1beta1.MariaDBAccount) (client.Object, error) { +func (r *MariaDBAccountReconciler) getDatabaseObject(ctx context.Context, mariaDBDatabase *databasev1beta1.MariaDBDatabase, instance *databasev1beta1.MariaDBAccount) (*databasev1beta1.Galera, error) { dbName := mariaDBDatabase.ObjectMeta.Labels["dbName"] return GetDatabaseObject( r.Client, ctx, diff --git a/controllers/mariadbdatabase_controller.go b/controllers/mariadbdatabase_controller.go index 92430262..1cb466c2 100644 --- a/controllers/mariadbdatabase_controller.go +++ b/controllers/mariadbdatabase_controller.go @@ -44,7 +44,6 @@ type MariaDBDatabaseReconciler struct { // +kubebuilder:rbac:groups=mariadb.openstack.org,resources=mariadbdatabases,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=mariadb.openstack.org,resources=mariadbdatabases/status,verbs=get;update;patch // +kubebuilder:rbac:groups=mariadb.openstack.org,resources=mariadbdatabases/finalizers,verbs=update -// +kubebuilder:rbac:groups=mariadb.openstack.org,resources=mariadbs/status,verbs=get;list // +kubebuilder:rbac:groups=mariadb.openstack.org,resources=galeras/status,verbs=get;list // +kubebuilder:rbac:groups=batch,resources=jobs,verbs=get;list;watch;create;update;delete;patch @@ -81,15 +80,14 @@ func (r *MariaDBDatabaseReconciler) Reconcile(ctx context.Context, req ctrl.Requ } }() - // Fetch the Galera or MariaDB instance from which we'll pull the credentials - // Note: this will go away when we transition to galera as the db - db, err := r.getDatabaseObject(ctx, instance) + // Fetch the Galera instance from which we'll pull the credentials + dbGalera, err := r.getDatabaseObject(ctx, instance) - // if we are being deleted then we have to remove the finalizer from MariaDB/Galera and then remove it from ourselves + // if we are being deleted then we have to remove the finalizer from Galera and then remove it from ourselves if !instance.DeletionTimestamp.IsZero() { - if err == nil { // so we have MariaDB or Galera to remove finalizer from - if controllerutil.RemoveFinalizer(db, fmt.Sprintf("%s-%s", helper.GetFinalizer(), instance.Name)) { - err := r.Update(ctx, db) + if err == nil { // so we have Galera to remove finalizer from + if controllerutil.RemoveFinalizer(dbGalera, fmt.Sprintf("%s-%s", helper.GetFinalizer(), instance.Name)) { + err := r.Update(ctx, dbGalera) if err != nil { return ctrl.Result{}, err } @@ -106,17 +104,17 @@ func (r *MariaDBDatabaseReconciler) Reconcile(ctx context.Context, req ctrl.Requ // we now know that this is not a delete case if err != nil { if k8s_errors.IsNotFound(err) { - // as it is not a delete case we need to wait for MariaDB or Galera to exists before we can continue. + // as it is not a delete case we need to wait for Galera to exists before we can continue. return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil } return ctrl.Result{}, err } - // here we know that MariaDB or Galera exists so add a finalizer to ourselves and to the db CR. Before this point there is no reason to have a finalizer on ourselves as nothing to cleanup. + // here we know that Galera exists so add a finalizer to ourselves and to the db CR. Before this point there is no reason to have a finalizer on ourselves as nothing to cleanup. if instance.DeletionTimestamp.IsZero() { // this condition can be removed if you wish as it is always true at this point otherwise we would returned earlier. - if controllerutil.AddFinalizer(db, fmt.Sprintf("%s-%s", helper.GetFinalizer(), instance.Name)) { - err := r.Update(ctx, db) + if controllerutil.AddFinalizer(dbGalera, fmt.Sprintf("%s-%s", helper.GetFinalizer(), instance.Name)) { + err := r.Update(ctx, dbGalera) if err != nil { return ctrl.Result{}, err } @@ -133,34 +131,16 @@ func (r *MariaDBDatabaseReconciler) Reconcile(ctx context.Context, req ctrl.Requ // var dbName, dbSecret, dbContainerImage, serviceAccount string - // It is impossible to reach here without either dbGalera or dbMariadb not being nil, due to the checks above - - dbGalera, isGalera := db.(*databasev1beta1.Galera) - dbMariadb, isMariaDB := db.(*databasev1beta1.MariaDB) - - if isGalera { - - if !dbGalera.Status.Bootstrapped { - log.Info("DB bootstrap not complete. Requeue...") - return ctrl.Result{RequeueAfter: time.Second * 10}, nil - } - - dbName = dbGalera.Name - dbSecret = dbGalera.Spec.Secret - dbContainerImage = dbGalera.Spec.ContainerImage - serviceAccount = dbGalera.RbacResourceName() - } else if isMariaDB { - if dbMariadb.Status.DbInitHash == "" { - log.Info("DB initialization not complete. Requeue...") - return ctrl.Result{RequeueAfter: time.Duration(10) * time.Second}, nil - } - - dbName = dbMariadb.Name - dbSecret = dbMariadb.Spec.Secret - dbContainerImage = dbMariadb.Spec.ContainerImage - serviceAccount = dbMariadb.RbacResourceName() + if !dbGalera.Status.Bootstrapped { + log.Info("DB bootstrap not complete. Requeue...") + return ctrl.Result{RequeueAfter: time.Second * 10}, nil } + dbName = dbGalera.Name + dbSecret = dbGalera.Spec.Secret + dbContainerImage = dbGalera.Spec.ContainerImage + serviceAccount = dbGalera.RbacResourceName() + // Define a new Job object (hostname, password, containerImage) jobDef, err := mariadb.DbDatabaseJob(instance, dbName, dbSecret, dbContainerImage, serviceAccount) if err != nil { @@ -206,8 +186,8 @@ func (r *MariaDBDatabaseReconciler) SetupWithManager(mgr ctrl.Manager) error { Complete(r) } -// getDatabaseObject - returns either a Galera or MariaDB object (and an associated client.Object interface) -func (r *MariaDBDatabaseReconciler) getDatabaseObject(ctx context.Context, instance *databasev1beta1.MariaDBDatabase) (client.Object, error) { +// getDatabaseObject - returns a Galera object +func (r *MariaDBDatabaseReconciler) getDatabaseObject(ctx context.Context, instance *databasev1beta1.MariaDBDatabase) (*databasev1beta1.Galera, error) { return GetDatabaseObject( r.Client, ctx, instance.ObjectMeta.Labels["dbName"], diff --git a/main.go b/main.go index 065c544a..d5bb41f3 100644 --- a/main.go +++ b/main.go @@ -110,14 +110,6 @@ func main() { setupLog.Error(err, "unable to create controller", "controller", "Galera") os.Exit(1) } - if err = (&controllers.MariaDBReconciler{ - Client: mgr.GetClient(), - Kclient: kclient, - Scheme: mgr.GetScheme(), - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "MariaDB") - os.Exit(1) - } if err = (&controllers.MariaDBDatabaseReconciler{ Client: mgr.GetClient(), Kclient: kclient, @@ -137,10 +129,6 @@ func main() { srv := mgr.GetWebhookServer() srv.TLSOpts = []func(config *tls.Config){disableHTTP2} - if err = (&mariadbv1beta1.MariaDB{}).SetupWebhookWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create webhook", "webhook", "MariaDB") - os.Exit(1) - } if err = (&mariadbv1beta1.Galera{}).SetupWebhookWithManager(mgr); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "Galera") os.Exit(1) diff --git a/pkg/mariadb/dbinit.go b/pkg/mariadb/dbinit.go deleted file mode 100644 index 43c1043c..00000000 --- a/pkg/mariadb/dbinit.go +++ /dev/null @@ -1,62 +0,0 @@ -package mariadb - -import ( - databasev1beta1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" - batchv1 "k8s.io/api/batch/v1" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// DbInitJob - -func DbInitJob(db *databasev1beta1.MariaDB) *batchv1.Job { - - job := &batchv1.Job{ - ObjectMeta: metav1.ObjectMeta{ - Name: db.Name + "-db-init", - Namespace: db.Namespace, - Labels: GetLabels(db.Name), - }, - Spec: batchv1.JobSpec{ - Template: corev1.PodTemplateSpec{ - Spec: corev1.PodSpec{ - RestartPolicy: corev1.RestartPolicyOnFailure, - ServiceAccountName: db.RbacResourceName(), - Containers: []corev1.Container{ - { - Name: "mariadb-init", - Image: db.Spec.ContainerImage, - Env: []corev1.EnvVar{ - { - Name: "KOLLA_CONFIG_STRATEGY", - Value: "COPY_ALWAYS", - }, - { - Name: "KOLLA_BOOTSTRAP", - Value: "true", - }, - { - Name: "DB_MAX_TIMEOUT", - Value: "60", - }, - { - Name: "DB_ROOT_PASSWORD", - ValueFrom: &corev1.EnvVarSource{ - SecretKeyRef: &corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{ - Name: db.Spec.Secret, - }, - Key: "DbRootPassword", - }, - }, - }, - }, - VolumeMounts: getInitVolumeMounts(), - }, - }, - Volumes: getVolumes(db.Name), - }, - }, - }, - } - return job -} diff --git a/pkg/mariadb/endpoints.go b/pkg/mariadb/endpoints.go index 45a5c50d..e9bf25f1 100644 --- a/pkg/mariadb/endpoints.go +++ b/pkg/mariadb/endpoints.go @@ -8,12 +8,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// Endpoints func -func Endpoints(db *databasev1beta1.MariaDB) *corev1.Endpoints { - adoption := &db.Spec.AdoptionRedirect - return EndpointsForAdoption(db, adoption) -} - // EndpointsForAdoption - create an endpoint based on the adoption configuration func EndpointsForAdoption(db metav1.Object, adoption *databasev1beta1.AdoptionRedirectSpec) *corev1.Endpoints { adoptionHost := adoption.Host diff --git a/pkg/mariadb/pod.go b/pkg/mariadb/pod.go deleted file mode 100644 index 2dd3b289..00000000 --- a/pkg/mariadb/pod.go +++ /dev/null @@ -1,41 +0,0 @@ -package mariadb - -import ( - databasev1beta1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// Pod - -func Pod(db *databasev1beta1.MariaDB, configHash string) *corev1.Pod { - - pod := &corev1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "mariadb-" + db.Name, - Namespace: db.Namespace, - Labels: GetLabels(db.Name), - }, - Spec: corev1.PodSpec{ - ServiceAccountName: db.RbacResourceName(), - Containers: []corev1.Container{ - { - Name: "mariadb", - Image: db.Spec.ContainerImage, - Env: []corev1.EnvVar{ - { - Name: "KOLLA_CONFIG_STRATEGY", - Value: "COPY_ALWAYS", - }, - { - Name: "CONFIG_HASH", - Value: configHash, - }, - }, - VolumeMounts: getVolumeMounts(), - }, - }, - Volumes: getVolumes(db.Name), - }, - } - return pod -} diff --git a/pkg/mariadb/pvc.go b/pkg/mariadb/pvc.go deleted file mode 100644 index 83b61aab..00000000 --- a/pkg/mariadb/pvc.go +++ /dev/null @@ -1,19 +0,0 @@ -package mariadb - -import ( - databasev1beta1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" - corev1 "k8s.io/api/core/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// Pvc - Returns the deployment object for the Database -func Pvc(db *databasev1beta1.MariaDB) *corev1.PersistentVolumeClaim { - pv := &corev1.PersistentVolumeClaim{ - ObjectMeta: v1.ObjectMeta{ - Name: "mariadb-" + db.Name, - Namespace: db.Namespace, - Labels: GetLabels(db.Name), - }, - } - return pv -} diff --git a/pkg/mariadb/service.go b/pkg/mariadb/service.go index 58d767fb..7be93497 100644 --- a/pkg/mariadb/service.go +++ b/pkg/mariadb/service.go @@ -1,18 +1,13 @@ package mariadb import ( + "net" + databasev1beta1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "net" ) -// Service func -func Service(db *databasev1beta1.MariaDB) *corev1.Service { - adoption := &db.Spec.AdoptionRedirect - return ServiceForAdoption(db, "mariadb", adoption) -} - // ServiceForAdoption - create a service based on the adoption configuration func ServiceForAdoption(db metav1.Object, dbType string, adoption *databasev1beta1.AdoptionRedirectSpec) *corev1.Service { adoptionHost := adoption.Host diff --git a/templates/mariadb/bin/config.json b/templates/mariadb/bin/config.json deleted file mode 100644 index b6890bc0..00000000 --- a/templates/mariadb/bin/config.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "command": "/usr/libexec/mysqld --user=mysql", - "config_files": [ - { - "source": "/var/lib/config-data/galera.cnf", - "dest": "/etc/my.cnf.d/galera.cnf", - "owner": "root", - "perm": "0600" - } - ] -} diff --git a/templates/mariadb/bin/galera.cnf b/templates/mariadb/bin/galera.cnf deleted file mode 100644 index 4bcea888..00000000 --- a/templates/mariadb/bin/galera.cnf +++ /dev/null @@ -1,39 +0,0 @@ -[client] -port = 3306 -socket = /var/lib/mysql/mysql.sock - -[isamchk] -key_buffer_size = 16M - -[mysqld] -basedir = /usr -bind-address = 127.0.0.1 -datadir = /var/lib/mysql -expire_logs_days = 10 -innodb_file_per_table = ON -key_buffer_size = 16M -max_allowed_packet = 16M -max_binlog_size = 100M -max_connections = 4096 -open_files_limit = 65536 -pid-file = /var/lib/mysql/mariadb.pid -port = 3306 -query_cache_limit = 1M -query_cache_size = 16M -skip-external-locking -socket = /var/lib/mysql/mysql.sock -ssl = false -thread_cache_size = 8 -thread_stack = 256K -tmpdir = /tmp -user = mysql - -[mysqld_safe] -nice = 0 -pid-file = /var/lib/mysql/mariadb.pid -socket = /var/lib/mysql/mysql.sock - -[mysqldump] -max_allowed_packet = 16M -quick -quote-names diff --git a/templates/mariadb/bin/init_config.json b/templates/mariadb/bin/init_config.json deleted file mode 100644 index 351a4fe4..00000000 --- a/templates/mariadb/bin/init_config.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "command": "/usr/local/bin/mariadb_init.sh", - "config_files": [ - { - "source": "/var/lib/config-data/galera.cnf", - "dest": "/etc/my.cnf.d/galera.cnf", - "owner": "root", - "perm": "0600" - }, - { - "source": "/var/lib/config-data/mariadb_init.sh", - "dest": "/usr/local/bin/mariadb_init.sh", - "owner": "root", - "perm": "0755" - } - ], - "permissions": [ - { - "path": "/var/lib/mysql", - "owner": "mysql:mysql", - "recurse": "true" - } - ] -} diff --git a/templates/mariadb/bin/mariadb_init.sh b/templates/mariadb/bin/mariadb_init.sh deleted file mode 100755 index f3f40c1d..00000000 --- a/templates/mariadb/bin/mariadb_init.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -set -e -if [ -e /var/lib/mysql/mysql ]; then exit 0; fi -#echo -e "\n[mysqld]\nwsrep_provider=none" >> /etc/my.cnf -#kolla_set_configs -#sudo -u mysql -E kolla_extend_start -mkdir -p /var/lib/mysql -mysql_install_db -mysqld_safe --skip-networking --wsrep-on=OFF & -timeout {{.DbMaxTimeout}} /bin/bash -c "until mysqladmin -uroot -p'$DB_ROOT_PASSWORD' ping 2>/dev/null; do sleep 1; done" -mysql -uroot -p"$DB_ROOT_PASSWORD" -e "CREATE USER 'mysql'@'localhost';" -mysql -uroot -p"$DB_ROOT_PASSWORD" -e "REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'mysql'@'localhost';" -timeout {{.DbMaxTimeout}} mysqladmin -uroot -p"$DB_ROOT_PASSWORD" shutdown diff --git a/tests/kuttl/tests/mariadb_deploy/01-assert.yaml b/tests/kuttl/tests/mariadb_deploy/01-assert.yaml deleted file mode 100644 index 44b5c61f..00000000 --- a/tests/kuttl/tests/mariadb_deploy/01-assert.yaml +++ /dev/null @@ -1,69 +0,0 @@ -# -# Check for: -# -# - 1 MariaDB CR -# - 1 Pod for MariaDB CR -# - -apiVersion: mariadb.openstack.org/v1beta1 -kind: MariaDB -metadata: - name: openstack -spec: - secret: osp-secret - storageRequest: 500M -status: - conditions: - - message: Setup complete - reason: Ready - status: "True" - type: Ready - - message: Deployment completed - reason: Ready - status: "True" - type: DeploymentReady - - message: Exposing service completed - reason: Ready - status: "True" - type: ExposeServiceReady - - message: MariaDB dbinit completed - reason: Ready - status: "True" - type: MariaDBInitialized - - message: RoleBinding created - reason: Ready - status: "True" - type: RoleBindingReady - - message: Role created - reason: Ready - status: "True" - type: RoleReady - - message: ServiceAccount created - reason: Ready - status: "True" - type: ServiceAccountReady - - message: Service config create completed - reason: Ready - status: "True" - type: ServiceConfigReady ---- -apiVersion: v1 -kind: Pod -metadata: - annotations: - openshift.io/scc: anyuid - labels: - app: mariadb - cr: mariadb-openstack - owner: mariadb-operator - name: mariadb-openstack -spec: - containers: - - imagePullPolicy: IfNotPresent - name: mariadb - resources: {} - restartPolicy: Always - serviceAccount: mariadb-openstack - serviceAccountName: mariadb-openstack -status: - phase: Running diff --git a/tests/kuttl/tests/mariadb_deploy/01-deploy-mariadb.yaml b/tests/kuttl/tests/mariadb_deploy/01-deploy-mariadb.yaml deleted file mode 120000 index d8c4505e..00000000 --- a/tests/kuttl/tests/mariadb_deploy/01-deploy-mariadb.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../config/samples/mariadb_v1beta1_mariadb.yaml \ No newline at end of file diff --git a/tests/kuttl/tests/mariadb_deploy/02-cleanup-mariadb.yaml b/tests/kuttl/tests/mariadb_deploy/02-cleanup-mariadb.yaml deleted file mode 100644 index c13a09cd..00000000 --- a/tests/kuttl/tests/mariadb_deploy/02-cleanup-mariadb.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -delete: -- apiVersion: mariadb.openstack.org/v1beta1 - kind: MariaDB - name: openstack diff --git a/tests/kuttl/tests/mariadb_deploy/02-errors.yaml b/tests/kuttl/tests/mariadb_deploy/02-errors.yaml deleted file mode 100644 index db00d0a8..00000000 --- a/tests/kuttl/tests/mariadb_deploy/02-errors.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# -# Check for: -# -# - No MariaDB CR -# - No Pod for MariaDB CR - -apiVersion: mariadb.openstack.org/v1beta1 -kind: MariaDB -metadata: - name: openstack ---- -apiVersion: v1 -kind: Pod -metadata: - labels: - app: mariadb - cr: mariadb-openstack - owner: mariadb-operator - name: mariadb-openstack