Reputation: 495
developing an ASP.NET Core 3.0 application, with centralized MySQL Database.
I am using a Connection String, which looks like this:
Server=mysql;Database=db-name;Uid=User;Pwd=Pass;SslMode=Preferred;persistsecurityinfo=false;
"mysql" is an internal DNS Record, which points to the central MySQL Server. In Visual Studio, it works fine.
Now I want to deploy it to kubernetes.
I already did that with MSSQL successfully. I created an endpoint (ep) in kubernetes, pointing to the correct IP:
Name: mysql
Namespace: my_namespace
Labels: <none>
...
Subsets:
Addresses: 192.168.6.200
NotReadyAddresses: <none>
Ports:
Name Port Protocol
---- ---- --------
mysql 3306 TCP
Events: <none>
And I created a corresponding Kubernetes service:
Name: mysql
Namespace: my_namespace
Labels: <none>
...
Selector: <none>
Type: ClusterIP
IP: 10.104.84.99
Port: mysql 3306/TCP
TargetPort: 3306/TCP
Endpoints: 192.168.6.200:3306
Session Affinity: None
Events: <none>
All this looks like the stuff I did with MSSQL.
And I could confirm the working networking:
root@kubernetes-server:/application# kv exec application-7c85b5d9d8-9vxhb -- curl mysql:3306
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:04 --:--:-- 0J
100 115 0 115 0 0 25 0 --:--:-- 0:00:04 --:--:-- 25#08S01Got packets out of order
"Got packets out of order" is definately a response from the MySQL server. I also could confirm that via Wireshark.
But the application will not run. I get the error: "Unable to connect to any of the specified MySQL hosts."
Did I do something wrong?
Greetings, xola
Upvotes: 0
Views: 815
Reputation: 495
Got it. It wasn't the Connection String. Unfortunately, I did't see the errors prior to that error message. Since we encrypt the connection string, we have a key for decryption. The decrypt-key was not correctly set, so the application wanted to set up a connection using the encrypted, not the decrypted Connection String.
But thank you anyway!
Upvotes: 1