0

Having:

  • An Openshift Cluster version 4.8.18 running on the Azure Openshift Service

  • A Project in the cluster running a SQL Server 2019 Instance created via oc new-app like so: oc new-app mcr.microsoft.com/mssql/server:2019-latest -e ACCEPT_EULA=Y -e SA_PASSWORD="securepa$$@asdf" --name sqlserver

  • The instance starts properly according to the pod logs and openshift reports OK readiness and liveliness

  • By connecting via oc rsh directly to the container, I am able to interact with the database via sqlcmd

I am trying to connect to the database instance with SSMS v18.10 on Windows 10 via the kubernetes port-forwarding mechanism following this post without success:

oc port-forward pod/sqlserver-aaaaaaaaa-aaaaa 1433:1433

Connections on localhost from SSMS with correct credentials always result in the following error:

Cannot connect to localhost.
Additional information:
A network-related or instance-specific error occured while establishing a connection to SQL Server.
...

Note that:

  • I am trying to connect while the oc port-forward is running
  • I tried disabling the Windows 10 firewall and trying to connect without success
  • I tried port forwarding from a web application and it worked with the firewall on with the same cluster

What am I missing here?

UPDATE 1

I have been able to connect to the SQL Server Instance by creating a service of type LoadBalancer via the External IP created by the service.

asked Jan 23, 2022 at 13:03
4
  • 2
    What settings are you using in SSMS to connect? In the Server name field are you typing 127.0.0.1,1433? Commented Jan 23, 2022 at 21:24
  • 2
    The linked blog entry seems to expose the container's port 1433 in its Kubernetes template with containerPort: 1433. Are you sure you don't need to do something like that with oc new-app? Commented Jan 23, 2022 at 21:25
  • @AlwaysLearning I am connecting with SSMS by specifying localhost, I will give a try to 127.0.0.1,1433 Commented Jan 24, 2022 at 6:37
  • @AlwaysLearning After creating the deployment with oc new-app I am able to confirm that the port exposed on the pod is 1433 Commented Jan 24, 2022 at 6:38

1 Answer 1

1

As mentioned in the linked post and by @AlwaysLearning in the comments, you have to connect by refering to localhost by IP(127.0.0.1) and not by hostname(localhost).

answered Aug 14, 2022 at 8:55

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.