Unable to execute "kubectl" with exec pipeline

hi, I’m trying to execute “kubectl” command with exec pipeline because of some reasons. I had installed a runner.

I also use the command below to start the service:
sudo drone-runner-exec daemon exec.config

and got the successful messages from logs as well:

INFO[0000] successfully pinged the remote server
INFO[0000] polling the remote server        ....

However, when Drone is activated by pushing code, the error occur:

Here is my .drone.yaml:

kind: pipeline
type: exec
name: default1

platform:
  os: linux
  arch: amd64

steps:
- name: greeting
  commands:
  - kubectl get no

btw, I tried other commands like “ls”, “docker ps”, etc. And they all run correctly.

How are you providing your kube config?

You need to account for pipelines running in an ephemeral workspace, where each pipeline has its own home directory.

hi, thank for the quick reply. Sorry i am beginner of K8s and Drone.

I realize that I didn’t set any configuration with kube config. Are there related configurations included in the following command from document?

$ drone-runner-exec service install
$ drone-runner-exec service start

if so, i got the error message:

drone-runner-exec: error: cannot read configuration

Is there have anything I was missing?

I figure out how to solve my problem.

Just copy kubeconfig file to the piprline workspace:

kind: pipeline
type: exec
name: default1

platform:
  os: linux
  arch: amd64

steps:
- name: greeting
  commands:
  - mkdir ~/.kube
  - cp /home/k8s-node5/.kube/config ~/.kube
  - kubectl get no

Thanks for the help.