Skip to content

Instantly share code, notes, and snippets.

@bluven
Last active February 15, 2019 10:20
Show Gist options
  • Save bluven/e2e963d2969e54c8f3928f3ad96af869 to your computer and use it in GitHub Desktop.
Save bluven/e2e963d2969e54c8f3928f3ad96af869 to your computer and use it in GitHub Desktop.
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app: mysql-operator
name: mysql
namespace: default
data:
my.cnf: |
[mysqld]
binlog-format = ROW
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
default-storage-engine = InnoDB
enforce-gtid-consistency = on
expire-logs-days = 14
gtid-mode = on
innodb-file-per-table = 1
innodb-flush-log-at-trx-commit = 2
innodb-flush-method = O_DIRECT
innodb-log-files-in-group = 2
key-buffer-size = 32M
log-bin = /var/lib/mysql/mysql-bin
log-slave-updates = on
master_info_repository = TABLE
max-allowed-packet = 16M
max-connect-errors = 1000000
max-connections = 500
max-heap-table-size = 32M
myisam-recover-options = FORCE,BACKUP
open-files-limit = 65535
query-cache-size = 0
query-cache-type = 0
read-only = on
relay-log-info-repository = TABLE
relay-log-recovery = on
skip-slave-start = on
sql-mode = STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ONLY_FULL_GROUP_BY
sync-binlog = 1
sysdate-is-now = 1
table-definition-cache = 4096
table-open-cache = 4096
thread-cache-size = 50
tmp-table-size = 32M
innodb-buffer-pool-size = 512M
innodb-log-file-size = 128M
skip-host-cache
skip-name-resolve
!includedir /etc/mysql/conf.d
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mysql
namespace: default
spec:
selector:
matchLabels:
app: mysql
serviceName: mysql
replicas: 2
template:
metadata:
labels:
app: mysql
spec:
containers:
- env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
key: ROOT_PASSWORD
name: my-secret
- name: MYSQL_USER
valueFrom:
secretKeyRef:
key: USER
name: my-secret
optional: true
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
key: PASSWORD
name: my-secret
optional: true
- name: MYSQL_DATABASE
valueFrom:
secretKeyRef:
key: DATABASE
name: my-secret
optional: true
image: registry.bluven.me:5000/bluven/percona:5.7-debug
imagePullPolicy: Always
livenessProbe:
exec:
command:
- mysqladmin
- --defaults-file=/etc/mysql/client.cnf
- ping
failureThreshold: 1000
initialDelaySeconds: 30
periodSeconds: 5
successThreshold: 1
timeoutSeconds: 5
name: mysql
ports:
- containerPort: 3306
name: mysql
protocol: TCP
readinessProbe:
exec:
command:
- mysql
# - --defaults-file=/etc/mysql/client.cnf
- -e
- SELECT 1
failureThreshold: 3
initialDelaySeconds: 5
periodSeconds: 2
successThreshold: 1
timeoutSeconds: 5
resources:
requests:
cpu: 500m
memory: 1Gi
volumeMounts:
- mountPath: /etc/mysql
name: conf
- mountPath: /var/lib/mysql
name: data
volumes:
- emptyDir: {}
name: conf
- configMap:
defaultMode: 420
name: mysql
name: config-map
- name: data
persistentVolumeClaim:
claimName: data
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes:
- ReadWriteOnce
dataSource: null
resources:
requests:
storage: 1Gi
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mysql
namespace: default
spec:
selector:
matchLabels:
app: mysql
serviceName: mysql
replicas: 2
template:
metadata:
labels:
app: mysql
spec:
containers:
- env:
- name: MY_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: MY_POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: MY_POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
- name: MY_SERVICE_NAME
value: mc-mysql-nodes
- name: MY_CLUSTER_NAME
value: mc
- name: MY_FQDN
value: $(MY_POD_NAME).$(MY_SERVICE_NAME).$(MY_NAMESPACE)
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
key: ROOT_PASSWORD
name: my-secret
- name: MYSQL_USER
valueFrom:
secretKeyRef:
key: USER
name: my-secret
optional: true
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
key: PASSWORD
name: my-secret
optional: true
- name: MYSQL_DATABASE
valueFrom:
secretKeyRef:
key: DATABASE
name: my-secret
optional: true
image: registry.bluven.me:5000/bluven/percona:5.7-debug
imagePullPolicy: Always
livenessProbe:
exec:
command:
- mysqladmin
- --defaults-file=/etc/mysql/client.cnf
- ping
failureThreshold: 1000
initialDelaySeconds: 30
periodSeconds: 5
successThreshold: 1
timeoutSeconds: 5
name: mysql
ports:
- containerPort: 3306
name: mysql
protocol: TCP
readinessProbe:
exec:
command:
- mysql
- --defaults-file=/etc/mysql/client.cnf
- -e
- SELECT 1
failureThreshold: 3
initialDelaySeconds: 5
periodSeconds: 2
successThreshold: 1
timeoutSeconds: 5
resources:
requests:
cpu: 500m
memory: 1Gi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /etc/mysql
name: conf
- mountPath: /var/lib/mysql
name: data
dnsPolicy: ClusterFirst
initContainers:
- args:
- files-config
env:
- name: MY_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: MY_POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: MY_POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
- name: MY_SERVICE_NAME
value: mc-mysql-nodes
- name: MY_CLUSTER_NAME
value: mc
- name: MY_FQDN
value: $(MY_POD_NAME).$(MY_SERVICE_NAME).$(MY_NAMESPACE)
image: quay.io/presslabs/mysql-operator-sidecar:latest
imagePullPolicy: Always
name: init-mysql
resources: {}
volumeMounts:
- mountPath: /etc/mysql
name: conf
- mountPath: /mnt/conf
name: config-map
- args:
- clone
env:
- name: MY_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: MY_POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: MY_POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
- name: MY_SERVICE_NAME
value: mc-mysql-nodes
- name: MY_CLUSTER_NAME
value: mc
- name: MY_FQDN
value: $(MY_POD_NAME).$(MY_SERVICE_NAME).$(MY_NAMESPACE)
- name: MYSQL_BACKUP_USER
valueFrom:
secretKeyRef:
key: BACKUP_USER
name: my-secret
optional: true
- name: MYSQL_BACKUP_PASSWORD
valueFrom:
secretKeyRef:
key: BACKUP_PASSWORD
name: my-secret
optional: true
image: quay.io/presslabs/mysql-operator-sidecar:latest
imagePullPolicy: Always
name: clone-mysql
resources: {}
volumeMounts:
- mountPath: /etc/mysql
name: conf
- mountPath: /var/lib/mysql
name: data
restartPolicy: Always
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- emptyDir: {}
name: conf
- configMap:
defaultMode: 420
name: mysql
name: config-map
- name: data
persistentVolumeClaim:
claimName: data
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes:
- ReadWriteOnce
dataSource: null
resources:
requests:
storage: 1Gi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment