Closed joebullard closed 5 years ago
this seems to be a known issues with kubernetes. I was able to find this issue: https://github.com/kubernetes/kubernetes/issues/48912
I would caution against using the kubernetes runtime in production. The kubernetes runtime is labeled experimental (hopefully the docs convey this) which means it is not production ready and could (hypothetically) be removed in a future version. We are actively considering replacing it with a Tekton runner, for example. I recommend reading https://github.com/drone/drone-runtime/issues/65 and https://github.com/drone/drone-runtime/issues/69 to get a better sense of the state of native kubernetes.
Thanks @bradrydzewski. I'm currently just experimenting with the k8s-native setup in parallel with our team's server/agent production setup. I guess I'll hold out for the future updates
the kubernetes implementation in this repository was scrapped for reasons described here. We have a new implementation, created from scratch, that no longer mounts a host machine volume which obsoletes this issue. New codebase can be found here: https://github.com/drone-runners/drone-runner-kube
I tested to confirm it is fixed:
$ cat .drone.yml
kind: pipeline
type: kubernetes
name: default
clone:
disable: true
steps:
- name: test
pull: if-not-exists
image: alpine
commands:
- echo "echo hello" > foo.sh
- chmod +x foo.sh
- ./foo.sh
$ drone-runner-kube exec --kubeconfig=$HOME/.kube/config
[test:1] + echo "echo hello" > foo.sh
[test:2] + chmod +x foo.sh
[test:3] + ./foo.sh
[test:4] hello
Context
I am running Drone 1.0 in Kuberentes-native mode after using Drone 0.8 for 1-2 years.
I noticed that I am unable to execute any scripts within my repository code or any of it's dependencies (e.g. certain packages installed from
npm install
), despite those files having the proper executex
permissions. This is a necessary part of my workflow and I would assume for many others as well.My understanding is this:
/drone/src
on each step of that pipelinenoexec
flag, which prevents execution of anything in that mountpoint, regardless of thex
permission flag on the files.How to reproduce
Here is a trivial
.drone.yml
which illustrates the underlying issue (though I discovered this in an uglier way withnpm install
).drone.yml
Output
You can see that
/drone/src
mountpoint has thenoexec
flag set:You can also see that the
/bin/sh
, which resides in a partition without thenoexec
flag, is executable, while the dummy script I made within/drone/src
is not, even though it has executable permissions on the file.Ideas?
Is there a simple way to mount this without the
noexec
flag? A cursory look through the Drone source code and the k8s API Go documentation did not reveal an explicit setting of this flag (though I am a Go noob and have never peaked into the Drone source before this).It seems though that this may be imposed by k8s itself, since we are using the
tmpfs
, but I found that in other Docker applications likedocker-compose
, you can override mount flags. Perhaps the same is possible for the k8s API and someone with more experience would be able to do it easily.