Skip to content

Commit

Permalink
Merge pull request #262 from cybozu-go/migrate-mysql-repo
Browse files Browse the repository at this point in the history
Migrate MySQL image repository to quay.io/cybozu/mysql
  • Loading branch information
ymmt2005 authored Jun 10, 2021
2 parents a965da7 + 2869470 commit 84af826
Show file tree
Hide file tree
Showing 22 changed files with 4,771 additions and 1,695 deletions.
2 changes: 1 addition & 1 deletion DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Edit the following lines in `Dockerfile`:

```
# The tag should be the latest one
FROM quay.io/cybozu/moco-mysql:8.0.25.1 as mysql
FROM quay.io/cybozu/mysql:8.0.25.1 as mysql
# See the below description for how to get the version string.
ARG MYSQLSH_VERSION=8.0.25-1
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ USER 10000:10000
ENTRYPOINT ["/moco-controller"]

# For MySQL binaries
FROM quay.io/cybozu/moco-mysql:8.0.25.1 as mysql
FROM quay.io/cybozu/mysql:8.0.25.1 as mysql

# the backup image
FROM quay.io/cybozu/ubuntu:20.04
Expand Down
33 changes: 13 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Tool versions
CTRL_TOOLS_VERSION=0.5.0
CTRL_TOOLS_VERSION=0.6.0
CTRL_RUNTIME_VERSION := $(shell awk '/sigs.k8s.io\/controller-runtime/ {print substr($$2, 2)}' go.mod)
KUSTOMIZE_VERSION = 4.1.3
CRD_TO_MARKDOWN_VERSION = 0.0.3
Expand All @@ -18,7 +18,7 @@ SHELL = /bin/bash
.SHELLFLAGS = -e -o pipefail -c

# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS = "crd:crdVersions=v1"
CRD_OPTIONS = "crd:crdVersions=v1,maxDescLen=220"

# for Go
GOOS = $(shell go env GOOS)
Expand Down Expand Up @@ -50,8 +50,6 @@ help: ## Display this help.
.PHONY: manifests
manifests: controller-gen## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
@echo "Shrinking CRD size..."
sed -i -E 's/^( +description: ).*$$/\1"omitted"/' config/crd/bases/moco.cybozu.com_mysqlclusters.yaml

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
Expand All @@ -72,29 +70,18 @@ check-generate:
$(MAKE) manifests generate apidoc
git diff --exit-code --name-only

ENVTEST_ASSETS_DIR := $(shell pwd)/testbin
.PHONY: envtest
envtest:
mkdir -p ${ENVTEST_ASSETS_DIR}
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v$(CTRL_RUNTIME_VERSION)/hack/setup-envtest.sh
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; \
fetch_envtest_tools $(ENVTEST_ASSETS_DIR); \
setup_envtest_env $(ENVTEST_ASSETS_DIR); \
envtest: setup-envtest
source <($(SETUP_ENVTEST) use -p env); \
export MOCO_CHECK_INTERVAL=100ms; \
export MOCO_WAIT_INTERVAL=100ms; \
go test -v -count 1 -race ./clustering -ginkgo.progress -ginkgo.v -ginkgo.failFast
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; \
fetch_envtest_tools $(ENVTEST_ASSETS_DIR); \
setup_envtest_env $(ENVTEST_ASSETS_DIR); \
source <($(SETUP_ENVTEST) use -p env); \
export DEBUG_CONTROLLER=1; \
go test -v -count 1 -race ./controllers -ginkgo.progress -ginkgo.v -ginkgo.failFast
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; \
fetch_envtest_tools $(ENVTEST_ASSETS_DIR); \
setup_envtest_env $(ENVTEST_ASSETS_DIR); \
source <($(SETUP_ENVTEST) use -p env); \
go test -v -count 1 -race ./api/... -ginkgo.progress -ginkgo.v
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; \
fetch_envtest_tools $(ENVTEST_ASSETS_DIR); \
setup_envtest_env $(ENVTEST_ASSETS_DIR); \
source <($(SETUP_ENVTEST) use -p env); \
go test -v -count 1 -race ./backup -ginkgo.progress -ginkgo.v -ginkgo.failFast

.PHONY: test-dbop
Expand Down Expand Up @@ -146,6 +133,12 @@ CONTROLLER_GEN := $(shell pwd)/bin/controller-gen
controller-gen: ## Download controller-gen locally if necessary.
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v$(CTRL_TOOLS_VERSION))

SETUP_ENVTEST := $(shell pwd)/bin/setup-envtest
.PHONY: setup-envtest
setup-envtest: ## Download setup-envtest locally if necessary
# see https://github.com/kubernetes-sigs/controller-runtime/tree/master/tools/setup-envtest
GOBIN=$(shell pwd)/bin go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

KUSTOMIZE := $(shell pwd)/bin/kustomize
.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ spec:
spec:
containers:
- name: mysqld
image: quay.io/cybozu/moco-mysql:8.0.25
image: quay.io/cybozu/mysql:8.0.25
volumeClaimTemplates:
- metadata:
name: mysql-data
Expand Down
919 changes: 672 additions & 247 deletions config/crd/bases/moco.cybozu.com_backuppolicies.yaml

Large diffs are not rendered by default.

5,173 changes: 3,875 additions & 1,298 deletions config/crd/bases/moco.cybozu.com_mysqlclusters.yaml

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/custom-mysqld.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Building custom image of `mysqld`

There are pre-built `mysqld` container images for MOCO on [`quay.io/cybozu/moco-mysql`](https://quay.io/repository/cybozu/moco-mysql?tag=latest&tab=tags).
There are pre-built `mysqld` container images for MOCO on [`quay.io/cybozu/mysql`](https://quay.io/repository/cybozu/mysql?tag=latest&tab=tags).
Users can use one of these images to supply `mysqld` container in [MySQLCluster](crd_mysqlcluster.md) like:

```yaml
Expand All @@ -11,19 +11,19 @@ spec:
spec:
containers:
- name: mysqld
image: quay.io/cybozu/moco-mysql:8.0.25
image: quay.io/cybozu/mysql:8.0.25
```
If you want to build and use your own `mysqld`, read the rest of this document.

## Dockerfile

The easiest way to build a custom `mysqld` for MOCO is to copy and edit our Dockerfile.
You can find it under [`moco-mysql` directory in `github.com/cybozu/neco-containers`](https://github.com/cybozu/neco-containers/tree/main/moco-mysql).
You can find it under [`mysql` directory in `github.com/cybozu/neco-containers`](https://github.com/cybozu/neco-containers/tree/main/mysql).

You should keep the following points:

- Build and install [`moco-init`](https://github.com/cybozu/neco-containers/tree/main/moco-mysql/moco-init)
- Build and install [`moco-init`](https://github.com/cybozu/neco-containers/tree/main/mysql/moco-init)
- Add directories for `mysqld` and `moco-init` to `PATH`
- `ENTRYPOINT` should be `["mysqld"]`
- `USER` should be `10000:10000`
Expand All @@ -36,7 +36,7 @@ On Ubuntu 20.04, you can build the source code as follows:
```console
$ sudo apt-get update
$ sudo apt-get -y --no-install-recommends install build-essential libssl-dev \
cmake libncurses5-dev libjemalloc-dev libnuma-dev pkg-config
cmake libncurses5-dev libjemalloc-dev libnuma-dev libaio-dev pkg-config
$ curl -fsSL -O https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-8.0.20.tar.gz
$ tar -x -z -f mysql-boost-8.0.20.tar.gz
$ cd mysql-8.0.20
Expand Down
8 changes: 4 additions & 4 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ spec:
containers:
# At least a container named "mysqld" must be defined.
- name: mysqld
image: quay.io/cybozu/moco-mysql:8.0.25
image: quay.io/cybozu/mysql:8.0.25
# By limiting CPU and memory, Pods will have Guaranteed QoS class.
# requests can be omitted; it will be set to the same value as limits.
resources:
Expand Down Expand Up @@ -165,7 +165,7 @@ spec:
spec:
containers:
- name: mysqld
image: quay.io/cybozu/moco-mysql:8.0.25 # must be the same version as the donor
image: quay.io/cybozu/mysql:8.0.25 # must be the same version as the donor
volumeClaimTemplates:
- metadata:
name: mysql-data
Expand All @@ -180,7 +180,7 @@ To stop the replication from the donor, update MySQLCluster with `spec.replicati

### Bring your own image

We provide a pre-built MySQL container image at [quay.io/cybozu/moco-mysql](http://quay.io/cybozu/moco-mysql).
We provide pre-built MySQL container images at [quay.io/cybozu/mysql](http://quay.io/cybozu/mysql).
If you want to build and use your own image, read [`custom-mysqld.md`](custom-mysqld.md).

## Configurations
Expand Down Expand Up @@ -620,7 +620,7 @@ spec:
containers:
- name: mysqld
# Edit the next line
image: quay.io/cybozu/moco-mysql:8.0.25
image: quay.io/cybozu/mysql:8.0.25
```

