https://pulumi.com logo
#general
Title
# general
d

dazzling-spring-78843

07/30/2022, 7:57 PM
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

bored-oyster-3147

07/30/2022, 11:13 PM
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

dazzling-spring-78843

07/30/2022, 11:14 PM
They're both different stacks and they're both "subprojects"
b

bored-oyster-3147

07/30/2022, 11:15 PM
Can you clarify what you mean by subprojects?
d

dazzling-spring-78843

07/30/2022, 11:17 PM
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

bored-oyster-3147

07/30/2022, 11:17 PM
Ok I mean in the context of pulumi. They are separate pulumi projects, separate pulumi programs?
d

dazzling-spring-78843

07/30/2022, 11:18 PM
Idk how to explain
they both have their own Pulumi yaml files
b

bored-oyster-3147

07/30/2022, 11:19 PM
Ok so then I would guess they are separate pulumi projects. So what is the error you are getting?
d

dazzling-spring-78843

07/30/2022, 11:20 PM
A connection refused error because the mysql plugin cannot find "cerus-db-mariadb-primary.cerusbots.svc.cluster.local:3306"
b

bored-oyster-3147

07/30/2022, 11:23 PM
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

dazzling-spring-78843

07/30/2022, 11:24 PM
Yes, I need the mysql Pulumi plugin to proxy into the Kubernetes cluster
b

bored-oyster-3147

07/30/2022, 11:25 PM
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

dazzling-spring-78843

07/30/2022, 11:35 PM
Yeah, I'm trying to figure out how to do that
b

billowy-army-68599

07/30/2022, 11:57 PM
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

dazzling-spring-78843

07/30/2022, 11:57 PM
I deploy it with the Bitnami help chart as replicated
b

billowy-army-68599

07/30/2022, 11:58 PM
okay but can you share the code you have?
d

dazzling-spring-78843

07/31/2022, 12:04 AM
https://github.com/CerusBots - repos are API and runner. I've got my most recent additions being pushed soon.
Commits are pushed now
b

billowy-army-68599

07/31/2022, 12:10 AM
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

dazzling-spring-78843

07/31/2022, 12:11 AM
Alright, and how do I get
@pulumi/mysql
to connect to it automatically?
b

billowy-army-68599

07/31/2022, 12:12 AM
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

dazzling-spring-78843

07/31/2022, 12:13 AM
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

billowy-army-68599

07/31/2022, 12:14 AM
Got it. This is all just a kubernetes networking problem
d

dazzling-spring-78843

07/31/2022, 12:21 AM
Is there a way for Pulumi to retrieve the IP of the NodePort automatically?
b

billowy-army-68599

07/31/2022, 12:21 AM
Yep, there's an example in the docs
d

dazzling-spring-78843

07/31/2022, 12:23 AM
Where? I've checked and I haven't been able to find it
d

dazzling-spring-78843

07/31/2022, 12:31 AM
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

billowy-army-68599

07/31/2022, 2:34 AM
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

dazzling-spring-78843

07/31/2022, 2:36 AM
Ok, looks like an ingress will work
b

billowy-army-68599

07/31/2022, 2:51 AM
not necessarily, most ingress controllers won’t support tcp
d

dazzling-spring-78843

07/31/2022, 2:53 AM
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

bored-oyster-3147

07/31/2022, 3:32 AM
you just use the ingress in your connection string
d

dazzling-spring-78843

07/31/2022, 3:34 AM
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

bored-oyster-3147

07/31/2022, 3:35 AM
what is
db.internal.cerusbots.test
d

dazzling-spring-78843

07/31/2022, 3:35 AM
A hostname in the ingress
The idea is to use the IP to connect since this ingress is only needed for deployment.
b

bored-oyster-3147

07/31/2022, 3:42 AM
Yes I guess I'm confused why you need proxy. I would expect that all you need is
endpoint: "{ingress-ip}:{ingress-port}"
b

billowy-army-68599

07/31/2022, 3:43 AM
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

dazzling-spring-78843

07/31/2022, 3:43 AM
Because the ingress is trying to send HTTP and not raw TCP packets
b

bored-oyster-3147

07/31/2022, 3:44 AM
then ingress isn't the right thing to use
d

dazzling-spring-78843

07/31/2022, 3:44 AM
I'm not trying to use the mysql command, I'm trying to use the mysql plugin for Pulumi
b

bored-oyster-3147

07/31/2022, 3:44 AM
yes but he's saying if you can get it to work with the mysql command it will work with pulumi
d

dazzling-spring-78843

07/31/2022, 3:44 AM
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

bored-oyster-3147

07/31/2022, 3:46 AM
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

dazzling-spring-78843

07/31/2022, 3:47 AM
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

bored-oyster-3147

07/31/2022, 3:50 AM
I wouldn't worry about how you destroy your temporary resources until after you get your connection working
d

dazzling-spring-78843

07/31/2022, 3:51 AM
Ok, and how should I do the connection?
I've tried NodePorts, LoadBalancers, and Ingresses
b

bored-oyster-3147

07/31/2022, 3:54 AM
d

dazzling-spring-78843

07/31/2022, 3:55 AM
That looks like what I've already tried
🤷‍♂️ 1
b

billowy-army-68599

07/31/2022, 4:06 AM
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

dazzling-spring-78843

07/31/2022, 4:08 AM
I was hoping to use a proxy to do that, and how can I get the IP I need to use automatically?
m

mammoth-garden-53682

07/31/2022, 5:54 AM
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
24 Views