So I've got Minikube running for testing and I dep...
# general
d
So I've got Minikube running for testing and I deploy mariadb through Helm in one stack. In another stack, I need to add my user and database for that app into the instance of mariadb. I'm having DNS resolution problems and I'm trying to find the best solution to access the database in Pulumi. The stack deploying Pulumi is a runner stack and it's designed to run independent but the other stack is an API stack which requires the runner to operate. It's designed so others can run it minimally. Does anyone have a solution so I can access the database in the 2nd stack?
b
Are they different stacks or different projects? They should be different projects since they functionally are deploying different things. But beyond that, you can output your connection string info in the one stack and then access it with a stack reference from the other stack. Have you tried something like that? Might need more info on your DNS problem.
d
They're both different stacks and they're both "subprojects"
b
Can you clarify what you mean by subprojects?
d
Both are submodules of the main git repo which deploys via Tilt with the help of Pulumi. Both have their own Pulumi deployment stuff.
b
Ok I mean in the context of pulumi. They are separate pulumi projects, separate pulumi programs?
d
Idk how to explain
they both have their own Pulumi yaml files
b
Ok so then I would guess they are separate pulumi projects. So what is the error you are getting?
d
A connection refused error because the mysql plugin cannot find "cerus-db-mariadb-primary.cerusbots.svc.cluster.local:3306"
b
That looks like an internal Kubernetes hostname. That's like for a pod that is in the same namespace to access the pod that is running the database. Is that what you are trying to do or are you trying to reach that from outside of the cluster?
d
Yes, I need the mysql Pulumi plugin to proxy into the Kubernetes cluster
b
I think if you want to reach the database from outside the cluster you need to setup an ingress on the cluster that points at the service in front of your database pod. And then from outside the cluster you would point at that ingress
d
Yeah, I'm trying to figure out how to do that
b
you need to expose the the mariadb as a service, can you share how you’ve deployed mariadb? there’s settings on the helm chart to expose it. I’m assuming this is your first foray into kubernetes?
d
I deploy it with the Bitnami help chart as replicated
b
okay but can you share the code you have?
d
https://github.com/CerusBots - repos are API and runner. I've got my most recent additions being pushed soon.
Commits are pushed now
b
i was mainly just looking for the part of the code that has the helm chart values. essentially you just need to change this value: https://github.com/bitnami/charts/blob/master/bitnami/mariadb/values.yaml#L474 expose the service as a
NodePort
and retrieve the address
d
Alright, and how do I get
@pulumi/mysql
to connect to it automatically?
b
you need to pass the address to the provider configuration
if you’re not familiar with Kubernetes, this is going to be a lot of peeling back layers though
d
I've been learning k8s for almost 3 months now
But I'm looking to see if I can get Pulumi to retrieve the IP address automatically
b
Got it. This is all just a kubernetes networking problem
d
Is there a way for Pulumi to retrieve the IP of the NodePort automatically?
b
Yep, there's an example in the docs
d
Where? I've checked and I haven't been able to find it
d
Thanks
Ok, it's almost working
Copy code
Could not connect to server: dial tcp 10.103.26.125:30000: connect: connection timed out
I just need to figure out how to expose the cluster ip
b
That's the minikube node address, it's not routable from your machine
You'll need to read up on how minikube does it's networking
d
Ok, looks like an ingress will work
b
not necessarily, most ingress controllers won’t support tcp
d
I don't see a specific format for the proxy input in the mysql provider.
How do I use the IP on an ingress as a proxy for the mysql plugin which then lets me use "db.internal.cerusbots.test" to access the database?
b
you just use the ingress in your connection string
d
Copy code
entrypoint: `db.internal.cerusbots.test`,
proxy: k8s.core.v1.Service.get( 'cerus-ingress-internal', interpolate`${namespace}/cerus-ingress-internal` ).status.loadBalancer.ingress.apply((ingress) => ingress[0].ip), I have this in my code
It's the configuration for the mysql provider so this will work?
b
what is
db.internal.cerusbots.test
d
A hostname in the ingress
The idea is to use the IP to connect since this ingress is only needed for deployment.
b
Yes I guess I'm confused why you need proxy. I would expect that all you need is
endpoint: "{ingress-ip}:{ingress-port}"
b
I'm not sure how else to say this, but what you're doing is being complicated by the kubernetes networking model and minikube. Both have a networking layer which is making what is usually an easy process very difficult. I would start by understanding how kubernetes networking operates, and how minikube networking works. If you can connect from the machine you're running Pulumi on to your MySQL host with the MySQL command line client, all of this will just work
☝️ 1
d
Because the ingress is trying to send HTTP and not raw TCP packets
b
then ingress isn't the right thing to use
d
I'm not trying to use the mysql command, I'm trying to use the mysql plugin for Pulumi
b
yes but he's saying if you can get it to work with the mysql command it will work with pulumi
d
I've tried everything else
I need a proxy which automatically runs for the duration of Pulumi deploying the stack
And with CI/CD that makes things more complicated since I did get it working with a manual kubectl proxy
b
I think you're thinking about that wrong. What you need to do is deploy temporary resources and destroy them after. You don't need something that automatically runs for X duration. You can spin up a 3rd pulumi project temporarily and then destroy it after
d
I'm not sure how to do that
I've been on this issue all day and so far nothing works the way I need it to
b
I wouldn't worry about how you destroy your temporary resources until after you get your connection working
d
Ok, and how should I do the connection?
I've tried NodePorts, LoadBalancers, and Ingresses
b
d
That looks like what I've already tried
🤷‍♂️ 1
b
For the third time, nodeport is not working because of minikube. Minikube creates a VM which is not routable from where you are running Pulumi by default
I don't know how else to say it. I'm going to mute this thread because it's going nowhere
d
I was hoping to use a proxy to do that, and how can I get the IP I need to use automatically?
m
apologies if I’ve missed something in skimming this thread but - @dazzling-spring-78843 you would have to expose a routable ip on the host in order to access your nodeport/ingress/whatever via
minikube tunnel
this could be cumbersome to automate because the tunnel runs as a separate process. have a read of this: https://minikube.sigs.k8s.io/docs/handbook/accessing/
for automation it may be preferable to switch to something like
kind
over minikube because you can configure exposure on the host network from file: https://kind.sigs.k8s.io/docs/user/configuration/#networking