Spinnaker Training Series #5: Pipeline Stages

Ethan Rogers, resident Spinnaker expert, demonstrates an introduction to creating different types of pipeline stages.

A Transcript of the video is available below:

Ethan: What’s up guys, I am Ethan your Spinnaker expert. Thanks for joining us for another instalment of our Spinnaker training series where we take you through Spinnaker and teach you how to get the most out of it. Today we are going to be talking about how to use the different stages within Spinnaker, to model the deployment workflows that you need rather than feeling constrained. So what we are going to do is use a whole bunch of different stages to show you how you can build a pipeline very easily that goes from build all the way to production with some various checks thrown in there, let’s get started.
So the first thing you might see in a typical deployment pipeline is Bake stage. A Bake stage is going to take some artifact produced in your CI environment bake that into an AMI, so let’s start with that. We will select a bake stage from our dropdown. Now the next thing we might typically do is take that AMI and deploy it into a test environment, so we use the add stage button again and select the deploy stage. Here we will rename the deploy stage to Deploy test so that we know which environment we are intending to stage for. Now something I have typically seen is the need to have some type of approval that says this next step of my pipeline can proceed, I can go from test to staging. Spinnaker provides us a really great way to do that using the manual judgment stage. So we will add one of those here. So the manual judgment stage gives us a lot of options, we can prompt a user for some input for example, so we will do that by saying "are you ready?" in this instruction box and then we will give the user two options. We will say yes and then we will say no. We will use these options later in our pipeline to determine where we are going like what branch we might take. We will do that now by adding a check pre-condition stage. We will select add stage again checking a pre-condition. So this gets into a part of Spinnaker that we haven’t covered yet and that is expressions. You can check out the documentation of Armory's website about expressions at docs.armory.io. So what expressions give us is the ability to dynamically check some value within our pipeline and then we can make judgments on that.
So what we will do here is we will add a new pre-condition and we will say we want to use an expression and we will check the manual judgment stages that we just added. If you look at the documentation you will find there is a bunch of helpers here, and we are going to use one of those helpers called the judgment helper. Then will say judgment, the name of our stage equals yes. Now, if this stage passes then if these are put in yes for the manual judgment they will proceed on further down our pipeline. If it didn’t, then we will just stop the pipeline, not failing the pipeline specifically but halting it. So the next thing we will do here is we will model some type of promotion which will allow us to deploy to a different environment. So we will use another deploy stage and call that Deploy Staging. Now when you are build or your deployment finally hits a staging environment you may want to use Jenkins to run some type of acceptance testing.
We can do that by jumping back into check pre-conditions adding a parallel stage by just clicking add stage while we are sitting all in that stage and we will select the Jenkins job. You can see here that now we are running two stages in parallel. Once both of those are successfully completed, we will add one more stage that will let us deploy to production and here we will add another dependency for our up string stages that says the two previous that this stage depend on have to successfully complete before we can do this. So we will add the deploy stage here as a dependency and we can see that we have then said deployed production depends on these two. I hope that this video was helpful to you in understanding how you can use all the different stage in the Spinnaker to model your deployment workflow. Spinnaker gives us all of these really robust things that have been battle tested at some of the biggest names in our industry. You can use all of these deployment stages to do very simple deployments and very complex deployments and you can see that in this example here where we branched out and reached out into other systems specifically to do work that spinnaker doesn’t expose to us natively. I hope this video was helpful, thanks for watching.