You are advised to make backups and/or create a replica cluster before starting the upgrade process.
Expand Down
2 changes: 1 addition & 1 deletion e2e/testdata/backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ spec:
spec:
containers:
- name: mysqld
image: quay.io/cybozu/moco-mysql:{{ . }}
image: quay.io/cybozu/mysql:{{ . }}
volumeClaimTemplates:
- metadata:
name: mysql-data
Expand Down
2 changes: 1 addition & 1 deletion e2e/testdata/client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ metadata:
spec:
containers:
- name: pause
image: quay.io/cybozu/moco-mysql:{{ . }}
image: quay.io/cybozu/mysql:{{ . }}
command: ["pause"]
2 changes: 1 addition & 1 deletion e2e/testdata/donor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
spec:
containers:
- name: mysqld
image: quay.io/cybozu/moco-mysql:{{ . }}
image: quay.io/cybozu/mysql:{{ . }}
volumeClaimTemplates:
- metadata:
name: mysql-data
Expand Down
2 changes: 1 addition & 1 deletion e2e/testdata/replication.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
spec:
containers:
- name: mysqld
image: quay.io/cybozu/moco-mysql:{{ . }}
image: quay.io/cybozu/mysql:{{ . }}
volumeClaimTemplates:
- metadata:
name: mysql-data
Expand Down
2 changes: 1 addition & 1 deletion e2e/testdata/restore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ spec:
spec:
containers:
- name: mysqld
image: quay.io/cybozu/moco-mysql:{{ .MySQLVersion }}
image: quay.io/cybozu/mysql:{{ .MySQLVersion }}
volumeClaimTemplates:
- metadata:
name: mysql-data
Expand Down
2 changes: 1 addition & 1 deletion e2e/testdata/single.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
spec:
containers:
- name: mysqld
image: quay.io/cybozu/moco-mysql:{{ . }}
image: quay.io/cybozu/mysql:{{ . }}
volumeClaimTemplates:
- metadata:
name: mysql-data
Expand Down
2 changes: 1 addition & 1 deletion e2e/testdata/upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
spec:
containers:
- name: mysqld
image: quay.io/cybozu/moco-mysql:{{ . }}
image: quay.io/cybozu/mysql:{{ . }}
volumeClaimTemplates:
- metadata:
name: mysql-data
Expand Down
2 changes: 1 addition & 1 deletion examples/anti-affinity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec:
topologyKey: "kubernetes.io/hostname"
containers:
- name: mysqld
image: quay.io/cybozu/moco-mysql:8.0.25
image: quay.io/cybozu/mysql:8.0.25
resources:
requests:
cpu: "10"
Expand Down
2 changes: 1 addition & 1 deletion examples/collect-metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
spec:
containers:
- name: mysqld
image: quay.io/cybozu/moco-mysql:8.0.25
image: quay.io/cybozu/mysql:8.0.25
volumeClaimTemplates:
- metadata:
name: mysql-data
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-mycnf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
spec:
containers:
- name: mysqld
image: quay.io/cybozu/moco-mysql:8.0.25
image: quay.io/cybozu/mysql:8.0.25
volumeClaimTemplates:
- metadata:
name: mysql-data
Expand Down
2 changes: 1 addition & 1 deletion examples/guaranteed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
spec:
containers:
- name: mysqld
image: quay.io/cybozu/moco-mysql:8.0.25
image: quay.io/cybozu/mysql:8.0.25
# By limiting CPU and memory, Pods will have Guaranteed QoS class.
# requests can be omitted; it will be set to the same value as limits.
resources:
Expand Down
2 changes: 1 addition & 1 deletion examples/loadbalancer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
spec:
containers:
- name: mysqld
image: quay.io/cybozu/moco-mysql:8.0.25
image: quay.io/cybozu/mysql:8.0.25
volumeClaimTemplates:
- metadata:
name: mysql-data
Expand Down
22 changes: 11 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ require (
github.com/go-sql-driver/mysql v1.6.0
github.com/google/go-cmp v0.5.6
github.com/jmoiron/sqlx v1.3.4
github.com/onsi/ginkgo v1.16.2
github.com/onsi/gomega v1.12.0
github.com/prometheus/client_golang v1.10.0
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.13.0
github.com/prometheus/client_golang v1.11.0
github.com/prometheus/client_model v0.2.0
github.com/prometheus/common v0.25.0
github.com/prometheus/common v0.26.0
github.com/robfig/cron/v3 v3.0.1
github.com/spf13/cobra v1.1.3
github.com/spf13/pflag v1.0.5
go.uber.org/zap v1.17.0
google.golang.org/grpc v1.38.0
k8s.io/api v0.20.7
k8s.io/apimachinery v0.20.7
k8s.io/cli-runtime v0.20.7
k8s.io/client-go v0.20.7
k8s.io/api v0.21.1
k8s.io/apimachinery v0.21.1
k8s.io/cli-runtime v0.21.1
k8s.io/client-go v0.21.1
k8s.io/klog v1.0.0
k8s.io/kubectl v0.20.7
k8s.io/utils v0.0.0-20210521133846-da695404a2bc
sigs.k8s.io/controller-runtime v0.8.3
k8s.io/kubectl v0.21.1
k8s.io/utils v0.0.0-20210527160623-6fdb442a123b
sigs.k8s.io/controller-runtime v0.9.0
)
Loading

0 comments on commit 84af826

Please sign in to comment.