0

I have a k8s cluster on which I want to deploy the MariaDB cluster. I have master and slave pods and want to monitor them with a maxscale. The pod runs with its default config without any problem, but when I mount the volume in a type of configmap and run maxctrl list servers I get the below error:

Error: Could not connect to MaxScale

The logs of the pod:

maxscale log

Deployment file:

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: maxscale
  namespace: mariaDB-cluster
spec:
  replicas: 2
  selector:
    matchLabels:
      app: maxscale
  template:
    metadata:
      labels:
        app: maxscale
    spec:
      containers:
        - name: maxscale
          image: mariadb/maxscale:6.3.1
          volumeMounts:
          - name: maxscale
            mountPath: /etc/maxscale.cnf.d/
          ports:
          - name: mariadb
            containerPort: 3306
          - name: restapi
            containerPort: 8989
      volumes:
      - name: maxscale
        configMap:
          name: maxscale-test
          items:
          - key: "maxscale.cnf"
            path: "maxscale.cnf"

Configmap.yaml:

apiVersion: v1
kind: ConfigMap
metadata:
  name:  maxscale-test
  namespace: mariadb-cluster
  labels:
    app:  maxscale
    app.kubernetes.io/name: maxscale
data:
  maxscale.cnf: |
    [maxscale]
    threads=auto
    admin_enabled=false

    # Server definitions
    #
    # Set the address of the server to the network
    # address of a MariaDB server.
    #

    [server1]
    type=server
    address=127.0.0.1
    port=3306
    protocol=MariaDBBackend

    # Monitor for the servers
    #
    # This will keep MaxScale aware of the state of the servers.
    # MariaDB Monitor documentation:
    # https://mariadb.com/kb/en/maxscale-6-monitors/

    [MariaDB-Monitor]
    type=monitor
    module=mariadbmon
    servers=server1
    user=myuser
    password=mypwd
    monitor_interval=2000

    # Service definitions
    #
    # Service Definition for a read-only service and
    # a read/write splitting service.
    #

    # ReadConnRoute documentation:
    # https://mariadb.com/kb/en/mariadb-maxscale-6-readconnroute/

    [Read-Only-Service]
    type=service
    router=readconnroute
    servers=server1
    user=myuser
    password=mypwd
    router_options=slave

    # ReadWriteSplit documentation:
    # https://mariadb.com/kb/en/mariadb-maxscale-6-readwritesplit/

    [Read-Write-Service]
    type=service
    router=readwritesplit
    servers=server1
    user=myuser
    password=mypwd

    # Listener definitions for the services
    #
    # These listeners represent the ports the
    # services will listen on.
    #

    [Read-Only-Listener]
    type=listener
    service=Read-Only-Service
    protocol=MariaDBClient
    port=4008

    [Read-Write-Listener]
    type=listener
    service=Read-Write-Service
    protocol=MariaDBClient
    port=4006

I use the maxscale default config, but it does not work when I mount it to /etc/maxscale.cnf.d, so I think the problem is related to reading the config file.

2 Answers2

0

Make sure to run the command inside the same container that the maxscale process is running on: by default it listens only for local connections on port 8989. If you want MaxScale to listen on all interfaces, not just the loopback interface, use admin_host=0.0.0.0.

If you expose the REST API port of the container and want to connect to it from outside, use maxctrl -h address:port. The address is the network address (admin_host in maxscale.cnf) and port is the network port it listens on (admin_port in maxctrl.cnf).

For example, to connect to a MaxScale container at mxshost:

maxctrl -h mxshost:8989 list servers
markusjm
  • 2,358
  • 1
  • 11
  • 23
0

i found the answer. It was about the conflict in maxscale config. i add a new config in maxscale.cnf and mount it to /etc/maxscale.cnf.d/ . but I think this config was appended to /etc/maxscale.cnf, so when I have the below part in /etc/maxscale.cnf.d/maxscale.cnf again, it makes conflict:

[maxscale]
    threads=auto
    admin_enabled=false

So I deleted this part from my configmap, and it worked.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 08 '22 at 22:18