kubernetesmariadbkubernetes-helmkubernetes-operator

MaxScale with replication couldn't create the monitor - mariadbmon-monitor' with module 'mariadbmon'


I've been trying to deploy the mariadb-operator, mariadb full replication and maxscale. It's all working great but I have 2 problems - which they might be related.

When I deploy the below yaml for the maxscale, it gives error as error initializing Pod 'maxscale-0': error creating monitor: Could not create monitor 'mariadbmon-monitor' with module 'mariadbmon'

My Maxscale:

apiVersion: k8s.mariadb.com/v1alpha1
kind: MaxScale
metadata:
  name: maxscale
spec:
  podSecurityContext:
    runAsUser: 0
  replicas: 3
  mariaDbRef:
    name: mariadb
  initContainers:
  ## Added for local in mac/minikube: https://github.com/mariadb-operator/mariadb-operator/issues/381
  - image: busybox
    command:
      - /bin/sh
      - -c
      - chown -R 998:996 /var/lib/maxscale
    volumeMounts:
    - name: storage
      mountPath: /var/lib/maxscale
  services:
    - name: rw-router
      router: readwritesplit
      params:
        transaction_replay: "true"
        transaction_replay_attempts: "10"
        transaction_replay_timeout: "5s"
        max_slave_connections: "255"
        max_replication_lag: "3s"
        master_accept_reads: "true"
      listener:
        port: 3306
        protocol: MariaDBProtocol
        params:
          connection_metadata: "tx_isolation=auto"
    - name: rconn-master-router
      router: readconnroute
      params:
        router_options: "master"
        max_replication_lag: "3s"
        master_accept_reads: "true"
      listener:
        port: 3307
    - name: rconn-slave-router
      router: readconnroute
      params:
        router_options: "slave"
        max_replication_lag: "3s"
      listener:
        port: 3308

  monitor:
    interval: 2000ms
    cooperativeMonitoring: majority_of_all
    params:
      disable_master_failback: "false"
      available_when_donor: "false"
      disable_master_role_setting: "false"

  admin:
    port: 8989
    guiEnabled: true

  config:
    sync:
      database: mysql
      interval: 5s
      timeout: 10s
    volumeClaimTemplate:
      resources:
        requests:
          storage: 300Mi
      accessModes:
        - ReadWriteOnce

  auth:
    generate: true

  kubernetesService:
    type: LoadBalancer

  guiKubernetesService:
    type: ClusterIP

  connection:
    secretName: mxs-conn
    port: 3306

  requeueInterval: 10s

my mariadb :

apiVersion: k8s.mariadb.com/v1alpha1
kind: MariaDB
metadata:
  name: mariadb
spec:
  podSecurityContext:
    runAsUser: 0
  rootPasswordSecretKeyRef:
    name: mariadb-root
    key: password
    generate: true

  username: mariadb
  passwordSecretKeyRef:
    name: mariadb-password
    key: password
    generate: true
  database: mariadb

  
  storage:
    size: 300Mi
    resizeInUseVolumes: true
    waitForVolumeResize: true
    volumeClaimTemplate:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 300Mi

  replicas: 3

  # provision a MaxScale instance and set 'spec.maxScaleRef' automatically.
  maxScaleRef:
    name: maxscale
    enabled: true
    
  replication:
    enabled: true
    primary:
      automaticFailover: false
    replica:
      waitPoint: AfterCommit
      gtid: SlavePos
      connectionTimeout: 10s
      connectionRetries: 10
      syncTimeout: 10s
    syncBinlog: true

  service:
    type: LoadBalancer

  connection:
    secretName: mariadb-repl-conn
    secretTemplate:
      key: dsn

  primaryService:
    type: ClusterIP

  primaryConnection:
    secretName: mariadb-repl-conn-primary
    secretTemplate:
      key: dsn

  secondaryService:
    type: ClusterIP

  secondaryConnection:
    secretName: mariadb-repl-conn-secondary
    secretTemplate:
      key: dsn

  affinity:
    antiAffinityEnabled: true

  tolerations:
    - key: "k8s.mariadb.com/ha"
      operator: "Exists"
      effect: "NoSchedule"

  podDisruptionBudget:
    maxUnavailable: 33%

  updateStrategy:
    type: ReplicasFirstPrimaryLast

  myCnf: |
    [mariadb]
    bind-address=*
    default_storage_engine=InnoDB
    binlog_format=row
    innodb_autoinc_lock_mode=2
    innodb_buffer_pool_size=1024M
    max_allowed_packet=256M

  resources:
    requests:
      cpu: 100m
      memory: 128Mi
    limits:
      memory: 1Gi

  livenessProbe:
    initialDelaySeconds: 20
    periodSeconds: 5
    timeoutSeconds: 5

  readinessProbe:
    initialDelaySeconds: 20
    periodSeconds: 5
    timeoutSeconds: 5

  metrics:
    enabled: true

Error logs:

{"level":"error","ts":1724848591.526018,"msg":"Reconciler error","controller":"maxscale","controllerGroup":"k8s.mariadb.com","controllerKind":"MaxScale","MaxScale":{"name":"maxscale","namespace":"mariadb"},"namespace":"mariadb","name":"maxscale","reconcileID":"9ef2ef75-7a9e-40b3-9f7f-47e8e7d5dff7","error":"error reconciling phase Init: 1 error occurred:\n\t* error initializing Pod 'maxscale-0': error creating monitor: Could not create monitor 'mariadbmon-monitor' with module 'mariadbmon'\n\n","stacktrace":"sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.3/pkg/internal/controller/controller.go:329\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.3/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(Controller).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.3/pkg/internal/controller/controller.go:227"}
{"level":"info","ts":1724848591.7120426,"msg":"Initializing MaxScale Pod","controller":"maxscale","controllerGroup":"k8s.mariadb.com","controllerKind":"MaxScale","MaxScale":{"name":"maxscale","namespace":"mariadb"},"namespace":"mariadb","name":"maxscale","reconcileID":"4e51940e-0eee-428e-8b33-6a8a507e1f71","pod":"maxscale-0"}
{"level":"error","ts":1724848591.7299356,"msg":"Reconciler error","controller":"maxscale","controllerGroup":"k8s.mariadb.com","controllerKind":"MaxScale","MaxScale":{"name":"maxscale","namespace":"mariadb"},"namespace":"mariadb","name":"maxscale","reconcileID":"4e51940e-0eee-428e-8b33-6a8a507e1f71","error":"error reconciling phase Init: 1 error occurred:\n\t error initializing Pod 'maxscale-0': error creating monitor: Could not create monitor 'mariadbmon-monitor' with module 'mariadbmon'\n\n","stacktrace":"sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.3/pkg/internal/controller/controller.go:329\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.3/pkg/internal/controller/controller.go:266\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.17.3/pkg/internal/controller/controller.go:227"}

Environment details:


Solution

  • This has been addressed in newer mariadb-operator versions. https://github.com/mariadb-operator/mariadb-operator/issues/814#issuecomment-2343125150