Skip to content

Commit

Permalink
Merge pull request #24 from kloeckner-i/METAL-1890_proxySQL
Browse files Browse the repository at this point in the history
proxysql support for percona cluster
  • Loading branch information
hyunysmile committed Jun 5, 2020
2 parents 013ff84 + 0acd3fd commit 8031dec
Show file tree
Hide file tree
Showing 81 changed files with 2,460 additions and 240 deletions.
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ cache:
- $GOPATH/pkg/mod

jobs:
# allow_failures:
# - env:
# - ALLOW_FAIL=true
allow_failures:
- env:
- ALLOW_FAIL=true
include:
- stage: test
name: "Unit Tests"
Expand All @@ -37,6 +37,8 @@ jobs:
- find . -type f -name "*\.go" | grep -v "zz_generated" | while read line; do
golint -set_exit_status $line || exit 1;
done
env:
- ALLOW_FAIL=true
- stage: test
name: "Go Vet"
script:
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ test:
@docker stop postgres
@docker stop mysql

lint:
@golint ./...

vet:
@go vet ./...

Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ require (
github.com/sirupsen/logrus v1.4.2
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.4.0
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
golang.org/x/tools v0.0.0-20200526224456-8b020aee10d2 // indirect
google.golang.org/api v0.9.0
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55
gopkg.in/yaml.v2 v2.2.4
Expand Down
16 changes: 16 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xlab/handysort v0.0.0-20150421192137-fb3537ed64a1/go.mod h1:QcJo0QPSfTONNIgpN5RA8prR7fF8nkF6cTWTcNerRO8=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
gitlab.com/nyarla/go-crypt v0.0.0-20160106005555-d9a5dc2b789b/go.mod h1:T3BPAOm2cqquPa0MKWeNkmOM5RQsRhkrwMWonFMN7fE=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
Expand Down Expand Up @@ -633,6 +634,8 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 h1:ydJNl0ENAG67pFbB+9tfhiL2pYqLhfoaZFw/cjLhY4A=
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190312203227-4b39c73a6495/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand All @@ -644,8 +647,12 @@ golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTk
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190409202823-959b441ac422 h1:QzoH/1pFpZguR8NrRHLcO6jKqfv2zpuSqZLgdm7ZmjI=
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180112015858-5ccada7d0a7b/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -676,6 +683,8 @@ golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc h1:gkKoSkUmnU6bpS/VhkuO27bzQ
golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 h1:fHDIZ2oxGnUZRN6WgWFCbYBjH9uqVPRCUVUDhs0wnbA=
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -753,8 +762,15 @@ golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgw
golang.org/x/tools v0.0.0-20190706070813-72ffa07ba3db/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
golang.org/x/tools v0.0.0-20191018212557-ed542cd5b28a h1:UuQ+70Pi/ZdWHuP4v457pkXeOynTdgd/4enxeIO/98k=
golang.org/x/tools v0.0.0-20191018212557-ed542cd5b28a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200526224456-8b020aee10d2 h1:21BqcH/onxtGHn1A2GDOJjZnbt4Nlez629S3eaR+eYs=
golang.org/x/tools v0.0.0-20200526224456-8b020aee10d2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gomodules.xyz/jsonpatch/v2 v2.0.1 h1:xyiBuvkD2g5n7cYzx6u2sxQvsAy4QJsZFCzGVdzOXZ0=
gomodules.xyz/jsonpatch/v2 v2.0.1/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU=
gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0=
Expand Down
Binary file added helm/db-instances-0.4.0.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion helm/db-instances/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: v1
appVersion: "1.0"
description: Database Instances for db operator
name: db-instances
version: 0.3.1
version: 0.4.0
30 changes: 30 additions & 0 deletions helm/db-instances/templates/dbinstance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ spec:
backupHost: {{ $value.generic.backupHost }}
{{- end }}
{{- end }}
{{- if $value.percona }}
percona:
servers:
{{- range $server := $value.percona.servers }}
- host: {{ $server.host }}
port: {{ $server.port }}
maxConn: {{ $server.maxConn }}
{{- if $server.readonly }}
readonly: {{ $server.readonly }}
{{- end }}
{{- end }}
monitorUserSecretRef:
Name: {{ $name }}-monitoruser-secret
Namespace: {{ $operatorNs }}
{{- end }}
{{- if not $value.existingAdminSecret }}
---
apiVersion: v1
Expand Down Expand Up @@ -83,5 +98,20 @@ data:
config: |
{{ $value.google.configMap.data | indent 4 }}
{{- end }}
{{- if $value.percona }}
apiVersion: v1
kind: Secret
metadata:
name: {{ $name }}-monitoruser-secret
namespace: {{ $operatorNs }}
labels:
chart: {{ $chart }}
release: {{ $release.Name }}
heritage: {{ $heritage }}
type: Opaque
data:
user: {{ $value.percona.monitoruser.name | b64enc }}
password: {{ $value.percona.monitoruser.password | b64enc }}
{{- end }}
{{- end }}
{{- end }}
Binary file added helm/db-operator-0.3.0.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion helm/db-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: v1
appVersion: "1.0"
description: A Database Operator
name: db-operator
version: 0.2.0
version: 0.3.0
3 changes: 3 additions & 0 deletions helm/db-operator/templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ data:
{{ toYaml .Values.config.instance.google.proxy.nodeSelector | indent 10 }}
image: {{ .Values.config.instance.google.proxy.image }}
generic: {}
percona:
proxy:
image: {{ .Values.config.instance.percona.proxy.image }}
backup:
nodeSelector:
{{ toYaml .Values.config.backup.nodeSelector | indent 8 }}
Expand Down
148 changes: 94 additions & 54 deletions helm/db-operator/templates/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,60 +68,100 @@ spec:
subresources:
status: {}
preserveUnknownFields: true
# validation:
# openAPIV3Schema:
# description: DbInstance is the Schema for the dbinstances 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/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/api-conventions.md#types-kinds'
# type: string
# metadata:
# type: object
# spec:
# description: DbInstanceSpec defines the desired state of DbInstance
# type: object
# properties:
# engine:
# type: string
# adminSecretRef:
# type: map
# properties:
# Namespace:
# type: string
# Name:
# type: string
# backup:
# type: object
# generic:
# type: object
# properties:
# host:
# type: string
# port:
# type: integer
# google:
# type: object
# properties:
# instance:
# type: string
# configmapRef:
# type: map
# properties:
# Namespace:
# type: string
# Name:
# type: string
# status:
# description: DbInstanceStatus defines the observed state of DbInstance
# type: object
# type: object
validation:
openAPIV3Schema:
description: DbInstance is the Schema for the dbinstances 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/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/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: DbInstanceSpec defines the desired state of DbInstance
type: object
required:
- engine
- adminSecretRef
oneOf:
- required:
- percona
- required:
- google
- required:
- generic
properties:
engine:
type: string
adminSecretRef:
type: object
properties:
Namespace:
type: string
Name:
type: string
backup:
type: object
generic:
type: object
required:
- host
- port
properties:
host:
type: string
port:
type: integer
google:
type: object
required:
- instance
properties:
instance:
type: string
configmapRef:
type: object
properties:
Namespace:
type: string
Name:
type: string
percona:
type: object
required:
- servers
- monitorUserSecretRef
properties:
servers:
type: array
items:
required:
- host
- port
- maxConn
properties:
host:
type: string
port:
type: integer
maxConn:
type: integer
minimum: 1
readonly:
type: boolean
monitorUserSecretRef:
type: object
status:
description: DbInstanceStatus defines the observed state of DbInstance
type: object
type: object
version: v1alpha1
versions:
- name: v1alpha1
Expand Down
3 changes: 3 additions & 0 deletions helm/db-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ config:
nodeSelector: {}
image: gcr.io/cloudsql-docker/gce-proxy:1.16
generic: {}
percona:
proxy:
image: severalnines/proxysql:2.0
backup:
nodeSelector: {}
postgres:
Expand Down
Loading

0 comments on commit 8031dec

Please sign in to comment.