Skip to content

Commit

Permalink
*: helm support for v3.0.0 apis
Browse files Browse the repository at this point in the history
  • Loading branch information
zhl003 committed Mar 9, 2023
1 parent 989e9c4 commit fb057fc
Show file tree
Hide file tree
Showing 20 changed files with 347 additions and 42 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ COPY utils/ utils/
COPY mysqluser/ mysqluser/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -oPg manager cmd/manager/main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager cmd/manager/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
45 changes: 27 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# Image URL to use all building/pushing image targets
FROM_VERSION ?=v2.2.1
CHART_VERSION ?=2.2.1
CHART_TOVERSION ?=2.3.0
TO_VERSION ?=v2.3.0
FROM_VERSION ?=v2.3.0
CHART_VERSION ?=2.3.0
CHART_TOVERSION ?=3.0.0
TO_VERSION ?=v3.0.0
TAG ?=v3.0.0
IMGPREFIX ?=radondb/
MYSQL_IMAGE_57 ?=5.7.39
MYSQL_IMAGE_57 ?=5.7.34
MYSQL_IMAGE_80 ?=8.0.25
MYSQL_IMAGE_57_TAG ?=$(IMGPREFIX)percona-server:$(MYSQL_IMAGE_57)
MYSQL_IMAGE_80_TAG ?=$(IMGPREFIX)percona-server:$(MYSQL_IMAGE_80)
IMG ?= $(IMGPREFIX)mysql-operator:latest
SIDECAR57_IMG ?= $(IMGPREFIX)mysql57-sidecar:latest
SIDECAR80_IMG ?= $(IMGPREFIX)mysql80-sidecar:latest
XENON_IMG ?= $(IMGPREFIX)xenon:latest
IMG ?= $(IMGPREFIX)mysql-operator:$(TAG)
SIDECAR57_IMG ?= $(IMGPREFIX)mysql57-sidecar:$(TAG)
SIDECAR80_IMG ?= $(IMGPREFIX)mysql80-sidecar:$(TAG)
XENON_IMG ?= $(IMGPREFIX)xenon:$(TAG)
GO_PORXY ?= off
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
Expand Down Expand Up @@ -90,11 +91,12 @@ build: generate fmt vet ## Build manager binary.
run: manifests generate fmt vet ## Run a controller from your host.
go run ./cmd/manager/main.go

docker-build: test ## Build docker image with the manager.
docker-build: ## Build docker image with the manager.
docker buildx build --build-arg GO_PROXY=${GO_PORXY} -t ${IMG} .
docker buildx build -f Dockerfile.sidecar --build-arg GO_PROXY=${GO_PORXY} -t ${SIDECAR57_IMG} .
docker buildx build -f build/xenon/Dockerfile --build-arg GO_PROXY=${GO_PORXY} -t ${XENON_IMG} .
docker buildx build --build-arg XTRABACKUP_PKG=percona-xtrabackup-80 --build-arg GO_PROXY=${GO_PORXY} -f Dockerfile.sidecar -t ${SIDECAR80_IMG} .
docker buildx build --build-arg XTRABACKUP_PKG=percona-xtrabackup-57 --build-arg GO_PROXY=${GO_PORXY} -f Dockerfile.sidecar -t ${SIDECAR80_IMG} .
docker buildx build --build-arg "MYSQL_IMAGE=${MYSQL_IMAGE_57}" --build-arg GO_PROXY=${GO_PORXY} -f build/mysql/Dockerfile -t ${MYSQL_IMAGE_57_TAG} .
docker buildx build --build-arg "MYSQL_IMAGE=${MYSQL_IMAGE_80}" --build-arg GO_PROXY=${GO_PORXY} -f build/mysql/Dockerfile -t ${MYSQL_IMAGE_80_TAG} .
docker-build-mysql57: test ## Build docker image with the manager.
Expand Down Expand Up @@ -152,13 +154,20 @@ todo:
@grep -Irnw './' -e 'TODO:'|grep -v grep

