Bug #109971 MySQL Operator doesn't respect non-default cluster domains
Submitted: 7 Feb 2023 20:04 Modified: 8 Feb 2023 15:07
Reporter: Chris Marslender Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Operator Severity:S2 (Serious)
Version: OS:Any
Assigned to: CPU Architecture:Any

[7 Feb 2023 20:04] Chris Marslender
Description:
In the MySQL operator, there are several hard-coded references to the default cluster domain of cluster.local (Links below). This causes the mysql operator to fail to start a cluster on anything where the --cluster-domain flag is set to something non default. In our case, we run multiple clusters, each with its own unique domain. MySQL clusters just get stuck at Initializing because the up check never succeeds:

```[2023-02-07 19:52:28,989] kopf.objects         [INFO    ] Handler 'on_pod_event' succeeded.
2023-02-07 19:52:30: Info: Connecting to MySQL at: mysql://mysqladmin@block-metrics-generic-mysql-0.block-metrics-generic-mysql-instances.block-metrics.svc.cluster.local:3306
[2023-02-07 19:52:30,120] kopf.objects         [INFO    ] Error executing mysqlsh.connect_dba, retrying after 10s: MySQL Error (2005): mysqlsh.connect_dba: Unknown MySQL server host 'block-metrics-generic-mysql-0.block-metrics-generic-mysql-instances.block-metrics.svc.cluster.local' (-2)```

Links:
https://github.com/mysql/mysql-operator/blob/06b963e5b7403f7c217a1a4a4e83d9f4483c892a/mysq...

https://github.com/mysql/mysql-operator/blob/62d884e187a78f9deb689531ac70fbf0a88f5d9d/test...

https://github.com/mysql/mysql-operator/blob/62d884e187a78f9deb689531ac70fbf0a88f5d9d/mysq...

https://github.com/mysql/mysql-operator/blob/62d884e187a78f9deb689531ac70fbf0a88f5d9d/mysq...

How to repeat:
Set up a k8s cluster with a non-default cluster domain and try to deploy an innodbcluster using the operator

Suggested fix:
Support a non-default cluster domain - perhaps via an environment variable that if set, overrides the hardcoded default of cluster.local (and add that to the helm chart, so that it can be passed in via values as well)
[8 Feb 2023 15:07] MySQL Verification Team
Hi, Thank you for the report
[24 Mar 2024 20:17] Avash Kumar
I am also facing similar issue with mysql operator version v8.3.0-2.1.2. 
As per logs '[ERROR   ] Failed to automatically identify the cluster domain. If this persists try setting MYSQL_OPERATOR_K8S_CLUSTER_DOMAIN via environment.'
Is there any fix available for this.