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).
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!