mounted file "is a directory"
Globegitter opened this issue · 8 comments
I am just testing out buildkite running it in google kubernetes engine, following the docs and I am running into issues when wanting to mount in secrets as a file via kubernetes. This is my yaml:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: buildkite-agent
namespace: ci
spec:
replicas: 1
template:
metadata:
labels:
app: buildkite-agent
spec:
containers:
- name: buildkite-agent
image: buildkite/agent:3
imagePullPolicy: Always
securityContext:
privileged: true
env:
- name: BUILDKITE_AGENT_TOKEN
valueFrom: {secretKeyRef: {name: buildkite-agent, key: token}}
- name: BUILDKITE_BUILD_PATH
value: "/home/kubernetes/flexvolume/buildkite/builds"
volumeMounts:
- name: docker-binary
mountPath: /usr/bin/docker
- name: docker-socket
mountPath: /var/run/docker.sock
- name: ssh-keys
mountPath: /root/.ssh/id_rsa
subPath: id_rsa
- name: ssh-keys
mountPath: /root/.ssh/id_rsa.pub
subPath: id_rsa.pub
- name: secrets
mountPath: /home/kubernetes/flexvolume/secrets
- name: buildkite-path
mountPath: /home/kubernetes/flexvolume/buildkite/builds
volumes:
- name: docker-binary
hostPath: {path: /usr/bin/docker}
- name: docker-socket
hostPath: {path: /var/run/docker.sock}
- name: buildkite-path
hostPath: {path: /home/kubernetes/flexvolume/buildkite/builds}
- name: ssh-keys
secret:
secretName: buildkite-agent-ssh
defaultMode: 0400
- name: secrets
secret:
secretName: buildkite-agent-secrets
defaultMode: 0400
Then my pipeline.yml
:
steps:
- label: Build
command: ls -lah /home/kubernetes/flexvolume/secrets && cat /home/kubernetes/flexvolume/secrets/secrets.libsonnet
plugins:
- docker#v3.0.1:
image: "ecosiadev/bazel-circleci:latest"
mount-buildkite-agent: false
propagate-environment: true
additional-groups: ['root']
user: 'root'
volumes:
- "/home/kubernetes/flexvolume/secrets:/home/kubernetes/flexvolume/secrets"
I can see that the secrets file exists in the first ls
but for the cat command I am getting the error cat: /home/kubernetes/flexvolume/secrets/secrets.libsonnet: Is a directory
. I can see that the kubernetes pod has the secrets file and I can read it but I have no idea why it is turned into a directory through this volume mount. Could it be in any way related to #61?
I might not need this functionality to work in the long run as we can also provides secrets differently but I still would like to know what is going on and would like to be able to fix this.
Sorry you had problems getting this going, and the belated reply. Did you have any luck? It sounds like the best way to diagnose it would be to use a vanilla bash script to run the plain Docker commands via the agent, and see the results.
I worked around the issue for now by passing it in as a base64 encoded environment variable and then decoding and storing it into a file in the command. Not nice but it works for now. Otherwise I had to pause progress one our buildkite ci setup for now, but hope to resume soon again.
This is still and issue
when I try to mount something with
volumes:
- "/sourcePath/fileName:/destinationPath/fileName"
And later if I use /destinationPath/fileName it says its a directory. It is not recognizing it as a file.
Sorry @ritvick for the delay. I did a quick look but couldn't reproduce it, are you still having issues? did you have the issue on kubernetes? Thanks!
Hey folks! We did some tests but couldn't reproduce the issue, so I'm closing this. Feel free to re-open this if not. Thanks!
Hi I am still experiencing this issue. I have a file on Docker container of build agent and attempt to mount it as volume as so:
steps:
- label: "Test"
command: "cat /root/.ssh/id_rsa"
plugins:
- docker#v5.9.0:
image: "busybox"
network: "host"
volumes:
- "/root/.ssh/id_rsa:/root/.ssh/id_rsa"
Then will output an error that /root/.ssh/id_rsa
is a directory