Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
117 lines (91 sloc) 2.5 KB
date title author tags repo logo image
2018-10-15 00:00:00 +0000
kubectl
kubeci
kubernetes
kubectl
kubeciio/kubectl
kubectl.svg
kubeciio/kubectl

The kubectl plugin can be used to do everything kubectl can do. It provides some helpers and shortcuts to make your pipeline step more readable.

Example configuration running inside a kubernetes cluster:

pipeline:
  kubectl:
    image: kubeciio/kubectl
    kubectl: get pods

Example configuration using a kubeconfig via a secret:

This is required when running outside a cluster or a different one should be talked to.

pipeline:
  kubectl:
    image: kubeciio/kubectl
    kubectl: get pods
+   secrets: [ kubeconfig ]

This takes the secret kubeconfig, base64 decodes it and writes it to disk ready for kubectl.

Example configuration using a different kubeconig via a secrets:

pipeline:
  kubectl:
    image: kubeciio/kubectl
    kubectl: get pods
+   secrets:
+     - source: kubeconfig_development
+       target: kubeconfig

This maps the kubeconfig_develpment secret to be used by the plugin as kubeconfig which is then forwarded to kubectl.

Example configuration running inside a kubernetes cluster using a different namespace:

pipeline:
  kubectl:
    image: kubeciio/kubectl
-   kubectl: get pods
+   kubectl: --namespace kubeci get pods

equivalent:

pipeline:
  kubectl:
    image: kubeciio/kubectl
    kubectl: get pods
+   namespace: kubeci

Example configuration using file paths to apply:

pipeline:
  kubectl:
    image: kubeciio/kubectl
+   kubectl: apply -f /path/to/folder/foo.yaml -f /path/to/folder/bar.yaml -f /path/to/folder/baz.yaml

equivalent but easier to read:

pipeline:
  kubectl:
    image: kubeciio/kubectl
-   kubectl: apply -f /path/to/folder/foo.yaml -f /path/to/folder/bar.yaml -f /path/to/folder/baz.yaml
+   kubectl: apply
+   files: 
+     - /path/to/folder/foo.yaml 
+     - /path/to/folder/bar.yaml 
+     - /path/to/folder/baz.yaml

Templating

Templating generate commands or files to be used by kubectl when executing.

Setting the image to the current commit:

pipeline:
  kubectl:
   image: kubeciio/kubectl
   kubectl: set image deployment/foo container=bar/baz:{{ .DroneCommit }}

Debug

You can turn on the debug mode to see some details like the plain text kubeconfig. Attention only use this on test systems, NOT AT PRODUCTIVE SYSTEMS.

pipeline:
  kubectl:
   image: kubeciio/kubectl
+  debug: true  
You can’t perform that action at this time.