Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to pass Kubernetes volumeMount into container #114

Closed
gazzer82 opened this issue Mar 27, 2018 · 7 comments
Closed

Unable to pass Kubernetes volumeMount into container #114

gazzer82 opened this issue Mar 27, 2018 · 7 comments

Comments

@gazzer82
Copy link

I have a JSON file that's stored in a Kubernetes secret that's shared with my the Buildagent with the following config.

- mountPath: /root/docker.json
          name: docker-login
          subPath: docker.json

The file is a JSON key for a Kubernetes service account, so obviously not wanting to bake it into any of my images.

I'm using the file within a script to build/push an image using docker push as follows and this works fine.

docker login -u _json_key -p "$(cat /root/docker.json)" https://eu.gcr.io

But I have a docker compose step using this plugin where I load up a pre-built image that contains Gcloud and Kubectl so I can update the deployment to the latest build version, and I need this key file to be able to login, but I can't seem to get the volume to mount with my docker compose file, I'm using the following.

volumes:
      - /root/docker.json:/base/kube/docker.json

But it always throws and error about not being able to create the folder, so seems the docker-compose plugin is not able to see/access the mounted file.

Error response from daemon: error while creating mount source path '/root/docker.json': mkdir /root/docker.json: read-only file system

Not sure how to resolve this?

@torbjornvatn
Copy link

torbjornvatn commented Apr 13, 2018

I'm experiencing something similar trying to follow your golang in docker example.
I get this error in the logs:

Running command in Docker Compose service: app

docker-compose -f docker-compose.yml -p buildkitedfb3eabc02b84a13b8fd25b13b22a459 run --name buildkitedfb3eabc02b84a13b8fd25b13b22a459_app_build_23 app ./scripts/build.sh

Error response from daemon: error while creating mount source path '/buildkite/builds/bk-agent-buildkite-78845d9f56-lxz2j/unacast/walrus': mkdir /buildkite: read-only file system

I'm running the agent on Kubernetes installed via your helm chart

I also got the same error when I tried the docker plugin

@lox
Copy link
Contributor

lox commented Apr 14, 2018

The key part here is read-only file system. If you look at the output of mount you will see that the Google Container OS mounts the root filesystem as read-only.

Docker will try and create the source path if it doesn't exist, which will fail on a read-only filesystem. I suspect the answer is to avoid host mounts and go for mounting volumes in Kubernetes, but I'd love to hear from an expert. We'll do some testing of our own.

@lox
Copy link
Contributor

lox commented Apr 14, 2018

I'm trying to figure out where the /buildkite comes from. I suspect if we used something like /opt/buildkite it would solve the problem. I assume you are both running buildkite-agent as a docker container?

@lox
Copy link
Contributor

lox commented Apr 14, 2018

@gazzer82 are you sure that /root/docker.json actually exists?

@gazzer82
Copy link
Author

gazzer82 commented Apr 14, 2018 via email

@torbjornvatn
Copy link

Seem like @lox figured this out over in buildkite/agent#729 (comment)

@toolmantim
Copy link
Contributor

Yep, see buildkite/agent#729

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants