diff --git a/deploy/crds/planetscale.com_vitessclusters.yaml b/deploy/crds/planetscale.com_vitessclusters.yaml index e1da903a..9b56e67b 100644 --- a/deploy/crds/planetscale.com_vitessclusters.yaml +++ b/deploy/crds/planetscale.com_vitessclusters.yaml @@ -1172,6 +1172,16 @@ spec: type: string durabilityPolicy: type: string + images: + properties: + mysqld: + properties: + mysql56Compatible: + type: string + mysql80Compatible: + type: string + type: object + type: object name: maxLength: 63 minLength: 1 diff --git a/docs/api/index.html b/docs/api/index.html index 6cce83f3..809e6e46 100644 --- a/docs/api/index.html +++ b/docs/api/index.html @@ -1418,9 +1418,7 @@

MysqldImage VitessKeyspaceImages)

-

MysqldImage specifies the container image to use for mysqld, -as well as declaring which MySQL flavor setting in Vitess the -image is compatible with.

+

TODO: Remove this once everything is migrated to MysqldImageNew.

@@ -1480,6 +1478,52 @@

MysqldImage

+

MysqldImageNew +

+

+(Appears on: +VitessKeyspaceTemplateImages) +

+

+

MysqldImageNew specifies the container image to use for mysqld, +as well as declaring which MySQL flavor setting in Vitess the +image is compatible with.

+

TODO: rename this to MysqldImage once MysqldImage is removed.

+

+ + + + + + + + + + + + + + + + + +
FieldDescription
+mysql56Compatible
+ +string + +
+

Mysql56Compatible is a container image (including version tag) for mysqld +that’s compatible with the Vitess “MySQL56” flavor setting.

+
+mysql80Compatible
+ +string + +
+

Mysql80Compatible is a container image (including version tag) for mysqld +that’s compatible with the Vitess “MySQL80” flavor setting.

+

MysqldSpec

@@ -4738,10 +4782,12 @@

VitessKeyspace -

Images are not customizable by users at the keyspace level because version -skew across the cluster is discouraged except during rolling updates, -in which case this field is automatically managed by the VitessCluster -controller that owns this VitessKeyspace.

+

Images are inherited from the VitessCluster spec, unless the user has +specified keyspace-level overrides. Version skew across the cluster is +discouraged except during rolling updates, in which case this field is +automatically managed by the VitessCluster controller that owns this +VitessKeyspace, or else when a user has specified a keyspace-level +images on VitessKeyspaceTemplate.

@@ -5525,10 +5571,12 @@

VitessKeyspaceSpec -

Images are not customizable by users at the keyspace level because version -skew across the cluster is discouraged except during rolling updates, -in which case this field is automatically managed by the VitessCluster -controller that owns this VitessKeyspace.

+

Images are inherited from the VitessCluster spec, unless the user has +specified keyspace-level overrides. Version skew across the cluster is +discouraged except during rolling updates, in which case this field is +automatically managed by the VitessCluster controller that owns this +VitessKeyspace, or else when a user has specified a keyspace-level +images on VitessKeyspaceTemplate.

@@ -5904,6 +5952,57 @@

VitessKeyspaceTemplate

Annotations can optionally be used to attach custom annotations to the VitessKeyspace object.

+ + +images
+ + +VitessKeyspaceTemplateImages + + + + +

For special cases, users may specify per-VitessKeyspace images. An +example: migrating from MySQL 5.7 to MySQL 8.0 via a MoveTables +operation, after which the source keyspace is destroyed.

+ + + + +

VitessKeyspaceTemplateImages +

+

+(Appears on: +VitessKeyspaceTemplate) +

+

+

VitessKeyspaceTemplateImages specifies user-definable container images to +use for this keyspace.

+

+ + + + + + + + + + + +
FieldDescription
+mysqld
+ + +MysqldImageNew + + +
+

Mysqld specifies the container image to use for mysqld, as well as +declaring which MySQL flavor setting in Vitess the image is +compatible with. Only one flavor image may be provided at a time. +mysqld running alongside each tablet.

+