updateVersion:
find ./ -type f -name "*.go" -o -name "*.yaml" -exec sed -i "s/mysql57-sidecar:$(FROM_VERSION)/mysql57-sidecar:$(TO_VERSION)/g" {} \;
find ./ -type f -name "*.go" -o -name "*.yaml" -exec sed -i "s/xenon:$(FROM_VERSION)/xenon:$(TO_VERSION)/g" {} \;
find ./ -type f -name "*.go" -o -name "*.yaml" -exec sed -i "s/mysql-operator:$(FROM_VERSION)/mysql-operator:$(TO_VERSION)/g" {} \;
find ./ -type f -name "*.go" -o -name "*.yaml" -exec sed -i "s/mysql80-sidecar:$(FROM_VERSION)/mysql80-sidecar:$(TO_VERSION)/g" {} \;
find ./ -type f -name "*.go" -o -name "*.yaml" -exec sed -i "s/mysql-operator-$(FROM_VERSION)/mysql-operator-$(TO_VERSION)/g" {} \;
find ./ -type f -name "*.go" -o -name "*.yaml" -exec sed -i "s/\"$(FROM_VERSION)\"/\"$(TO_VERSION)\"/g" {} \;
find ./* -type f -name "*.go" -o -name "*.yaml" -exec sed -i "" "s/mysql57-sidecar:$(FROM_VERSION)/mysql57-sidecar:$(TO_VERSION)/g" {} \;
find ./* -type f -name "*.go" -o -name "*.yaml" -exec sed -i "" "s/xenon:$(FROM_VERSION)/xenon:$(TO_VERSION)/g" {} \;
find ./* -type f -name "*.go" -o -name "*.yaml" -exec sed -i "" "s/mysql-operator:$(FROM_VERSION)/mysql-operator:$(TO_VERSION)/g" {} \;
find ./* -type f -name "*.go" -o -name "*.yaml" -exec sed -i "" "s/mysql80-sidecar:$(FROM_VERSION)/mysql80-sidecar:$(TO_VERSION)/g" {} \;
find ./* -type f -name "*.go" -o -name "*.yaml" -exec sed -i "" "s/mysql-operator-$(FROM_VERSION)/mysql-operator-$(TO_VERSION)/g" {} \;
find ./* -type f -name "*.go" -o -name "*.yaml" -exec sed -i "" "s/\"$(FROM_VERSION)\"/\"$(TO_VERSION)\"/g" {} \;
# sed -i "18s/$(CHART_VERSION)/$(CHART_TOVERSION)/" charts/mysql-operator/charts/Chart.yaml
find ./charts -type f -name "*.yaml" -exec sed -i "s/$(CHART_VERSION)/$(CHART_TOVERSION)/g" {} \;
find ./config -type f -name "*.yaml" -exec sed -i "s/$(CHART_VERSION)/$(CHART_TOVERSION)/g" {} \;
find ./charts/* -type f -name "*.yaml" -exec sed -i "" "s/$(CHART_VERSION)/$(CHART_TOVERSION)/g" {} \;
find ./config/* -type f -name "*.yaml" -exec sed -i "" "s/$(CHART_VERSION)/$(CHART_TOVERSION)/g" {} \;

CRD_TO_MARKDOWN := $(shell pwd)/bin/crd-to-markdown
CRD_TO_MARKDOWN_VERSION = 0.0.3
crd-to-markdown: ## Download crd-to-markdown locally if necessary.
$(call go-get-tool,$(CRD_TO_MARKDOWN),github.com/clamoriniere/crd-to-markdown@v$(CRD_TO_MARKDOWN_VERSION))
apidoc: crd-to-markdown $(wildcard api/*/*_types.go)
$(CRD_TO_MARKDOWN) --links docs/links.csv -f api/v1beta1/mysqlcluster_types.go -n MySQLCluster > docs/crd_mysqlcluster_v1beta1.md

