Question

Is possible to connect a DO K8s cluster with a DO Droplet private network?

Hi there, folks.

I do have a 3-node-sized DO K8s cluster (for my apps and services), and a DO Droplet that runs my PostgreSQL. I’m planning on connecting them together using a K8s external service pretty much like this article here.

But I don’t want to use a external IP connection to do so, I want to block external IPs from accessing my Postgres, and then connect my K8s cluster and my Postgres using a DO private network.

I know how to setup this network for my Postgres Droplet, but I don’t see such option for my K8s cluster. Is there a way to join my cluster into this network? Any documentation on this subject?

Any help? Thanks!


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Works for me!

Your database server must be in same region (eg. NYC1) as your kubernetes cluster.

Make sure your database server only listening to the private IP address of your droplet (not public IP).

---
kind: Service
apiVersion: v1
metadata:
  name: mysql
spec:
  ports:
    - name: mysql
      port: 3306
      targetPort: 3306

---
kind: Endpoints
apiVersion: v1
metadata:
  name: mysql
subsets:
  - addresses:
      - ip: PRIVATE.IP.OF.DATABASE.DROPLET
    ports:
      - name: mysql
        port: 3306

I just made this this weekend. We don’t need any extra stuff here, for connecting pods to a droplet database.

Ensure the k8s cluster is in the same region of the droplets you want to connect.

Ensure that the firewall of the DB droplet is well configured.

The issue i was having was because, the pool of nodes for k8s cluster was not having the tag it should have to pass the firewall.

Once i added the tag to the pool, all nodes of that pool inherit the tag, and the private connections started to work.

DO support replied me:

Kubernetes clusters use their own overlay network so it wouldn’t be possible to connect other Droplets to the cluster; you would have to expose a service on the cluster, through a Load Balancer typically, to be able to access the service from outside the cluster.

So I think that answers the question.