#Kubernetes configuration q

1 messages · Page 1 of 1 (latest)

last basalt
#

Hello !

First of all, love dagger & thank you !!

Bit of a noob question here, I've been learning about dagger and been trying to create something tangible and applicable to my work. I've been using the python SDK, and got something working locally - essentially replacing the dockerfile used for building our python aws lambda's.

My question is, i've followed 'docs.dagger.io/integrations/104820/kubernetes/' guide, which is installed in my kubernetes cluster, and have been able to run a dagger query, like in the example in the doc. How can i execute my python/dagger script against that engine ? When i try to, moans that the python script is not in the $PATH, which makes sense, because i'm assuming it's looking for the script in the dagger engine container that is running in kubernetes ? To give more context, i have jenkins set-up in a kubernetes cluster, so all builds are just containers that spin up to do the work, i want to leverage dagger as much as possible into our current set-up.
Not sure if there is any documentation or videos that explain this more ?

Thank you !

naive quail
#

@last basalt - The containers that spin up need to be in a node with the engine and should connect via the socket delivered by the Engine (and why the Helm charts build the engines as a daemon set). To get the spun up container to use the "local" engine (in the pod in that node), you need to set the _EXPERIMENTAL_DAGGER_RUNNER_HOST as an environment variable. From there, the CLI or Dagger client know to use it to connect to the engine.

last basalt
#

Thanks @naive quail, i have done that, here's what's happening:

helm upgrade --install --namespace=dagger --create-namespace dagger oci://registry.dagger.io/dagger-helm
Release "dagger" does not exist. Installing it now.

kc get pods -n dagger (there are more)
NAME READY STATUS RESTARTS AGE
dagger-dagger-helm-engine-52xbr 1/1 Running 0 2m13s

_EXPERIMENTAL_DAGGER_RUNNER_HOST="kube-pod://dagger-dagger-helm-engine-52xbr?namespace=dagger"
export _EXPERIMENTAL_DAGGER_RUNNER_HOST
echo $_EXPERIMENTAL_DAGGER_RUNNER_HOST
kube-pod://dagger-dagger-helm-engine-52xbr?namespace=dagger

dagger query <<EOF
{
container {
from(address:"alpine") {
withExec(args: ["uname", "-a"]) { stdout }
}
}
}
EOF

The query works fine, but when trying to execute my python script for dagger, below:

dagger run jenkins-py-lambda.py
‚ñà [0.83s] connect
┣ [0.59s] starting engine
┣ [0.24s] starting session
┃ OK! █ [0.00s] ERROR jenkins-py-lambda.py
┻
• Engine: dagger-dagger-helm-engine-52xbr (version v0.9.10)
‚ßó 0.96s ‚úî 2 ‚úò 1
exec: "jenkins-py-lambda.py": executable file not found in $PATH

I get the above error, i'm guessing it's because the engine container can't find the .py in it's $PATH ?

#!/home/lkelly/bin/Python-3.12.2/python
import sys
import anyio
import dagger
import os
#from dagger import *
import uuid

async def pipeline():
async with dagger.Connection(dagger.Config(log_output=sys.stderr)) as client:

    src = client.host().directory(".")

    id = str(uuid.uuid4())
    tag = f'dagger-created-booya-{id}'
    py_image = "python:3.8.2-buster"

Am i trying to use this in the wrong way ?

#

thank you !!

#

snippet above of my dagger script

naive quail
#

I'm not a Python dev. But, from my short experience, somehow this doesn't feel right. This is an example of running Jenkins with Dagger.
https://docs.dagger.io/integrations/322019/jenkins

And, in general, can you run this in a pod with the CLI installed (not in the engine pod)?

dagger -m github.com/shykes/daggerverse/hello@v0.1.2 call hello
last basalt
#

That's ok, thank you for responding so far !!

So i've got dagger running locally on my mac (v0.10.2) and my script is working as expected, along with python3 v3.12.2

Just to recap, i've got jenkins running in an eks cluster (AWS), which builds all our code, as it is in kubernetes, we just use pod templates, to spin up containers to build the pipelines etc..

I've created a container in the cluster, and have installed dagger in the container and it works as expected from within that container, logs of this below

logs from contaner

  remoting  workspace
 bash-5.1# dagger version
dagger v0.10.2 (registry.dagger.io/engine) linux/amd64
python3 --version
Python 3.10.14