VitessKeyspaceTurndownPolicy diff --git a/pkg/apis/planetscale/v2/vitesscluster_types.go b/pkg/apis/planetscale/v2/vitesscluster_types.go index 8bbac586..f796d11b 100644 --- a/pkg/apis/planetscale/v2/vitesscluster_types.go +++ b/pkg/apis/planetscale/v2/vitesscluster_types.go @@ -244,9 +244,21 @@ type VitessImages struct { MysqldExporter string `json:"mysqldExporter,omitempty"` } -// MysqldImage specifies the container image to use for mysqld, +// MysqldImageNew specifies the container image to use for mysqld, // as well as declaring which MySQL flavor setting in Vitess the // image is compatible with. +// +// TODO: rename this to MysqldImage once MysqldImage is removed. +type MysqldImageNew struct { + // Mysql56Compatible is a container image (including version tag) for mysqld + // that's compatible with the Vitess "MySQL56" flavor setting. + Mysql56Compatible string `json:"mysql56Compatible,omitempty"` + // Mysql80Compatible is a container image (including version tag) for mysqld + // that's compatible with the Vitess "MySQL80" flavor setting. + Mysql80Compatible string `json:"mysql80Compatible,omitempty"` +} + +// TODO: Remove this once everything is migrated to MysqldImageNew. type MysqldImage struct { // Mysql56Compatible is a container image (including version tag) for mysqld // that's compatible with the Vitess "MySQL56" flavor setting. diff --git a/pkg/apis/planetscale/v2/vitesskeyspace_defaults.go b/pkg/apis/planetscale/v2/vitesskeyspace_defaults.go index 81189b87..aa5c51d2 100644 --- a/pkg/apis/planetscale/v2/vitesskeyspace_defaults.go +++ b/pkg/apis/planetscale/v2/vitesskeyspace_defaults.go @@ -69,3 +69,12 @@ func DefaultVitessKeyspaceImages(dst *VitessKeyspaceImages, clusterDefaults *Vit dst.MysqldExporter = clusterDefaults.MysqldExporter } } + +// MergeVitessKeyspaceTemplateImages takes non-empty image values from a non-nil src +// and sets them on dst. +func MergeVitessKeyspaceTemplateImages(dst *VitessKeyspaceImages, src *VitessKeyspaceTemplateImages) { + if src.Mysqld != nil { + dst.Mysqld.Mysql56Compatible = src.Mysqld.Mysql56Compatible + dst.Mysqld.Mysql80Compatible = src.Mysqld.Mysql80Compatible + } +} diff --git a/pkg/apis/planetscale/v2/vitesskeyspace_types.go b/pkg/apis/planetscale/v2/vitesskeyspace_types.go index 6f4e0ff1..1550b242 100644 --- a/pkg/apis/planetscale/v2/vitesskeyspace_types.go +++ b/pkg/apis/planetscale/v2/vitesskeyspace_types.go @@ -51,10 +51,12 @@ type VitessKeyspaceSpec struct { // GlobalLockserver are the params to connect to the global lockserver. GlobalLockserver VitessLockserverParams `json:"globalLockserver"` - // Images are not customizable by users at the keyspace level because version - // skew across the cluster is discouraged except during rolling updates, - // in which case this field is automatically managed by the VitessCluster - // controller that owns this VitessKeyspace. + // Images are inherited from the VitessCluster spec, unless the user has + // specified keyspace-level overrides. Version skew across the cluster is + // discouraged except during rolling updates, in which case this field is + // automatically managed by the VitessCluster controller that owns this + // VitessKeyspace, or else when a user has specified a keyspace-level + // images on VitessKeyspaceTemplate. Images VitessKeyspaceImages `json:"images,omitempty"` // ImagePullPolicies are inherited from the VitessCluster spec. @@ -178,6 +180,21 @@ type VitessKeyspaceTemplate struct { // Annotations can optionally be used to attach custom annotations to the VitessKeyspace object. Annotations map[string]string `json:"annotations,omitempty"` + + // For special cases, users may specify per-VitessKeyspace images. An + // example: migrating from MySQL 5.7 to MySQL 8.0 via a `MoveTables` + // operation, after which the source keyspace is destroyed. + Images VitessKeyspaceTemplateImages `json:"images,omitempty"` +} + +// VitessKeyspaceTemplateImages specifies user-definable container images to +// use for this keyspace. +type VitessKeyspaceTemplateImages struct { + // Mysqld specifies the container image to use for mysqld, as well as + // declaring which MySQL flavor setting in Vitess the image is + // compatible with. Only one flavor image may be provided at a time. + // mysqld running alongside each tablet. + Mysqld *MysqldImageNew `json:"mysqld,omitempty"` } // VitessOrchestratorSpec specifies deployment parameters for vtorc. diff --git a/pkg/apis/planetscale/v2/zz_generated.deepcopy.go b/pkg/apis/planetscale/v2/zz_generated.deepcopy.go index ff017d72..426ab67b 100644 --- a/pkg/apis/planetscale/v2/zz_generated.deepcopy.go +++ b/pkg/apis/planetscale/v2/zz_generated.deepcopy.go @@ -405,6 +405,21 @@ func (in *MysqldImage) DeepCopy() *MysqldImage { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MysqldImageNew) DeepCopyInto(out *MysqldImageNew) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MysqldImageNew. +func (in *MysqldImageNew) DeepCopy() *MysqldImageNew { + if in == nil { + return nil + } + out := new(MysqldImageNew) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MysqldSpec) DeepCopyInto(out *MysqldSpec) { *out = *in @@ -1983,6 +1998,7 @@ func (in *VitessKeyspaceTemplate) DeepCopyInto(out *VitessKeyspaceTemplate) { (*out)[key] = val } } + in.Images.DeepCopyInto(&out.Images) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VitessKeyspaceTemplate. @@ -1995,6 +2011,26 @@ func (in *VitessKeyspaceTemplate) DeepCopy() *VitessKeyspaceTemplate { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VitessKeyspaceTemplateImages) DeepCopyInto(out *VitessKeyspaceTemplateImages) { + *out = *in + if in.Mysqld != nil { + in, out := &in.Mysqld, &out.Mysqld + *out = new(MysqldImageNew) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VitessKeyspaceTemplateImages. +func (in *VitessKeyspaceTemplateImages) DeepCopy() *VitessKeyspaceTemplateImages { + if in == nil { + return nil + } + out := new(VitessKeyspaceTemplateImages) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VitessLockserverParams) DeepCopyInto(out *VitessLockserverParams) { *out = *in diff --git a/pkg/controller/vitesscluster/reconcile_keyspaces.go b/pkg/controller/vitesscluster/reconcile_keyspaces.go index 54ef4784..25136491 100644 --- a/pkg/controller/vitesscluster/reconcile_keyspaces.go +++ b/pkg/controller/vitesscluster/reconcile_keyspaces.go @@ -149,6 +149,9 @@ func newVitessKeyspace(key client.ObjectKey, vt *planetscalev2.VitessCluster, pa images := planetscalev2.VitessKeyspaceImages{} planetscalev2.DefaultVitessKeyspaceImages(&images, &vt.Spec.Images) + // Apply user-defined overrides for images. + planetscalev2.MergeVitessKeyspaceTemplateImages(&images, &keyspace.Images) + // Copy parent labels map and add keyspace-specific label. labels := make(map[string]string, len(parentLabels)+1) for k, v := range parentLabels { diff --git a/test/endtoend/operator/operator-latest.yaml b/test/endtoend/operator/operator-latest.yaml index caa658f7..847cc8b5 100644 --- a/test/endtoend/operator/operator-latest.yaml +++ b/test/endtoend/operator/operator-latest.yaml @@ -1,4 +1,3 @@ ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -2490,6 +2489,16 @@ spec: type: string durabilityPolicy: type: string + images: + properties: + mysqld: + properties: + mysql56Compatible: + type: string + mysql80Compatible: + type: string + type: object + type: object name: maxLength: 63 minLength: 1 @@ -6318,6 +6327,22 @@ subjects: - kind: ServiceAccount name: vitess-operator --- +apiVersion: scheduling.k8s.io/v1 +description: Vitess components (vttablet, vtgate, vtctld, etcd) +globalDefault: false +kind: PriorityClass +metadata: + name: vitess +value: 1000 +--- +apiVersion: scheduling.k8s.io/v1 +description: The vitess-operator control plane. +globalDefault: false +kind: PriorityClass +metadata: + name: vitess-operator-control-plane +value: 5000 +--- apiVersion: apps/v1 kind: Deployment metadata: @@ -6368,19 +6393,3 @@ spec: memory: 128Mi priorityClassName: vitess-operator-control-plane serviceAccountName: vitess-operator ---- -apiVersion: scheduling.k8s.io/v1 -description: The vitess-operator control plane. -globalDefault: false -kind: PriorityClass -metadata: - name: vitess-operator-control-plane -value: 5000 ---- -apiVersion: scheduling.k8s.io/v1 -description: Vitess components (vttablet, vtgate, vtctld, etcd) -globalDefault: false -kind: PriorityClass -metadata: - name: vitess -value: 1000