6 changes: 5 additions & 1 deletion api/v1beta1/mysqlcluster_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func Convert_v1alpha1_MysqlClusterSpec_To_v1beta1_MysqlClusterSpec(in *v1alpha1.
out.User = in.MysqlOpts.User
out.Xenon = XenonOpts(in.XenonOpts)
out.Monitoring.Exporter.Image = in.MetricsOpts.Image
out.Monitoring.Exporter.Enabled = in.MetricsOpts.Enabled
out.Monitoring.Exporter.Resources = in.MetricsOpts.Resources
out.Affinity = (*corev1.Affinity)(unsafe.Pointer(in.PodPolicy.Affinity))
out.ImagePullPolicy = in.PodPolicy.ImagePullPolicy
Expand Down Expand Up @@ -85,11 +86,14 @@ func Convert_v1beta1_MysqlClusterSpec_To_v1alpha1_MysqlClusterSpec(in *MysqlClus
out.MetricsOpts.Image = in.Monitoring.Exporter.Image
out.MetricsOpts.Resources = in.Monitoring.Exporter.Resources
out.MysqlOpts.Image = in.Image
out.PodPolicy.SlowLogTail = in.Log.SlowLogTail
out.PodPolicy.BusyboxImage = in.Log.BusyboxImage
out.MetricsOpts.Enabled = in.Monitoring.Exporter.Enabled
out.PodPolicy.ImagePullPolicy = in.ImagePullPolicy
out.PodPolicy.Tolerations = in.Tolerations
out.PodPolicy.Affinity = (*corev1.Affinity)(unsafe.Pointer(in.Affinity))
out.PodPolicy.PriorityClassName = in.PriorityClassName
// //TODO in.DataSource in.Standby
//TODO in.DataSource in.Standby
out.XenonOpts.EnableAutoRebuild = in.EnableAutoRebuild
//TODO in.Log n.Service
return nil
Expand Down
6 changes: 5 additions & 1 deletion api/v1beta1/mysqlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ type ExporterSpec struct {
// More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers
// +optional
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
// enabled is used to enable/disable the exporter.
// +optional
// +kubebuilder:default:=true
Enabled bool `json:"enabled,omitempty"`
}

type DataSource struct {
Expand All @@ -391,7 +395,7 @@ type LogOpts struct {
// The busybox image.
// +optional
// +kubebuilder:default:="busybox:1.32"
BusyboxImage string `json:"busyboxImage,omitempty"`
BusyboxImage string `json:"image,omitempty"`

// SlowLogTail represents if tail the mysql slow log.
// +optional
Expand Down
6 changes: 3 additions & 3 deletions charts/mysql-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: v2.3.0
version: v3.0.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v2.3.0"
appVersion: "v3.0.0"
dependencies:
- name: "mysqlcluster"
version: "v2.3.0"
version: "v3.0.0"

4 changes: 2 additions & 2 deletions charts/mysql-operator/charts/mysql-cluster/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 2.3.0
version: 3.0.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v2.3.0"
appVersion: "v3.0.0"
2 changes: 1 addition & 1 deletion charts/mysql-operator/charts/mysql-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: "sample"
namespace: "default"

mysqlVersion: "8.0"
version: v2.3.0
version: v3.0.0

tls:
enable: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2533,7 +2533,7 @@ spec:
default: false
description: AuditLogTail represents if tail the mysql audit log.
type: boolean
busyboxImage:
image:
default: busybox:1.32
description: To specify the image that will be used for log container.
The busybox image.
Expand Down Expand Up @@ -2638,6 +2638,10 @@ spec:
be defined
type: boolean
type: object
enabled:
default: true
description: enabled is used to enable/disable the exporter.
type: boolean
image:
default: prom/mysqld-exporter:v0.12.1
description: To specify the image that will be used for metrics
Expand Down
4 changes: 2 additions & 2 deletions charts/mysql-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ installCRDS: true

mysqlcluster:
install: false
version: v2.3.0
version: v3.0.0
## Specify an imagePullPolicy (Required)
## It's recommended to change this to 'Always' if the image tag is 'latest'
## ref: http://kubernetes.io/docs/user-guide/images/#updating-images
Expand All @@ -25,7 +25,7 @@ tolerationSeconds: 30

manager:
image: radondb/mysql-operator
tag: v2.3.0
tag: v3.0.0
enableWebhooks: true
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
Expand Down
6 changes: 5 additions & 1 deletion config/crd/bases/mysql.radondb.com_mysqlclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2533,7 +2533,7 @@ spec:
default: false
description: AuditLogTail represents if tail the mysql audit log.
type: boolean
busyboxImage:
image:
default: busybox:1.32
description: To specify the image that will be used for log container.
The busybox image.
Expand Down Expand Up @@ -2638,6 +2638,10 @@ spec:
be defined
type: boolean
type: object
enabled:
default: true
description: enabled is used to enable/disable the exporter.
type: boolean
image:
default: prom/mysqld-exporter:v0.12.1
description: To specify the image that will be used for metrics
Expand Down
2 changes: 1 addition & 1 deletion config/crd/patches/webhook_in_mysqlclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
clientConfig:
service:
namespace: system
name: webhook-service
name: radondb-mysql-webhook
path: /convert
conversionReviewVersions:
- v1
2 changes: 1 addition & 1 deletion config/samples/mysql_v1alpha1_backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: backup-sample
spec:
# Add fields here
image: radondb/mysql57-sidecar:v2.3.0
image: radondb/mysql57-sidecar:v3.0.0
# hostname if empty, use the leader as hostname
hostName: sample-mysql-0
clusterName: sample
Expand Down
4 changes: 2 additions & 2 deletions config/samples/mysql_v1alpha1_mysqlcluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ spec:
cpu: 500m
memory: 1Gi
xenonOpts:
image: radondb/xenon:v2.3.0
image: radondb/xenon:v3.0.0
admitDefeatHearbeatCount: 5
electionTimeout: 10000
resources:
Expand All @@ -57,7 +57,7 @@ spec:
memory: 128Mi
podPolicy:
imagePullPolicy: IfNotPresent
sidecarImage: radondb/mysql57-sidecar:v2.3.0
sidecarImage: radondb/mysql57-sidecar:v3.0.0
busyboxImage: busybox:1.32
slowLogTail: false
auditLogTail: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ spec:
memory: 1Gi

xenonOpts:
image: radondb/xenon:v2.3.0
image: radondb/xenon:v3.0.0
admitDefeatHearbeatCount: 5
electionTimeout: 10000

Expand All @@ -60,7 +60,7 @@ spec:

podPolicy:
imagePullPolicy: IfNotPresent
sidecarImage: radondb/mysql57-sidecar:v2.3.0
sidecarImage: radondb/mysql57-sidecar:v3.0.0
busyboxImage: busybox:1.32

slowLogTail: false
Expand Down
4 changes: 2 additions & 2 deletions config/samples/mysql_v1alpha1_mysqlcluster_mysql8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ spec:
memory: 1Gi

xenonOpts:
image: radondb/xenon:v2.3.0
image: radondb/xenon:v3.0.0
admitDefeatHearbeatCount: 5
electionTimeout: 10000

Expand All @@ -61,7 +61,7 @@ spec:

podPolicy:
imagePullPolicy: IfNotPresent
sidecarImage: radondb/mysql80-sidecar:v2.3.0
sidecarImage: radondb/mysql80-sidecar:v3.0.0
busyboxImage: busybox:1.32

slowLogTail: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ spec:
memory: 1Gi

xenonOpts:
image: radondb/xenon:v2.3.0
image: radondb/xenon:v3.0.0
admitDefeatHearbeatCount: 5
electionTimeout: 10000

Expand All @@ -60,7 +60,7 @@ spec:

podPolicy:
imagePullPolicy: IfNotPresent
sidecarImage: radondb/mysql57-sidecar:v2.3.0
sidecarImage: radondb/mysql57-sidecar:v3.0.0
busyboxImage: busybox:1.32

slowLogTail: false
Expand Down
2 changes: 1 addition & 1 deletion config/samples/mysql_v1beta1_backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: backup-sample
spec:
# Add fields here
image: radondb/mysql57-sidecar:v2.3.0
image: radondb/mysql57-sidecar:v3.0.0
# hostfrom if empty, use the leader as hostfrom
hostfrom: sample-mysql-0
clusterName: sample
Expand Down
Loading

0 comments on commit fb057fc

Please sign in to comment.