when running dagger run python3 dagger-scripts/dagger-jenkins.py works as expected, when trying that with the dagger engine pod, i just get the script not found in $PATH error, interstingly, when i try with dagger run py3 (py3 is what it is on another machine) dagger-scripts/dagger-jenkins.py it erros about 'py3' not in $PATH
Thank you

last basalt
#

sorry, running 'dagger -m github..etc..' works fine from the container with the cli installed locally

#

trying the same locally, but with the dagger engine pod in my kubernetes cluster, just seems to time out on intializing

#

logs:

✘ initialize 11m39.6s
Error: input: resolve: moduleSource: asModule: initialize: failed to initialize module: failed to call module "hello" to get functions: call constructor: process "go build -o /runtime ." did not complete successfully: exit code: 1
 
Stderr:
dagger.gen.go:17:2: github.com/99designs/gqlgen@v0.17.31: Get https://proxy.golang.org/github.com/99designs/gqlgen/@v/v0.17.31.mod: dial tcp 209.85.203.141:443: i/o timeout
dagger.gen.go:18:2: github.com/99designs/gqlgen@v0.17.31: Get https://proxy.golang.org/github.com/99designs/gqlgen/@v/v0.17.31.mod: dial tcp 209.85.203.141:443: i/o timeout
querybuilder/marshal.go:11:2: github.com/99designs/gqlgen@v0.17.31: Get https://proxy.golang.org/github.com/99designs/gqlgen/@v/v0.17.31.mod: dial tcp 209.85.203.141:443: i/o timeout
querybuilder/marshal.go:12:2: github.com/99designs/gqlgen@v0.17.31: Get https://proxy.golang.org/github.com/99designs/gqlgen/@v/v0.17.31.mod: dial tcp 209.85.203.141:443: i/o timeout
querybuilder/marshal.go:13:2: github.com/99designs/gqlgen@v0.17.31: Get https://proxy.golang.org/github.com/99designs/gqlgen/@v/v0.17.31.mod: dial tcp 209.85.203.141:443: i/o timeout```

i'm wondering if the network needs to be opened up more ?
naive quail
#

So, if the pod with the CLI isn‘t on the same node as the Dagger engine, the CLI won‘t be able to connect. It needs to connect over the Linux socket local to the node.

glacial forum
# last basalt Hello ! First of all, love dagger & thank you !! Bit of a noob question here,...

hey @last basalt! thx for joining the community and we're happy that you're liking Dagger so far.

re: My question is, i've followed 'docs.dagger.io/integrations/104820/kubernetes/' guide, which is installed in my kubernetes cluster, and have been able to run a dagger query, like in the example in the doc. How can i execute my python/dagger script against that engine ? When i try to, moans that the python script is not in the $PATH, which makes sense, because i'm assuming it's looking for the script in the dagger engine container that is running in kubernetes ? To give more context, i have jenkins set-up in a kubernetes cluster, so all builds are just containers that spin up to do the work, i want to leverage dagger as much as possible into our current set-up.
Not sure if there is any documentation or videos that explain this more ?

couple of comments:

  • I'd recommend using functions (https://dagger.io/blog/introducing-dagger-functions) if you haven't checked that out. It adds lot of benefits to the pipeline execution model.
  • it's very likely that you're getting the $PATH issue because dagger run is very likely changing your path (we need to check if that's an issue). If you run dagger run <full python3 binary location> that should work

Powerful, programmable CI/CD engine that runs your pipelines in
containers — pre-push on your local machine and/or post-push in CI

#

You should also update your kuberentes dagger engine image to the latest dagger version. helm upgrade --install --namespace=dagger --create-namespace dagger oci://registry.dagger.io/dagger-helm --set engine.image.tag=v0.11.1 . We're updating the docs here: https://github.com/dagger/dagger/issues/7105

GitHub

What is the issue? Coming from here: https://discord.com/channels/707636530424053791/1229798907362414673 Looks like our helm chart doesn't really work with the latest version of Dagger and it&#...

naive quail
#

I've upgraded my engines to the latest. 🙂

#

(side rant. It's overdue that Rancher can access OCI repositories for Helm charts. 😠 )

last basalt
#

Thank you both ! sorry, been stuck on other bits, coming back to this today, i'm all for upgrading, it's just that on dagger engine 10.2, i actually have something tangible in python applicable to my work (actually building a python lambda) and it's been working great, so really just trying to get a feel for this in jenkins to leverage daggers properly !