architecture: replication dns issue
Describe your Issue
When in replication mode for MariaDB, the mariadb-isalive container does not find the correct maria instance. It is looking for <ns-name>-mariadb when I would assume it should be looking for <ns-name>-mariadb-primary?. Because of this, the container will never end the initialization stage.
I would assume the externalDatabase.host value could change where mariadb-isalive is looking, but it does not.
I did create a bandaid solution, but I assume everyone would like this to work out of the box.
NOTE: The concept of this issue also exists with postgresql.
Describe your Environment
-
Kubernetes distribution: k3s
-
ArgoCD version v2.7.6+00c914a.dirty
-
Helm Chart Version: current with what's in master branch
Relevant parts of values.yaml:
...
internalDatabase:
enabled: false
externalDatabase: # needs to be true in orded to use mariadb (see commends in original values.yaml)
enabled: true
host: nextcloud-mariadb-primary # (currently does not change where mariadb-isalive is searching)
mariadb:
enabled: true
architecture: replication
primary:
persistence:
enabled: true
size: 8Gi
...
Logs from mariadb-isalive
│ ERROR 2005 (HY000): Unknown server host 'nextcloud-mariadb' (-2) │
│ waiting for mysql │
│ ERROR 2005 (HY000): Unknown server host 'nextcloud-mariadb' (-2) │
│ waiting for mysql │
│ ERROR 2005 (HY000): Unknown server host 'nextcloud-mariadb' (-2) │
│ waiting for mysql │
│ ERROR 2005 (HY000): Unknown server host 'nextcloud-mariadb' (-2) │
│ waiting for mysql │
│ ERROR 2005 (HY000): Unknown server host 'nextcloud-mariadb' (-2) │
│ waiting for mysql │
│ ERROR 2005 (HY000): Unknown server host 'nextcloud-mariadb' (-2) │
│ waiting for mysql │
│ ERROR 2005 (HY000): Unknown server host 'nextcloud-mariadb' (-2) │
│ waiting for mysql
Namespace state
Bandaid Solution
I was able to fix the dns issue by adding a headless service that pointed to the primary instance of the database.
apiVersion: v1
kind: Service
metadata:
name: nextcloud-mariadb
namespace: nextcloud
spec:
clusterIP: None
clusterIPs:
- None
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- name: mariadb
port: 3306
protocol: TCP
targetPort: mariadb
selector:
app.kubernetes.io/component: primary
app.kubernetes.io/instance: nextcloud
app.kubernetes.io/name: mariadb
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
Thanks for submitting this issue! It looks similar to https://github.com/nextcloud/helm/issues/406 I haven't had a chance to create a PR, but if you have time, this is what needs to be done, I think: https://github.com/nextcloud/helm/issues/406#issuecomment-1630775018