# Plugin entrypoint.sh not executed in kubernetes

**URL:** <https://drone.discourse.group/t/plugin-entrypoint-sh-not-executed-in-kubernetes/10336>\
**Category:** Drone Support\
**Created:** [June 4, 2020, 9:26am UTC](https://drone.discourse.group/t/plugin-entrypoint-sh-not-executed-in-kubernetes/10336 "2020-06-04T09:26:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![waterdrop01](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/waterdrop01/32/5035_2.png) [@waterdrop01](https://drone.discourse.group/u/waterdrop01)\
**Post date:** [June 4, 2020, 9:26am UTC](https://drone.discourse.group/t/plugin-entrypoint-sh-not-executed-in-kubernetes/10336/1 "2020-06-04T09:26:45Z")

</div>

Hello there.

I encounter the following problem: My plugin’s docker entrypoint (plugin.sh) is never executed.

Here is my plugin `Dockerfile`:

```
FROM alpine
RUN apk add --no-cache curl make git bash
COPY kustomize /usr/bin/
COPY plugin.sh /drone/
RUN curl -Lo /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.18.3/bin/linux/amd64/kubectl && chmod +x /usr/bin/kubectl
ENTRYPOINT ["/drone/plugin.sh"]

```

And here is my `plugin.sh`:

```
#!/bin/sh

set -euo pipefail
PLUGIN_DEBUG=true

if [[-z "${PLUGIN_KUBECONFIG}"]]; then
  echo "no PLUGIN_KUBECONFIG variable"
else
  mkdir -p $HOME/.kube
  echo "$PLUGIN_KUBECONFIG" > $HOME/.kube/config
  export KUBECONFIG=$HOME/.kube/config
fi

```

In my case, drone is deployed on Kubernetes. My pipeline looks like this:

```
kind: pipeline
type: kubernetes
name: default

steps:
  - name: deploy
    image: my/registry/k8s-drone-plugin:v1.0.1
    settings:
      kubeconfig:
        from_secret: kubeconfig
    commands:
      - kubectl version && kustomize version <-- this WORKS
      - echo $PLUGIN_KUBECONFIG <-- this WORKS
      - echo $KUBECONFIG <-- This env var is EMPTY (even though it's defined in plugin.sh)!
      - cat ~/.kube/config <-- This gives an error: "cat: can't open '/root/.kube/config': No such file or directory"
      - kubectl get pods <-- permission error, that's normal because ./kube/config is missing.

image_pull_secrets:
  - dockerconfig

```

Also, I can see that the image run in kubernetes is not `my/registry/k8s-drone-plugin:v1.0.1` but `drone/placeholder:1` ([https://hub.docker.com/r/drone/placeholder](https://hub.docker.com/r/drone/placeholder)).

When I test the docker image locally, the script `plugin.sh` works.

Clearly, my `plugin.sh` script is never run…Any idea why?

Thanks a lot for you help!

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [June 4, 2020, 12:00pm UTC](https://drone.discourse.group/t/plugin-entrypoint-sh-not-executed-in-kubernetes/10336/2 "2020-06-04T12:00:48Z")

</div>

when you declare a `commands` section, the commands are executed as your container entrypoint and thus override the entrypoint defined in the image.

---

<div class="post-metadata">

**Author:** ![waterdrop01](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/waterdrop01/32/5035_2.png) [@waterdrop01](https://drone.discourse.group/u/waterdrop01)\
**Post date:** [June 4, 2020, 12:49pm UTC](https://drone.discourse.group/t/plugin-entrypoint-sh-not-executed-in-kubernetes/10336/3 "2020-06-04T12:49:48Z")

</div>

I see, thanks @bradrydzewski for your answer!

May I know what is the recommended approach if I want to use a plugin _and_ run commands?

I like how plugins can help make the pipeline cleaner, but command give a lot of freedom as well…

Thanks in advance

---

<div class="post-metadata">

**Author:** ![bradrydzewski](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/bradrydzewski/32/3513_2.png) [@bradrydzewski](https://drone.discourse.group/u/bradrydzewski)\
**Post date:** [June 4, 2020, 12:55pm UTC](https://drone.discourse.group/t/plugin-entrypoint-sh-not-executed-in-kubernetes/10336/4 "2020-06-04T12:55:39Z")

</div>

Plugins are not designed to run user-defined commands. If you want the flexibility to run custom commands, perhaps a plugin is not the right approach. Instead consider invoking the bash script directly.

```diff
kind: pipeline
type: kubernetes
name: default

steps:
  - name: deploy
    image: my/registry/k8s-drone-plugin:v1.0.1
- settings:
- kubeconfig:
- from_secret: kubeconfig
+ environment:
+ PLUGIN_KUBECONFIG:
+ from_secret: kubeconfig
    commands:
+ - /drone/plugin.sh
      - kubectl version && kustomize version
      - echo $PLUGIN_KUBECONFIG 
      - echo $KUBECONFIG 
      - cat ~/.kube/config
      - kubectl get pods 

```

---

<div class="post-metadata">

**Author:** ![waterdrop01](https://yyz1.discourse-cdn.com/flex003/user_avatar/drone.discourse.group/waterdrop01/32/5035_2.png) [@waterdrop01](https://drone.discourse.group/u/waterdrop01)\
**Post date:** [June 4, 2020, 12:58pm UTC](https://drone.discourse.group/t/plugin-entrypoint-sh-not-executed-in-kubernetes/10336/5 "2020-06-04T12:58:09Z")

</div>

I see, I will try this way. Thanks a lot
