Hi all
I am stuck!
I’ve probably gone through most relevant forum threads and I have surely gone through the documentation many times over (to the point I started noticing typos and made a couple of PRs).
I am writing a plugin for Kubernetes because existing solutions don’t cover my use case (my need was for 100% kubectl apply -f multi-config.yaml
parity from inside the pipelines)
And while for my personal use case (in-cluster) works fine, I thought since there is no other plugin at the moment to solve the issue, make it work for out-of-cluster scenarios too (note: there is one open PR -adding drone-kubernetes-apply #264- that while it works, setting up a docker build containing kubectl
is an overkill, while using Kubernetes API and Server Side Apply feels more proper solution).
Out-of-cluster scenarios need to use secrets (to store kubeconfig
) and for the life of me I can not make them work!
I’d like to stress that I have the same problem for some time now and is not related to my plugin or current k8s cluster version. The only secrets I have ever managed to use are ones created via GUI. Even encrypted secrets created with drone CLI don’t work. The don’t work in the settings
section of plugin using from_secret
plus they don’t work with env variables either.
For example if I run a pipeline like this
kind: pipeline
type: kubernetes
name: default
steps:
- name: dron8s
image: bh90210/dron8s:v0.0.16
environment:
PLUGIN_KUBECONFIG:
from_secret: kc
settings:
yaml: ./k8s-deployment.yaml
kubeconfig:
from_secret: kc
commands:
- echo $PLUGIN_KUBECONFIG
- echo $PLUGIN_YAML
---
kind: secret
name: kc
data: ZZFNHUI489053iojrgfg56df65df857sg[...]
I get
default — dron8s
00:02
+ echo $PLUGIN_KUBECONFIG
+ echo $PLUGIN_YAML
./k8s-deployment.yaml
My setup is entirely on Kubernetes. Server, runner & secrets are operating in the same cluster. Everything installed via provided Helm charts.
Relevant drone-runner-kube
helm chart values
env:
DRONE_RPC_SECRET: <password>
DRONE_RPC_HOST: some.url.com
DRONE_RPC_PROTO: https
DRONE_NAMESPACE_DEFAULT: drone
DRONE_SECRET_PLUGIN_ENDPOINT: drone-kubernetes-secrets.drone.svc.cluster.local:3000
DRONE_SECRET_PLUGIN_TOKEN: <password>
and relevant drone-kubernetes-secrets
helm chart values
rbac:
enabled: true
secretNamespace: default
env:
SECRET_KEY: <password>
KUBERNETES_NAMESPACE: default
The secret was created by running kubectl create secret generic dron8s --from-file=kubeconfig=$HOME/.kube/config
though if the error is in kube runner/kube secrets configs, this does not explain why plain encrypted option is not working either
and logs from each pod
server:
{"level":"info","msg":"main: internal scheduler enabled","time":"2020-10-20T23:35:18Z"}
{"interval":"30m0s","level":"info","msg":"starting the cron scheduler","time":"2020-10-20T23:35:18Z"}
{"interval":"24h0m0s","level":"info","msg":"starting the zombie build reaper","time":"2020-10-20T23:35:18Z"}
{"acme":false,"host":"https://some.url.com","level":"info","msg":"starting the http server","port":":80","proto":"https","time":"2020-10-20T23:35:18Z","url":"https://some.url.com"}
runner:
time="2020-10-21T01:21:16Z" level=info msg="starting the server" addr=":3000"
time="2020-10-21T01:21:16Z" level=info msg="successfully pinged the remote server"
time="2020-10-21T01:21:16Z" level=info msg="polling the remote server" capacity=100 endpoint="https://some.url.com" kind=pipeline type=kubernetes
secrets:
time="2020-10-21T00:33:31Z" level=info msg="server listening on address :3000"
everything seems normal.
I figured if this was a bug somewhere other people would complain here or in github issues but it seems to be just me. Am I missing something obvious? Please help.
Thanks in advance,
Byron