Bug #110095 MySQL Operator: Cannot change resource request/limit via the operator
Submitted: 16 Feb 2023 7:49 Modified: 21 Feb 2023 16:06
Reporter: Vy Nguyen Tan Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Operator Severity:S3 (Non-critical)
Version:2.0.8 - 8.0.32 OS:Any
Assigned to: CPU Architecture:Any

[16 Feb 2023 7:49] Vy Nguyen Tan
Description:
Cannot change resource request/limit via the operator.

How to repeat:
- Step 1: Create a new innodb cluster via mysql-operator/mysql-innodbcluster chart.

helmfile.yaml
------
repositories:
  - name: mysql-operator
    url: "https://mysql.github.io/mysql-operator"
releases:
  - name: mysql-innodbcluster-p2
    namespace: infra-databases
    chart: mysql-operator/mysql-innodbcluster
    version: 2.0.8
    installed: true
    values:
      - values/mysql-innodbcluster-p2-config.yaml

values/mysql-innodbcluster-p2-config.yaml:
---------
...
serverVersion: 8.0.32
serverInstances: 3
routerInstances: 1 # or use router.instances
baseServerId: 1000
...
podSpec:
  containers:
  - name: mysql
    resources:
      requests:
        memory: "1024Mi"  # adapt to your needs
        cpu: "200m"      # adapt to your needs
      limits:
        memory: "2048Mi"  # adapt to your needs
        cpu: "3100m"      # adapt to your needs
...

get innodb cluster status
---------
kubectl -n infra-databases get innodbcluster                                                                                  
NAME                     STATUS         ONLINE   INSTANCES   ROUTERS   AGE
mysql-innodbcluster-p2   ONLINE         3        3           1         15m

get statefulset resource request/limit
---------
[  
  {
    "statefulset_name": "mysql-innodbcluster-p2",
    "containers": [
      {
        "container_name": "sidecar",
        "memory_requested": null,
        "cpu_requested": null,
        "memory_limit": null,
        "cpu_limit": null
      }
    ]
  },
  {
    "statefulset_name": "mysql-innodbcluster-p2",
    "containers": [
      {
        "container_name": "mysql",
        "memory_requested": "1Gi",
        "cpu_requested": "200m",
        "memory_limit": "2Gi",
        "cpu_limit": "3100m"
      }
    ]
  }
]

- Step 2: change resource request from 200m -> 300m

values/mysql-innodbcluster-p2-config.yaml:
---------
...
podSpec:
  containers:
  - name: mysql
    resources:
      requests:
        memory: "1024Mi"  # adapt to your needs
        cpu: "300m"      # adapt to your needs
      limits:
        memory: "2048Mi"  # adapt to your needs
        cpu: "3100m"      # adapt to your needs
...

get innodb cluster status
---------
kubectl -n infra-databases get innodbcluster                                                                                
NAME                     STATUS         ONLINE   INSTANCES   ROUTERS   AGE
mysql-innodbcluster-p2   ONLINE         3        3           1         19m

get statefulset resource request/limit
---------
[
    {
    "statefulset_name": "mysql-innodbcluster-p2",
    "containers": [
      {
        "container_name": "sidecar",
        "memory_requested": null,
        "cpu_requested": null,
        "memory_limit": null,
        "cpu_limit": null
      }
    ]
  },
  {
    "statefulset_name": "mysql-innodbcluster-p2",
    "containers": [
      {
        "container_name": "mysql",
        "memory_requested": "1Gi",
        "cpu_requested": "200m",
        "memory_limit": "2Gi",
        "cpu_limit": "3100m"
      }
    ]
  }
]
[16 Feb 2023 8:00] Vy Nguyen Tan
the command to get sts resource request/limit.
-----
kubectl get sts -n infra-databases --sort-by='.metadata.name' -o json | jq -r '[.items[] | {statefulset_name: .metadata.name, containers: .spec.template.spec.containers[] | [ {container_name: .name, memory_requested: .resources.requests.memory, cpu_requested: .resources.requests.cpu, memory_limit: .resources.limits.memory, cpu_limit: .resources.limits.cpu} ] }]'
[21 Feb 2023 16:06] MySQL Verification Team
Thank you for the report