#Running Dagger in K8S
1 messages ยท Page 1 of 1 (latest)
Did you checkout this guide about running dagger on kubernetes: https://docs.dagger.io/194031/kubernetes#introduction.
Yes but we are not using it for CI the goal here is to be able to run dagger with an execSync from a typescript worker
I managed to have another error now, but if I go in the container and check the /usr/local/bin nerdctl is here
failed to run container: time="2023-11-22T11:35:09Z" level=fatal msg="failed to create shim task: failed to create init process I/O: 1 error occurred:\n\t* failed to start binary process: fork/exec /usr/local/bin/nerdctl: no such file or directory\n\n: unknown"
: exit status 1
I understand. However, this sections should be still valid for k8s deployments: https://docs.dagger.io/194031/kubernetes#step-4-deploy-the-dagger-engine-daemonset-with-helm-v3
...
env:
- name: _EXPERIMENTAL_DAGGER_RUNNER_HOST
value: unix:///var/run/dagger/buildkitd.sock
...
volumeMounts:
- name: dagger-socket
mountPath: /var/run/dagger
volumes:
- name: dagger-socket
hostPath:
path: /var/run/dagger
did you make this to your workload to access dagger host?
When you deploy dagger as a deamon set, all nodes should have unix:///var/run/dagger/buildkitd.sock and /var/run/dagger paths and ideally it should work.
Dagger is installed inside the Docker and not the host
However this error suggest your pod doesn't have nerdctl or don't have permissions.
But yes if I continue to fail using dagger without creating a daemonset, I will use a daemonset :
:/
I was talking about k8s nodes. even in docker you should have them
if you share more details about your setup I can have a look. Can't tell too much from this snippets
Not sure I understand, today I have installed docker inside the dockerfile and not in the host.
This is the dockerfile
ARG CONTAINERIZED_SYSTEMD_VERSION=v0.1.1
ARG CONTAINER_BASE="containerd"
FROM ghcr.io/containerd/nerdctl:main AS containerd-base
amd64.tar.gz
ENV NODE_VERSION=18
RUN apt-get update && apt-get install -y ca-certificates curl gnupg
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_VERSION.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
RUN apt-get update && apt-get install nodejs -y
RUN node --version
RUN npm --version
RUN chmod +x /usr/local/bin/nerdctl
RUN ln -s `which nerdctl` /usr/local/bin/docker
systemd/${CONTAINERIZED_SYSTEMD_VERSION}/docker-entrypoint.sh && \
/usr/local/lib/systemd/system/*.service && \
FROM node:18-bullseye AS docker-base
COPY --from=docker:latest /usr/local/bin/docker /usr/local/bin/
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH=${HOME}/.bun/bin:${PATH}
FROM ${CONTAINER_BASE}-base AS builder
WORKDIR /app
RUN npm i -g turbo
COPY . .
RUN turbo prune --scope=@animaapp/scoring-worker --docker
# Add lockfile and package.json's of isolated subworkspace
FROM ${CONTAINER_BASE}-base AS installer
WORKDIR /
RUN curl -sfL https://releases.dagger.io/dagger/install.sh | sh
...
If you want we could jump over dev-audio and pair on this.
It would be amazing, I will grabe something to eat and we can see that this afternoon if this is ok for you ?
sure ๐ , I'm planning to go outside of the office in the afternoon but I'm sure we can find a suitable time
Hey I'm available if you want @dire escarp
I'll be in 15~30 min. will ping you
@silver wraith I have 20~30 min free time if you're available
Still available @dire escarp, I'm now
Thanks for the help @dire escarp , now when running a pod and the daemonset and get this:
new client: remote is not a valid dagger server (expected "github.com/dagger/dagger", got "dagger-dagger-helm-engine-9nl4g")
Not sure if I need to override the name of the daemonset but it seems weird to do that
@woven fable @half crow @oblique rapids have you seen this sort of error? ๐
This sort of use case? #1176841586089398292 message
@silver wraith does it look to you like this issue?
https://github.com/dagger/dagger/pull/5957/
Perhaps you can try with this PR and see if it fixes your issue ๐
@silver wraith can you check that the image tag is using dagger 0.9.0 or higher?
yes, this seems to be the issue
cc @silver wraith you need to bump your helmchart image match your dagger version in your code/CLI
Ok thx, will try that and keep you up to date
It finally seems to be working like that thank you all !
A small question on this but if I have 10 workers using only 2 dagger engine is it ok ?
as long as all the dagger tasks land in those two workers, that's fine
since the way the helm chart is designed is for the engines to run as a DaemonSet and connect via unix socket which will require all dagger jobs/pods to be scheduled in worker nodes where that DaemonSet is present
By the way I'm receiving a lot of this error any idea how it could happen ?
UnknownDaggerError: Encountered an unknown error while requesting data via graphql
@silver wraith maybe missing an await somewhere? #pro7sat message
https://github.com/dagger/dagger/issues/4386
Just double checked and I don't see anything not awaited
This is the build that I'm using
Not getting those errors so much. Did setup like this.
In a new directory with your build.mts in there:
npm install ts-node typescript --save-dev
npx tsc --init --module esnext --moduleResolution nodenext
npm install @dagger.io/dagger@latest --save-dev
dagger run node --loader ts-node/esm ./build.mts
[1.81s] exec docker-entrypoint.sh sh -c npm run build; echo -n $? > ./exit_code
โ npm ERR! Missing script: "build"
โ npm ERR!
โ npm ERR! To see a list of scripts, run:
โ npm ERR! npm run
โ
โ npm ERR! A complete log of this run can be found in: /app/.npm/_logs/2023-11-24T20_40_35_295Z-debu
โ g-0.log
โ [0.09s] exec docker-entrypoint.sh echo Build failed
โ Build failed
โ [0.09s] exec docker-entrypoint.sh cat ./tmp/logs
โ npm ERR! Missing script: "build"
โ npm ERR!
โ npm ERR! To see a list of scripts, run:
โ npm ERR! npm run
โ
โ npm ERR! A complete log of this run can be found in: /app/.npm/_logs/2023-11-24T20_40_35_295Z-debu
โ g-0.log
โ [0.01s] export file /app/tmp/logs to host ./logs.log
โ [8.78s] ERROR node --loader ts-node/esm ./build.mts
โ (node:958) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change a
โ any time
โ (Use `node --trace-warnings ...` to show where the warning was created)
โ Running test...
โ Build Graphql Runner error: GraphQLRequestError: lstat /app/bun.lockb: no such file or directory
โ [0.00s] ERROR file(path: "./bun.lockb")
โป
โข Engine: 3b6f7d2772be (version v0.9.3)
โง 10.06s โ 48 โ
1 โ 2
exit status 1
but I don't have a "build" script in my package.json
By the way I run it with dagger run bun ./build.mts do you think it can be related ?
ah. could be.
I just cleared all errors incrementally (with no other objective than to clear errors ๐ ) by:
- adding a dummy build script
"scripts": { "build": "echo build; exit 0" } - adding needed directory
mkdir dist - adding file that was complained about
touch ./bun.lockb
Maybe that will help you find the issue...
I know we haven't tested our Node.js SDK with Bun, Deno, etc, though some folks have made various things work for them.
@silver wraith oh, you're using bun? Well.. that might explain some things
can you try if that happens with node?
Yes I'm making the change and trying to see if I see the same errors
Oh never updated sorry
Everything working fine now, it seems that bun is not working
๐ thx
Creating a bun channel in the Dagger AND... section. cc @native pine
Here is a list of commands to:
- One line install of Dagger Engine to K8s (currently
v0.9.3, which is latest released) - Run a module in the Dagger Engine on K8s
- Downgrade to Dagger Engine
v0.9.2-gpu(there is nov0.9.4to upgrade just yet) - Run the same module in the downgraded Dagger Engine
- Clean everything up
Let me know if this is helpful to you @silver wraith
Thanks @errant fox for helloSecret! FWIW https://daggerverse.dev/mod/github.com/jpadams/daggerverse/helloSecret@68b6243b2e981126dbd397d836776573efae0d6e
I'm curious what would be more interesting as a next step for you @silver wraith?
A. Expand the above into a blog post on https://dagger.io/blog
B. Record a short video (2-3 mins)