I have a MariaDB/MySQL cluster deployed in Kubernetes w/ Istio injection enabled in the namespace. The database cluster works fine. The primary server is running on port 3306 with mariadb-primary
as the service name.
I would like to externally connect to my MariaDB instance using DNS (e.g. mariadb.example.com
), but am not able to make it works & I can’t seem to find the answer anywhere.
What I have so far:
Default gateway, deployed in istio-system
.
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
namespace: istio-system
name: default-gateway
spec:
selector:
istio: ingressgateway # use istio default controller
servers:
- port:
number: 3306
name: mysql
protocol: TCP
hosts:
- "*"
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
tls:
httpsRedirect: true
MariaDB deployment (only VirtualService part)
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: mariadb
namespace: mariadb
spec:
hosts:
- mariadb.example.com
gateways:
- istio-system/default-gateway
tcp:
- match:
- port: 3306
route:
- destination:
host: mariadb-primary # Name of the service
port:
number: 3306
When I try to connect to mariadb.example.com:3306
however it does not work (connection refused).
Any help appreciated!!