官方文档:通用 Kubernetes 安装 - Percona Operator for MySQL --- Generic Kubernetes installation - Percona Operator for MySQL
安装Operator
git clone -b v1.14.0 https://github.com/percona/percona-xtradb-cluster-operator
cd percona-xtradb-cluster-operator
方式一:分步安装
kubectl apply -f deploy/crd.yaml
kubectl apply -f deploy/cw-operator.yaml -n kube-system
sed -i "s/pxc-operator/kube-system/g" deploy/cw-rbac.yaml
sed -i "s/imagePullPolicy: Always/imagePullPolicy: IfNotPresent/g" deploy/cw-operator.yaml
kubectl apply -f deploy/cw-rbac.yaml -n kube-system
kubectl apply -f deploy/secrets.yaml -n kube-system
方式二:简易安装
sed -i "s/pxc-operator/kube-system/g" deploy/cw-bundle.yaml
sed -i "s/imagePullPolicy: Always/imagePullPolicy: IfNotPresent/g" deploy/cw-bundle.yaml
kubectl apply -f deploy/crd.yaml
kubectl apply -f deploy/cw-bundle.yaml -n kube-system
安装pxc集群
vim deploy/cr.yaml
apiVersion: pxc.percona.com/v1
kind: PerconaXtraDBCluster
metadata:
name: cluster1
finalizers:
- delete-pxc-pods-in-order
spec:
crVersion: 1.14.0
allowUnsafeConfigurations: false
updateStrategy: SmartUpdate
upgradeOptions:
versionServiceEndpoint: https://check.percona.com
apply: disabled
schedule: "0 4 * * *"
pxc:
size: 3
image: percona/percona-xtradb-cluster:8.0.35-27.1
imagePullPolicy: IfNotPresent
autoRecovery: true
resources:
requests:
memory: 1G
cpu: 600m
affinity:
antiAffinityTopologyKey: "kubernetes.io/hostname"
podDisruptionBudget:
maxUnavailable: 1
volumeSpec:
persistentVolumeClaim:
storageClassName: nfs-storage # 改为实际storageclass
resources:
requests:
storage: 6G
gracePeriod: 600
haproxy:
enabled: true
size: 3
image: percona/percona-xtradb-cluster-operator:1.14.0-haproxy
imagePullPolicy: IfNotPresent
resources:
requests:
memory: 1G
cpu: 600m
affinity:
antiAffinityTopologyKey: "kubernetes.io/hostname"
podDisruptionBudget:
maxUnavailable: 1
gracePeriod: 30
proxysql:
enabled: false
size: 3
image: percona/percona-xtradb-cluster-operator:1.14.0-proxysql
imagePullPolicy: IfNotPresent
resources:
requests:
memory: 1G
cpu: 600m
affinity:
antiAffinityTopologyKey: "kubernetes.io/hostname"
volumeSpec:
persistentVolumeClaim:
resources:
requests:
storage: 2G
podDisruptionBudget:
maxUnavailable: 1
gracePeriod: 30
logcollector:
enabled: true
image: percona/percona-xtradb-cluster-operator:1.14.0-logcollector
imagePullPolicy: IfNotPresent
resources:
requests:
memory: 100M
cpu: 200m
pmm:
enabled: false
image: percona/pmm-client:2.41.1
serverHost: monitoring-service
resources:
requests:
memory: 150M
cpu: 300m
backup:
image: percona/percona-xtradb-cluster-operator:1.14.0-pxc8.0-backup-pxb8.0.35
pitr:
enabled: false
storageName: STORAGE-NAME-HERE
timeBetweenUploads: 60
timeoutSeconds: 60
storages:
s3-us-west:
type: s3
verifyTLS: true
s3:
bucket: S3-BACKUP-BUCKET-NAME-HERE
credentialsSecret: my-cluster-name-backup-s3
region: us-west-2
azure-blob:
type: azure
azure:
credentialsSecret: azure-secret
container: test
fs-pvc:
type: filesystem
volume:
persistentVolumeClaim:
storageClassName: nfs-storage # 改为实际storageclass
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 6G
schedule:
- name: "daily-backup"
schedule: "0 0 * * *"
keep: 5
storageName: fs-pvc
kubectl create ns pxc
kubectl apply -f cr.yaml -n pxc
最小化pxc集群
vim cr-minimal.yaml
apiVersion: pxc.percona.com/v1
kind: PerconaXtraDBCluster
metadata:
name: minimal-cluster
spec:
crVersion: 1.14.0
secretsName: minimal-cluster-secrets
allowUnsafeConfigurations: true
upgradeOptions:
apply: disabled
schedule: "0 4 * * *"
pxc:
size: 1
image: percona/percona-xtradb-cluster:8.0.35-27.1
imagePullPolicy: IfNotPresent
volumeSpec:
persistentVolumeClaim:
storageClassName: nfs-storage
resources:
requests:
storage: 6G
haproxy:
enabled: true
size: 1
image: percona/percona-xtradb-cluster-operator:1.14.0-haproxy
imagePullPolicy: IfNotPresent
logcollector:
enabled: true
image: percona/percona-xtradb-cluster-operator:1.14.0-logcollector
imagePullPolicy: IfNotPresent
kubectl apply -f cr-minimal.yaml
卸载
kubectl delete pxc <pxc集群名称>
kubectl delete -f deploy/cw-bundle.yaml
kubectl delete -f deploy/crd.yaml
kubectl delete validatingwebhookconfigurations percona-xtradbcluster-webhook