Running custom scripts using Spinnaker

Although Spinnaker has a built-in Script Stage, it requires Jenkins to do the job in the background. It may not be a convenient option especially when a user does not have a Jenkins instance at all.

In this short blog, let’s look at how we can leverage a Kubernetes Job to run our custom scripts.

Pre-requisites:

  1. A container image is required with necessary tools installed on it so that K8s job can spin up a pod to run the custom script successfully.
  2. Add git artifact account in case we want to fetch the script from git repository

Use-case 1:

Create a Spinnaker pipeline that fetches the script from a git repository, creates a configmap using the fetched script and run that script using a K8s job stage in Spinnaker.

Use-case 2:

Create a Spinnaker pipeline that has a script in a configmap and then uses this config map in a K8s job stage to execute the script

Use-case 3:

Create a spinnaker pipeline that has a little complicated run job stage that requires a set of secrets and configmaps to be mounted to run the script

Note: Script expects git credentials to be mounted via a secret. So, a secret with the name gitsecret should be created before running the pipeline in the namespace where the run job runs

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store