Skip to content

Commit

Permalink
K8SPS-353: Deploy Binlog Server
Browse files Browse the repository at this point in the history
  • Loading branch information
egegunes committed Aug 8, 2024
1 parent 4f5a974 commit f7cae2d
Show file tree
Hide file tree
Showing 17 changed files with 5,436 additions and 22 deletions.
29 changes: 29 additions & 0 deletions api/v1alpha1/perconaservermysql_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ type BackupSpec struct {
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
Storages map[string]*BackupStorageSpec `json:"storages,omitempty"`
BackoffLimit *int32 `json:"backoffLimit,omitempty"`
PiTR PiTRSpec `json:"pitr,omitempty"`
}

// Retrieves the initialization image for the backup.
Expand Down Expand Up @@ -343,6 +344,34 @@ func (b *BackupStorageAzureSpec) ContainerAndPrefix() (string, string) {
return container, prefix
}

type PiTRSpec struct {
Enabled bool `json:"enabled,omitempty"`

BinlogServer BinlogServerSpec `json:"binlogServer,omitempty"`
}

type BinlogServerStorageSpec struct {
S3 *BackupStorageS3Spec `json:"s3,omitempty"`
}

type BinlogServerSpec struct {
Storage BinlogServerStorageSpec `json:"storage"`

// The number of seconds the MySQL client library will wait to establish a connection with a remote host
ConnectTimeout int32 `json:"connectTimeout,omitempty"`
// The number of seconds the MySQL client library will wait to read data from a remote server.
ReadTimeout int32 `json:"readTimeout,omitempty"`
// The number of seconds the MySQL client library will wait to write data to a remote server.
WriteTimeout int32 `json:"writeTimeout,omitempty"`

// Specifies the server ID that the utility will be using when connecting to a remote MySQL server
ServerID int32 `json:"serverId,omitempty"`
// The number of seconds the utility will spend in disconnected mode between reconnection attempts.
IdleTime int32 `json:"idleTime,omitempty"`

PodSpec `json:",inline"`
}

type ProxySpec struct {
Router *MySQLRouterSpec `json:"router,omitempty"`
HAProxy *HAProxySpec `json:"haproxy,omitempty"`
Expand Down
54 changes: 54 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

1 change: 1 addition & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,6 @@ COPY build/haproxy_readiness_check.sh /opt/percona-server-mysql-operator/haproxy
COPY build/haproxy.cfg /opt/percona-server-mysql-operator/haproxy.cfg
COPY build/haproxy-global.cfg /opt/percona-server-mysql-operator/haproxy-global.cfg
COPY build/pmm-prerun.sh /opt/percona-server-mysql-operator/pmm-prerun.sh
COPY build/binlog-server-entrypoint.sh /opt/percona-server-mysql-operator/binlog-server-entrypoint.sh

USER 2
5 changes: 5 additions & 0 deletions build/binlog-server-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

set -e

exec $@

Check failure on line 5 in build/binlog-server-entrypoint.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] build/binlog-server-entrypoint.sh#L5 <ShellCheck.SC2068>

Double quote array expansions to avoid re-splitting elements.
Raw output
./build/binlog-server-entrypoint.sh:5:6: error: Double quote array expansions to avoid re-splitting elements. (ShellCheck.SC2068)
14 changes: 4 additions & 10 deletions build/ps-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,6 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
GRANT SERVICE_CONNECTION_ADMIN ON *.* TO 'monitor'@'${MONITOR_HOST}';
EOSQL

if [ "$CLUSTER_TYPE" == 'async' ]; then
read -r -d '' replicationCreate <<-EOSQL || true
CREATE USER 'replication'@'%' IDENTIFIED BY '${REPLICATION_PASSWORD}' PASSWORD EXPIRE NEVER;
GRANT DELETE, INSERT, UPDATE ON mysql.* TO 'replication'@'%' WITH GRANT OPTION;
GRANT SELECT ON performance_schema.threads to 'replication'@'%';
GRANT SYSTEM_USER, REPLICATION SLAVE, BACKUP_ADMIN, GROUP_REPLICATION_STREAM, CLONE_ADMIN, CONNECTION_ADMIN, CREATE USER, EXECUTE, FILE, GROUP_REPLICATION_ADMIN, PERSIST_RO_VARIABLES_ADMIN, PROCESS, RELOAD, REPLICATION CLIENT, REPLICATION_APPLIER, REPLICATION_SLAVE_ADMIN, ROLE_ADMIN, SELECT, SHUTDOWN, SYSTEM_VARIABLES_ADMIN ON *.* TO 'replication'@'%' WITH GRANT OPTION;
EOSQL
fi

"${mysql[@]}" <<-EOSQL
-- What's done in this file shouldn't be replicated
-- or products like mysql-fabric won't work
Expand All @@ -327,7 +318,10 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
GRANT SELECT ON performance_schema.* TO 'monitor'@'${MONITOR_HOST}';
${monitorConnectGrant}
${replicationCreate}
CREATE USER 'replication'@'%' IDENTIFIED BY '${REPLICATION_PASSWORD}' PASSWORD EXPIRE NEVER;
GRANT DELETE, INSERT, UPDATE ON mysql.* TO 'replication'@'%' WITH GRANT OPTION;
GRANT SELECT ON performance_schema.threads to 'replication'@'%';
GRANT SYSTEM_USER, REPLICATION SLAVE, BACKUP_ADMIN, GROUP_REPLICATION_STREAM, CLONE_ADMIN, CONNECTION_ADMIN, CREATE USER, EXECUTE, FILE, GROUP_REPLICATION_ADMIN, PERSIST_RO_VARIABLES_ADMIN, PROCESS, RELOAD, REPLICATION CLIENT, REPLICATION_APPLIER, REPLICATION_SLAVE_ADMIN, ROLE_ADMIN, SELECT, SHUTDOWN, SYSTEM_VARIABLES_ADMIN ON *.* TO 'replication'@'%' WITH GRANT OPTION;
CREATE USER 'orchestrator'@'%' IDENTIFIED BY '${ORC_TOPOLOGY_PASSWORD}' PASSWORD EXPIRE NEVER;
GRANT SYSTEM_USER, SUPER, PROCESS, REPLICATION SLAVE, REPLICATION CLIENT, RELOAD ON *.* TO 'orchestrator'@'%';
Expand Down
2 changes: 2 additions & 0 deletions build/ps-init-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ install -o "$(id -u)" -g "$(id -g)" -m 0755 -D "${OPERATORDIR}/haproxy.cfg" "${B
install -o "$(id -u)" -g "$(id -g)" -m 0755 -D "${OPERATORDIR}/haproxy-global.cfg" "${BINDIR}/haproxy-global.cfg"

install -o "$(id -u)" -g "$(id -g)" -m 0755 -D "${OPERATORDIR}/pmm-prerun.sh" "${BINDIR}/pmm-prerun.sh"

install -o "$(id -u)" -g "$(id -g)" -m 0755 -D "${OPERATORDIR}/binlog-server-entrypoint.sh" "${BINDIR}/binlog-server-entrypoint.sh"
Loading

0 comments on commit f7cae2d

Please sign in to comment.