Spinnaker tricks: Restarting a deployment automatically

Jan 4, 2023 by Jason McIntosh

What problem are we trying to solve?

Spinnaker has always understood the need to do “Orchestration” type tasks. These are tasks that you can do via the UI to do things like rolling restart a deployment, scaling it up or down manually or similar. These types of operations are actually stages that are executed similarly to pipelines, but many such operations are not visible when modifying a pipeline.

A common case I’ve encountered recently is the need to restart a deployment to pick up a change. Typically this is a DNS change when my app does NOT support DNS updates (often a situation in highly secure environments), or a password change from a config that’s not re-read automatically. Normally, you’d have to login to a system, get credentials, and call a kubectl rollout restart -n namespace deployment my-webapp. This can be time-consuming and a pain. There are automations you can do (e.g. a Runjob internally, or some other workload automation). BUT let’s use the power of Spinnaker to solve this since it natively supports some options to make these kinds of tasks MUCH easier.

Today’s tip is how to restart a deployment via a simple trigger (webhook in this case) by manually creating a pipeline for one of these operations – the rollout restart stage.

Let’s get started…

First, create your pipeline. Note you’ll need to adjust settings to match your environment. The full pipeline is available here:


Let’s look at one piece of the config that I’ve shortened for this blog:

      "account": "k8s-namespace-prod",
      "application": "demo",
      "cloudProvider": "kubernetes",
      "location": "prod",
      "manifestName": "deployment demo-web-app",
      "name": "Restart pods",
      "type": "rollingRestartManifest"

The configuration above that is key is location, type, account, and manifestName. This is how Spinnaker identifies the type of operation, the location (aka namespace) and the resource. Note that the “manifestName” in this case is a combination of the kind “deployment” and the resource name to restart. You can now via a very simple curl trigger an automated restart of a deployment (DO note, it’s recommended to use validation to verify the contents of a webhook!):

curl -X POST -v -H "Content-Type: application/json" http://spinnaker.example.com/api/v1/webhooks/webhook/restartSomeDeploymentService -d '{"restartCreds":"isSomeSecuredEntry"}'

You can see the results of a restart below:

Screen shot of execution of rollout restart pipeline running

You can see the results of several rollouts here:

demo · Clusters 2023-01-04 at 10.51.34 AM

The pipeline in this example was only used to restart a single manifest and do nothing else but you could easily add this as a stage in any pipeline if you wanted for some reason to trigger a restart.

Final tidbits

This was done via a very simple webhook, but you could use any of the other spinnaker “triggers” – e.g. a pubsub message, a git commit, cron, or something else entirely. There are other operations than just rollout restarts you can use with this method. For example – this method can be used to scale up a deployment! And a reminder – watch the permissions and validation of your triggers! This is essentially exposing an automated operation against your infrastructure. It’s powerful, but with great power comes great responsibility!

Recently Published Posts

Spinnaker Tips: Setting a github status check on a PR from a pipeline

Oct 12, 2023

A common situation we hit is creating a pull request on github with some terraform changes that are run through our pipelines. We’d like to verify the terraform changes cleanly “plan” before we apply them. An example is when someone has a typo (how many times I’ve left dangling commas in a JSON object!) and […]

Read more

Introducing Pipelines-as-Code Plugin for Open Source Spinnaker

Jul 21, 2023

Easily Scale and Automate with Version Control in Git Developers choose best-of-breed version control systems like GitHub for a reason: they need the ability to collaborate and improve code together.  But a broken Spinnaker deployment pipeline can often be the last thing standing in the way of getting your application to market.  Until now. Armory’s […]

Read more

What is FedRAMP and Why It Matters

Jun 8, 2023

What’s FedRAMP? Federal Risk and Authorization Management Program (FedRAMP) is a government-wide program that provides a standardized approach to security assessment, authorization, and continuous monitoring for cloud products and services. FedRAMP is important since it’s the gold standard for assessing cloud service providers (CSP) within the government. Under this program, authorized FedRAMP cloud service providers […]

Read more