Open jonathanyuechun opened 2 years ago
this issue can easily be replicated using the gitlab-ci.yml below
stages:
- test
variables:
DOCKER_TLS_CERTDIR: ""
DOCKER_DRIVER: overlay2
stages:
- test-cluster
test-cluster:
image: docker:stable
variables:
KUBECTL: v1.21.3
stage: test
services:
- docker:stable-dind
before_script:
- apk add -U wget bash curl
# install kubectl
- wget -O /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBECTL}/bin/linux/amd64/kubectl
- chmod +x /usr/local/bin/kubectl
# install k3d
- wget -q -O - https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash
- k3d help
- k3d version
- k3d cluster create testgitlabci --agents 1 --servers 1 --servers-memory 1g --agents-memory 1g --wait
- kubectl cluster-info
script:
# Display initial pods, etc.
- kubectl get nodes -o wide
- kubectl get pods --all-namespaces -o wide
- kubectl get services --all-namespaces -o wide
after_script: ['k3d cluster delete testgitlabci']
Hi @jonathanyuechun thanks for creating this issue!
I may have missed it, but can you please share the actual error you're seeing? Any logs would be helpful 👍
@iwilltry42 no problem. Below are the logs
INFO[0000] Prep: Network
INFO[0000] Created network 'k3d-metascheduler-1585478' (18a6fca94d647768ec6e24cf2aa72b99e3fce173d06960a6b3876411aaf1fc71)
INFO[0000] Created volume 'k3d-metascheduler-1585478-images'
INFO[0001] Creating node 'k3d-metascheduler-1585478-server-0'
INFO[0010] Deleted 57fd0275f6374f899d2b61473b364cd792f80349d8abef83e0862851e4e10585
INFO[0010] Creating node 'k3d-metascheduler-1585478-agent-0'
INFO[0011] Deleted 1b487364c7e3ce551755bbfa9c99db67118326f93824ef22b32befc472bc3607
INFO[0011] Creating LoadBalancer 'k3d-metascheduler-1585478-serverlb'
INFO[0011] Starting cluster 'metascheduler-1585478'
INFO[0011] Starting servers...
INFO[0011] Starting Node 'k3d-metascheduler-1585478-server-0'
ERRO[0012] Failed to start node 'k3d-metascheduler-1585478-server-0'
ERRO[0012] Failed Cluster Start: Failed to start server k3d-metascheduler-1585478-server-0: Error response from daemon: OCI runtime create failed: container_linux.go:370: starting container process caused: process_linux.go:459: container init caused: rootfs_linux.go:59: mounting "/root/.k3d/.k3d-metascheduler-1585478-server-0/meminfo" to rootfs at "/var/lib/docker/overlay2/536b6a4245ca21f398d17f9778a2f348f7d129d3e6e7fb89ab1de8aa9ee740ba/merged/proc/meminfo" caused: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERRO[0012] Failed to create cluster >>> Rolling Back
INFO[0012] Deleting cluster 'metascheduler-1585478'
INFO[0012] Deleted k3d-metascheduler-1585478-server-0
INFO[0012] Deleted k3d-metascheduler-1585478-agent-0
INFO[0012] Deleted k3d-metascheduler-1585478-serverlb
INFO[0012] Deleting cluster network 'k3d-metascheduler-1585478'
INFO[0012] Deleting image volume 'k3d-metascheduler-1585478-images'
FATA[0012] Cluster creation FAILED, all changes have been rolled back!
@iwilltry42 any news about it or workaround ?
Hey @jonathanyuechun I just got back to this now and did a quick Google search, which turned up this issue: https://stackoverflow.com/a/66470542/6450189 Can you please give the suggested change (related to DIND in GitlabCI) a try?
@iwilltry42 the proposed solution is not to use DinD, which is not possible on my ends...
Googling for it, this issue is all around for Gitlab CI DIND runners :thinking: I guess it is because k3d is running in one container (c1) but talking to the Docker Daemon in another (dind) container (c2). In that case, k3d would create the faked meminfo file in c1, which is then not available in c2. I don't see many ways around that... except for some that do not rely on mounting a file (i.e. changing k3d code). You could however do the following ugly trick:
Hi thanks for the hack, this was what i thought at the beginning, sadly i don't have direct access to the runner itself. How about k3d itself integrate a new cmd:
k3d fake --agents 1 --servers 1 --servers-memory 1g --agents-memory 1g > myFakeMemInfo
k3d create cluster --agents 1 --servers 1 --servers-memory 1g --agents-memory 1g --meminfo-path myFakeMemInfo
Would this make sense ?
I guess as a feature request, we could change the code to not use a file mount but rather just write the file directly into the container filesystem using a pre-start hook. I'll add it to a future milestone.
How would your proposals help you though? You'd still have to get the fake meminfo file into the docker host (the GItLab service container), right? If you can do that, then you can as well do cat << EOF > /file/on/servicecontainer ... EOF
in your GitLab CI pipeline and use the --volume
flag as proposed above :thinking:
hi sorry for late reply !
Hmmn, to answer your question. I probably messed up my thinking :(
Hi again,
For information, the same bug can easily be reproduced using devcontainers tool from vscode.
What did you do
CI image: docker:20.10.2 and docker:20.10.2-dind as service
error with k3d v5.4.3
error with k3d v4.4.8
The same error will happen with v4.4.8 unless memory arguments are not set
What did you expect to happen
Concise description of what you expected to happen after doing what you described above.
Screenshots or terminal output
If applicable, add screenshots or terminal output (code block) to help explain your problem.
Which OS & Architecture
Ubuntu 18.04 LTS
Which version of
k3d
k3d version
v5.4.3
v4.4.8
Which version of docker
docker version
anddocker info
Note: Running k3d on a native linux platform works as expected...