Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: Fix the setting method of innodb_buffer_pool_instances parameter and change podSpec.Resources name. #244 #265

Merged
merged 2 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions api/v1alpha1/mysqlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ type MysqlClusterSpec struct {
// +kubebuilder:default:="5.7"
MysqlVersion string `json:"mysqlVersion,omitempty"`

// Pod extra specification.
// PodPolicy defines the policy to extra specification.
// +optional
// +kubebuilder:default:={imagePullPolicy: "IfNotPresent", resources: {requests: {cpu: "10m", memory: "32Mi"}}, sidecarImage: "radondb/mysql-sidecar:0.1", busyboxImage: "busybox:1.32"}
PodSpec PodSpec `json:"podSpec,omitempty"`
// +kubebuilder:default:={imagePullPolicy: "IfNotPresent", extraResources: {requests: {cpu: "10m", memory: "32Mi"}}, sidecarImage: "radondb/mysql-sidecar:latest", busyboxImage: "busybox:1.32"}
PodPolicy PodPolicy `json:"podPolicy,omitempty"`

// PVC extra specifiaction.
// +optional
Expand Down Expand Up @@ -178,8 +178,8 @@ type MetricsOpts struct {
// string and string.
type MysqlConf map[string]string

// PodSpec defines type for configure cluster pod spec.
type PodSpec struct {
// PodPolicy defines the general configuration and extra resources of pod.
type PodPolicy struct {
// +kubebuilder:validation:Enum=Always;IfNotPresent;Never
// +kubebuilder:default:="IfNotPresent"
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
Expand All @@ -191,10 +191,11 @@ type PodSpec struct {
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
SchedulerName string `json:"schedulerName,omitempty"`

// The compute resource requirements.
// ExtraResources defines quotas for containers other than mysql or xenon.
// These containers take up less resources, so quotas are set uniformly.
// +optional
// +kubebuilder:default:={requests: {cpu: "10m", memory: "32Mi"}}
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
ExtraResources corev1.ResourceRequirements `json:"extraResources,omitempty"`

// To specify the image that will be used for sidecar container.
// +optional
Expand Down
12 changes: 6 additions & 6 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 24 additions & 22 deletions charts/mysql-operator/crds/mysql.radondb.com_mysqlclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,16 @@ spec:
More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1'
type: string
type: object
podSpec:
podPolicy:
default:
busyboxImage: busybox:1.32
imagePullPolicy: IfNotPresent
resources:
extraResources:
requests:
cpu: 10m
memory: 32Mi
sidecarImage: radondb/mysql-sidecar:0.1
description: Pod extra specification.
imagePullPolicy: IfNotPresent
sidecarImage: radondb/mysql-sidecar:latest
description: PodPolicy defines the policy to extra specification.
properties:
affinity:
description: Affinity is a group of affinity scheduling rules.
Expand Down Expand Up @@ -1132,27 +1132,14 @@ spec:
default: busybox:1.32
description: The busybox image.
type: string
imagePullPolicy:
default: IfNotPresent
description: PullPolicy describes a policy for if/when to pull
a container image
enum:
- Always
- IfNotPresent
- Never
type: string
labels:
additionalProperties:
type: string
type: object
priorityClassName:
type: string
resources:
extraResources:
default:
requests:
cpu: 10m
memory: 32Mi
description: The compute resource requirements.
description: ExtraResources defines quotas for containers other
than mysql or xenon. These containers take up less resources,
so quotas are set uniformly.
properties:
limits:
additionalProperties:
Expand All @@ -1177,6 +1164,21 @@ spec:
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
imagePullPolicy:
default: IfNotPresent
description: PullPolicy describes a policy for if/when to pull
a container image
enum:
- Always
- IfNotPresent
- Never
type: string
labels:
additionalProperties:
type: string
type: object
priorityClassName:
type: string
schedulerName:
type: string
sidecarImage:
Expand Down
46 changes: 24 additions & 22 deletions config/crd/bases/mysql.radondb.com_mysqlclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,16 @@ spec:
More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1'
type: string
type: object
podSpec:
podPolicy:
default:
busyboxImage: busybox:1.32
imagePullPolicy: IfNotPresent
resources:
extraResources:
requests:
cpu: 10m
memory: 32Mi
sidecarImage: radondb/mysql-sidecar:0.1
description: Pod extra specification.
imagePullPolicy: IfNotPresent
sidecarImage: radondb/mysql-sidecar:latest
description: PodPolicy defines the policy to extra specification.
properties:
affinity:
description: Affinity is a group of affinity scheduling rules.
Expand Down Expand Up @@ -1132,27 +1132,14 @@ spec:
default: busybox:1.32
description: The busybox image.
type: string
imagePullPolicy:
default: IfNotPresent
description: PullPolicy describes a policy for if/when to pull
a container image
enum:
- Always
- IfNotPresent
- Never
type: string
labels:
additionalProperties:
type: string
type: object
priorityClassName:
type: string
resources:
extraResources:
default:
requests:
cpu: 10m
memory: 32Mi
description: The compute resource requirements.
description: ExtraResources defines quotas for containers other
than mysql or xenon. These containers take up less resources,
so quotas are set uniformly.
properties:
limits:
additionalProperties:
Expand All @@ -1177,6 +1164,21 @@ spec:
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
imagePullPolicy:
default: IfNotPresent
description: PullPolicy describes a policy for if/when to pull
a container image
enum:
- Always
- IfNotPresent
- Never
type: string
labels:
additionalProperties:
type: string
type: object
priorityClassName:
type: string
schedulerName:
type: string
sidecarImage:
Expand Down
6 changes: 3 additions & 3 deletions config/samples/mysql_v1alpha1_mysqlcluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ spec:
cpu: 100m
memory: 128Mi

podSpec:
podPolicy:
imagePullPolicy: IfNotPresent
sidecarImage: radondb/mysql-sidecar:latest
busyboxImage: busybox:1.32
Expand All @@ -74,8 +74,8 @@ spec:
priorityClassName: ""
tolerations: []
schedulerName: ""

resources:
# extraResources defines quotas for containers other than mysql or xenon.
extraResources:
requests:
cpu: 10m
memory: 32Mi
Expand Down
24 changes: 12 additions & 12 deletions docs/kubernetes/deploy_radondb-mysql_operator_on_k8s.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,18 @@ kubectl delete customresourcedefinitions.apiextensions.k8s.io mysqlclusters.mysq
| 参数 | 描述 | 默认值 |
|:------------------------- |:-------------------------------------------------- |:------------------------ |
| Replicas | 集群节点数,只允许为0、2、3、5 | 3 |
| PodSpec.ImagePullPolicy | 镜像拉取策略, 只允许为 Always/IfNotPresent/Never | IfNotPresent |
| PodSpec.Labels | 节点 pod [标签](#1-标签) | - |
| PodSpec.Annotations | 节点 pod [注解](#2-注解) | - |
| PodSpec.Affinity | 节点 pod [亲和性](#3-亲和性) | - |
| PodSpec.PriorityClassName | 节点 pod [优先级](#4-优先级)对象名称 | - |
| PodSpec.Tolerations | 节点 pod [污点容忍度](#5-容忍)列表 | - |
| PodSpec.SchedulerName | 节点 pod [调度器](#6-调度器)名称 | - |
| PodSpec.Resources | 节点 pod 配额 | 预留: cpu 10m, 内存 32Mi |
| PodSpec.SidecarImage | Sidecar 镜像 | radondb/mysql-sidecar:0.1 |
| PodSpec.BusyboxImage | Busybox 镜像 | busybox:1.32 |
| PodSpec.SlowLogTail | 是否开启慢日志跟踪 | false |
| PodSpec.AuditLogTail | 是否开启审计日志跟踪 | false |
| PodPolicy.ImagePullPolicy | 镜像拉取策略, 只允许为 Always/IfNotPresent/Never | IfNotPresent |
| PodPolicy.Labels | 节点 pod [标签](#1-标签) | - |
| PodPolicy.Annotations | 节点 pod [注解](#2-注解) | - |
| PodPolicy.Affinity | 节点 pod [亲和性](#3-亲和性) | - |
| PodPolicy.PriorityClassName | 节点 pod [优先级](#4-优先级)对象名称 | - |
| PodPolicy.Tolerations | 节点 pod [污点容忍度](#5-容忍)列表 | - |
| PodPolicy.SchedulerName | 节点 pod [调度器](#6-调度器)名称 | - |
| PodPolicy.Resources | 节点 pod 配额 | 预留: cpu 10m, 内存 32Mi |
| PodPolicy.SidecarImage | Sidecar 镜像 | radondb/mysql-sidecar:0.1 |
| PodPolicy.BusyboxImage | Busybox 镜像 | busybox:1.32 |
| PodPolicy.SlowLogTail | 是否开启慢日志跟踪 | false |
| PodPolicy.AuditLogTail | 是否开启审计日志跟踪 | false |

### 持久化配置

Expand Down
4 changes: 2 additions & 2 deletions mysqlcluster/container/auditlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (c *auditLog) getName() string {

// getImage get the container image.
func (c *auditLog) getImage() string {
return c.Spec.PodSpec.BusyboxImage
return c.Spec.PodPolicy.BusyboxImage
}

// getCommand get the container command.
Expand All @@ -58,7 +58,7 @@ func (c *auditLog) getLifecycle() *corev1.Lifecycle {

// getResources get the container resources.
func (c *auditLog) getResources() corev1.ResourceRequirements {
return c.Spec.PodSpec.Resources
return c.Spec.PodPolicy.ExtraResources
}

// getPorts get the container ports.
Expand Down
4 changes: 2 additions & 2 deletions mysqlcluster/container/auditlog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (
var (
auditlogMysqlCluster = mysqlv1alpha1.MysqlCluster{
Spec: mysqlv1alpha1.MysqlClusterSpec{
PodSpec: mysqlv1alpha1.PodSpec{
PodPolicy: mysqlv1alpha1.PodPolicy{
BusyboxImage: "busybox",
Resources: corev1.ResourceRequirements{
ExtraResources: corev1.ResourceRequirements{
Limits: nil,
Requests: nil,
},
Expand Down
4 changes: 2 additions & 2 deletions mysqlcluster/container/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (c *backupSidecar) getName() string {
}

func (c *backupSidecar) getImage() string {
return c.Spec.PodSpec.SidecarImage
return c.Spec.PodPolicy.SidecarImage
}

func (c *backupSidecar) getCommand() []string {
Expand Down Expand Up @@ -87,7 +87,7 @@ func (c *backupSidecar) getLifecycle() *corev1.Lifecycle {
}

func (c *backupSidecar) getResources() corev1.ResourceRequirements {
return c.Spec.PodSpec.Resources
return c.Spec.PodPolicy.ExtraResources
}

func (c *backupSidecar) getPorts() []corev1.ContainerPort {
Expand Down
2 changes: 1 addition & 1 deletion mysqlcluster/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func EnsureContainer(name string, c *mysqlcluster.MysqlCluster) corev1.Container
return corev1.Container{
Name: ctr.getName(),
Image: ctr.getImage(),
ImagePullPolicy: c.Spec.PodSpec.ImagePullPolicy,
ImagePullPolicy: c.Spec.PodPolicy.ImagePullPolicy,
Command: ctr.getCommand(),
Env: ctr.getEnvVars(),
Lifecycle: ctr.getLifecycle(),
Expand Down
4 changes: 2 additions & 2 deletions mysqlcluster/container/init_mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ var (
Name: "sample",
},
Spec: mysqlv1alpha1.MysqlClusterSpec{
PodSpec: mysqlv1alpha1.PodSpec{
Resources: corev1.ResourceRequirements{
PodPolicy: mysqlv1alpha1.PodPolicy{
ExtraResources: corev1.ResourceRequirements{
Limits: nil,
Requests: nil,
},
Expand Down
4 changes: 2 additions & 2 deletions mysqlcluster/container/init_sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (c *initSidecar) getName() string {

// getImage get the container image.
func (c *initSidecar) getImage() string {
return c.Spec.PodSpec.SidecarImage
return c.Spec.PodPolicy.SidecarImage
}

// getCommand get the container command.
Expand Down Expand Up @@ -143,7 +143,7 @@ func (c *initSidecar) getLifecycle() *corev1.Lifecycle {

// getResources get the container resources.
func (c *initSidecar) getResources() corev1.ResourceRequirements {
return c.Spec.PodSpec.Resources
return c.Spec.PodPolicy.ExtraResources
}

// getPorts get the container ports.
Expand Down
4 changes: 2 additions & 2 deletions mysqlcluster/container/init_sidecar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ var (
},
Spec: mysqlv1alpha1.MysqlClusterSpec{
Replicas: &replicas,
PodSpec: mysqlv1alpha1.PodSpec{
PodPolicy: mysqlv1alpha1.PodPolicy{
SidecarImage: "sidecar image",
Resources: corev1.ResourceRequirements{
ExtraResources: corev1.ResourceRequirements{
Limits: nil,
Requests: nil,
},
Expand Down
4 changes: 2 additions & 2 deletions mysqlcluster/container/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ var (
Name: "sample",
},
Spec: mysqlv1alpha1.MysqlClusterSpec{
PodSpec: mysqlv1alpha1.PodSpec{
Resources: corev1.ResourceRequirements{
PodPolicy: mysqlv1alpha1.PodPolicy{
ExtraResources: corev1.ResourceRequirements{
Limits: nil,
Requests: nil,
},
Expand Down
4 changes: 2 additions & 2 deletions mysqlcluster/container/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (
var (
mysqlMysqlCluster = mysqlv1alpha1.MysqlCluster{
Spec: mysqlv1alpha1.MysqlClusterSpec{
PodSpec: mysqlv1alpha1.PodSpec{
Resources: corev1.ResourceRequirements{
PodPolicy: mysqlv1alpha1.PodPolicy{
ExtraResources: corev1.ResourceRequirements{
Limits: nil,
Requests: nil,
},
Expand Down
Loading