ccyunchina-deploy/roles/proprietary-cloud/templates/database/mysql-operator.yaml

467 lines
13 KiB
YAML

---
# Source: mysql-operator/templates/pdb.yaml
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
name: mysql-operator
labels:
app: mysql-operator
chart: mysql-operator-0.1.1_master
release: mysql-operator
heritage: Helm
spec:
maxUnavailable: 1
selector:
matchLabels:
app: mysql-operator
---
# Source: mysql-operator/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: mysql-operator
labels:
app: mysql-operator
chart: mysql-operator-0.1.1_master
release: mysql-operator
heritage: Helm
---
# Source: mysql-operator/templates/orc-secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: mysql-operator-orc
labels:
app: mysql-operator
chart: mysql-operator-0.1.1_master
release: mysql-operator
heritage: Helm
data:
TOPOLOGY_USER: "b3JjaGVzdHJhdG9y"
TOPOLOGY_PASSWORD: "cWp2dW5RalVyVA=="
---
# Source: mysql-operator/templates/orc-config.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: mysql-operator-orc
labels:
app: mysql-operator
chart: mysql-operator-0.1.1_master
release: mysql-operator
heritage: Helm
data:
{% raw %}
orchestrator.conf.json: "{\n \"ApplyMySQLPromotionAfterMasterFailover\": true,\n \"BackendDB\": \"sqlite\",\n \"Debug\": false,\n \"DetachLostReplicasAfterMasterFailover\": true,\n \"DetectClusterAliasQuery\": \"SELECT CONCAT(SUBSTRING(@@hostname, 1, LENGTH(@@hostname) - 1 - LENGTH(SUBSTRING_INDEX(@@hostname,'-',-2))),'.',SUBSTRING_INDEX(@@report_host,'.',-1))\",\n \"DetectInstanceAliasQuery\": \"SELECT @@hostname\",\n \"DiscoverByShowSlaveHosts\": false,\n \"FailMasterPromotionIfSQLThreadNotUpToDate\": true,\n \"HTTPAdvertise\": \"http://{{ .Env.HOSTNAME }}-svc:80\",\n \"HostnameResolveMethod\": \"none\",\n \"InstancePollSeconds\": 5,\n \"ListenAddress\": \":3000\",\n \"MasterFailoverLostInstancesDowntimeMinutes\": 10,\n \"MySQLHostnameResolveMethod\": \"@@report_host\",\n \"MySQLTopologyCredentialsConfigFile\": \"/etc/orchestrator/orc-topology.cnf\",\n \"OnFailureDetectionProcesses\": [\n \"/usr/local/bin/orc-helper event -w '{failureClusterAlias}' 'OrcFailureDetection' 'Failure: {failureType}, failed host: {failedHost}, lost replcas: {lostReplicas}' || true\",\n \"/usr/local/bin/orc-helper failover-in-progress '{failureClusterAlias}' '{failureDescription}' || true\"\n ],\n \"PostIntermediateMasterFailoverProcesses\": [\n \"/usr/local/bin/orc-helper event '{failureClusterAlias}' 'OrcPostIntermediateMasterFailover' 'Failure type: {failureType}, failed hosts: {failedHost}, slaves: {countSlaves}' || true\"\n ],\n \"PostMasterFailoverProcesses\": [\n \"/usr/local/bin/orc-helper event '{failureClusterAlias}' 'OrcPostMasterFailover' 'Failure type: {failureType}, new master: {successorHost}, slaves: {slaveHosts}' || true\"\n ],\n \"PostUnsuccessfulFailoverProcesses\": [\n \"/usr/local/bin/orc-helper event -w '{failureClusterAlias}' 'OrcPostUnsuccessfulFailover' 'Failure: {failureType}, failed host: {failedHost} with {countSlaves} slaves' || true\"\n ],\n \"PreFailoverProcesses\": [\n \"/usr/local/bin/orc-helper failover-in-progress '{failureClusterAlias}' '{failureDescription}' || true\"\n ],\n \"ProcessesShellCommand\": \"sh\",\n \"RaftAdvertise\": \"{{ .Env.HOSTNAME }}-svc\",\n \"RaftBind\": \"{{ .Env.HOSTNAME }}\",\n \"RaftDataDir\": \"/var/lib/orchestrator\",\n \"RaftEnabled\": true,\n \"RaftNodes\": [\n \"mysql-operator-0-svc\",\n \"mysql-operator-1-svc\",\n \"mysql-operator-2-svc\"\n ],\n \"RecoverIntermediateMasterClusterFilters\": [],\n \"RecoverMasterClusterFilters\": [],\n \"RecoveryIgnoreHostnameFilters\": [],\n \"RecoveryPeriodBlockSeconds\": 300,\n \"RemoveTextFromHostnameDisplay\": \":3306\",\n \"SQLite3DataFile\": \"/var/lib/orchestrator/orc.db\",\n \"SlaveLagQuery\": \"SELECT TIMESTAMPDIFF(SECOND,ts,UTC_TIMESTAMP()) as drift FROM sys_operator.heartbeat ORDER BY drift ASC LIMIT 1\",\n \"UnseenInstanceForgetHours\": 1\n}"
orc-topology.cnf: |
[client]
user = {{ .Env.ORC_TOPOLOGY_USER }}
password = {{ .Env.ORC_TOPOLOGY_PASSWORD }}
{% endraw %}
---
# Source: mysql-operator/templates/clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: 'mysql-operator'
labels:
app: 'mysql-operator'
chart: 'mysql-operator-0.1.1_master'
release: 'mysql-operator'
heritage: 'Helm'
rules:
- apiGroups:
- apps
resources:
- statefulsets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- batch
resources:
- jobs
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- configmaps
- events
- jobs
- persistentvolumeclaims
- pods
- secrets
- services
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- pods/status
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- mysql.presslabs.org
resources:
- mysqlbackups
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- mysql.presslabs.org
resources:
- mysqlclusters
- mysqlclusters/status
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- mysql.presslabs.org
resources:
- mysqldatabases
- mysqldatabases/status
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- mysql.presslabs.org
resources:
- mysqlusers
- mysqlusers/status
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- policy
resources:
- poddisruptionbudgets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
---
# Source: mysql-operator/templates/clusterrolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: mysql-operator
labels:
app: mysql-operator
chart: mysql-operator-0.1.1_master
release: mysql-operator
heritage: Helm
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: mysql-operator
subjects:
- name: mysql-operator
namespace: "kube-public"
kind: ServiceAccount
---
# Source: mysql-operator/templates/orc-service.yaml
apiVersion: v1
kind: Service
metadata:
name: mysql-operator-0-svc
labels:
app: mysql-operator
chart: mysql-operator-0.1.1_master
release: mysql-operator
heritage: Helm
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
spec:
type: ClusterIP
ports:
- name: web
port: 80
targetPort: 3000
- name: raft
port: 10008
targetPort: 10008
selector:
statefulset.kubernetes.io/pod-name: mysql-operator-0
---
# Source: mysql-operator/templates/orc-service.yaml
apiVersion: v1
kind: Service
metadata:
name: mysql-operator-1-svc
labels:
app: mysql-operator
chart: mysql-operator-0.1.1_master
release: mysql-operator
heritage: Helm
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
spec:
type: ClusterIP
ports:
- name: web
port: 80
targetPort: 3000
- name: raft
port: 10008
targetPort: 10008
selector:
statefulset.kubernetes.io/pod-name: mysql-operator-1
---
# Source: mysql-operator/templates/orc-service.yaml
apiVersion: v1
kind: Service
metadata:
name: mysql-operator-2-svc
labels:
app: mysql-operator
chart: mysql-operator-0.1.1_master
release: mysql-operator
heritage: Helm
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
spec:
type: ClusterIP
ports:
- name: web
port: 80
targetPort: 3000
- name: raft
port: 10008
targetPort: 10008
selector:
statefulset.kubernetes.io/pod-name: mysql-operator-2
---
# Source: mysql-operator/templates/orc-service.yaml
apiVersion: v1
kind: Service
metadata:
name: mysql-operator
labels:
app: mysql-operator
chart: mysql-operator-0.1.1_master
release: mysql-operator
heritage: Helm
spec:
type: NodePort
selector:
app: mysql-operator
ports:
- name: http
port: 80
protocol: TCP
targetPort: 3000
nodePort: 30005
---
# Source: mysql-operator/templates/statefulset.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mysql-operator
labels:
app: mysql-operator
chart: mysql-operator-0.1.1_master
release: mysql-operator
heritage: Helm
spec:
replicas: 3
serviceName: mysql-operator-orc
podManagementPolicy: Parallel
selector:
matchLabels:
app: mysql-operator
release: mysql-operator
template:
metadata:
labels:
app: mysql-operator
release: mysql-operator
annotations:
checksum/config: bbaf79b4ccafc572955c88be6dcbfe954de831c802d72bbffa59cd85be681406
checksum/secret: 750f8dadd01aa03979b14b94cd7cc026f1929ae2cfc506b1aec827e398f363bd
spec:
serviceAccountName: mysql-operator
containers:
- name: operator
image: {{BASE_IMAGE_URL}}/{{mysql_operator_image}}
imagePullPolicy: IfNotPresent
securityContext:
runAsUser: 888
env:
- name: ORC_TOPOLOGY_USER
valueFrom:
secretKeyRef:
name: mysql-operator-orc
key: TOPOLOGY_USER
- name: ORC_TOPOLOGY_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-operator-orc
key: TOPOLOGY_PASSWORD
args:
- --leader-election-namespace=kube-public
# connect to orchestrator on localhost
- --orchestrator-uri=http://127.0.0.1:3000/api
- --sidecar-image=quay.io/presslabs/mysql-operator-sidecar-mysql57:latest
- --sidecar-mysql8-image={{BASE_IMAGE_URL}}/{{mysql_helper_image}}
- --failover-before-shutdown=false
- --metrics-exporter-image={{BASE_IMAGE_URL}}/{{mysql_exporter_image}}
resources:
{}
# TODO: add livenessProbe to controller
# livenessProbe:
# httpGet:
# path: /health
# port: 80
- name: orchestrator
image: {{BASE_IMAGE_URL}}/{{mysql_orchestrator_image}}
imagePullPolicy: IfNotPresent
ports:
- containerPort: 3000
name: web
protocol: TCP
- containerPort: 10008
name: raft
protocol: TCP
env:
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
envFrom:
- prefix: ORC_
secretRef:
name: mysql-operator-orc
volumeMounts:
- name: data
mountPath: /var/lib/orchestrator/
- name: config
mountPath: /templates/
livenessProbe:
timeoutSeconds: 10
initialDelaySeconds: 200
httpGet:
path: /api/lb-check
port: 3000
# https://github.com/github/orchestrator/blob/master/docs/raft.md#proxy-healthy-raft-nodes
readinessProbe:
timeoutSeconds: 10
httpGet:
path: /api/raft-health
port: 3000
resources:
null
volumes:
- name: config
configMap:
name: mysql-operator-orc
# security context to mount corectly the volume for orc
securityContext:
fsGroup: 777
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- topologyKey: kubernetes.io/hostname
labelSelector:
matchLabels:
app: mysql-operator
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: [ ReadWriteOnce ]
resources:
requests:
storage: 1Gi
---
# Source: mysql-operator/templates/servicemonitor.yaml
# This is a ServicMonitor for the MySQL clusters, not the operator itself.
# To scrape the operator, we need https://github.com/presslabs/mysql-operator/issues/151 first.
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
annotations:
meta.helm.sh/release-name: mysql-operator
meta.helm.sh/release-namespace: monitoring
labels:
app.kubernetes.io/instance: mysql-operator
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: mysql-operator
app.kubernetes.io/version: master
helm.sh/chart: mysql-operator-0.1.1_master
name: mysql-operator
spec:
endpoints:
- interval: 10s
path: /metrics
port: prometheus
scrapeTimeout: 3s
namespaceSelector:
any: true
selector:
matchLabels:
app.kubernetes.io/managed-by: mysql.presslabs.org
app.kubernetes.io/name: mysql