Skip to content
This repository has been archived by the owner on Mar 10, 2023. It is now read-only.

Run kubernetes apply as a drone plugin with variables injection built into the kubernetes YAML file

License

Notifications You must be signed in to change notification settings

naorlivne/drone-kubernetes-apply

Repository files navigation

Warning Drone cloud stopped working for months and as the developers of Drone seemed to stop caring I'm no longer able to fully test this nor will I longer have any use of it, as a result I'm stopping all development of this plugin.

drone-kubernetes-apply

CI/CD build status: Build Status

Code coverage: codecov

Drone plugin for deploying to kubernetes that allows injecting variables into the kubernetes YAML files & supports everything kubectl supports inside said YAML by running kubectl apply for you.

Usage

This plugin can be used to deploy applications to a Kubernetes cluster, it will create\update the given kubernetes deployments/cron jobs/pods/etc as needed.

The below pipeline configuration demonstrates simple usage:

In addition to the .drone.yml file you will need to create a injected_deployment.yaml file that contains the kubernetes configuration you want to deploy.

kind: pipeline
type: docker
name: default

steps:
- name: kubernetes_deploy
  image: naorlivne/drone-kubernetes-apply
  settings:
    kubernetes_token: my...vary...long...kube...token
    kubernetes_api_host: https://mykubecluster.example.com
    kubernetes_yaml_file: injected_deployment.yaml

Value substitution

Example configuration with values substitution:

kind: pipeline
type: docker
name: default

steps:
- name: kubernetes_deploy
  image: naorlivne/drone-kubernetes-apply
  settings:
    kubernetes_token: my...vary...long...kube...token
    kubernetes_api_host: https://mykubecluster.example.com
    kubernetes_yaml_file: injected_deployment.yaml
    my_image_tag: my_dynamic_image

In the injected_deployment.yaml file (please note the $ before the PLUGIN_MY_IMAGE_TAG key):

{
  ...
  "image": "myrepo/myimage:$PLUGIN_MY_IMAGE_TAG",
  ...
}

will result in:

{
  ...
  "image": "myrepo/myimage:my_dynamic_image",
  ...
}

Parameter Reference

kubernetes_api_host

The kubernetes API server URL (no trailing slash should be used), alternately mount a kubeconfig into the container /root/.kube/config

kubernetes_token

The token used to auth against the kubernetes API, alternately mount a kubeconfig into the container /root/.kube/config

kubernetes_yaml_file

The kubernetes deployment configuration file location relative to the root folder of the repo, defaults to injected_deployment.yaml

About

Run kubernetes apply as a drone plugin with variables injection built into the kubernetes YAML file

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published