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.
- 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.
- Add git artifact account in case we want to fetch the script from git repository
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.
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
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