Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Spinnaker Wants Tools, So Build Them!

Spinnaker Wants Tools, So Build Them!

Robert Ross

October 09, 2018
Tweet

More Decks by Robert Ross

Other Decks in Programming

Transcript

  1. ROBERT ROSS ME MY NAME IS I AM A SOFTWARE

    ENGINEER @ NAMELY I'M ALSO A MARCHING BAND NERD
  2. ROBERT ROSS ME MY NAME IS I AM A SOFTWARE

    ENGINEER @ NAMELY I'M ALSO A MARCHING BAND NERD
  3. BUILDING TOOLS FOR SPINNAKER THIS IS A STORY ABOUT NAMELY

    ▸ HR, Payroll, Benefits software. ▸ Moves more than 1 billion in payroll monthly ▸ Around 100 Engineering Employees ▸ Moving to microservices for the past couple of years
  4. THE INFRASTRUCTURE ▸ Kubernetes 1.9 ▸ Jenkins for tests ▸

    Spinnaker (Kubernetes v2 provider) for Deployments ▸ AWS for all Infrastructure ▸ 4 k8s Environments (Integration, staging, production, ops) ▸ Istio 1.0.2 ▸ Using gRPC for all service to service calls ▸ Go, C#, Ruby, and Python services, React frontends
  5. FROM TWO SERVICES TO TOO MANY ‣ We had 2

    applications: A Rails monolith and a .NET Monolith ‣ Now we have 3 dozen (and climbing) services in our architecture ‣ We also found ourselves with the improper tooling to deploy in this new world
  6. FROM TWO SERVICES TO TOO MANY ‣ This causes problems

    when you don't have the right tools to deploy ‣ SRE was responsible for all deploys. (Manually running kubectl apply -f locally) ‣ No standards on how applications deploy, when, how, etc.
  7. BUILDING TOOLS FOR SPINNAKER GREAT IDEA! ▸ Copy a kube-deploy.sh

    file to every project and modify the Jenkinsfile to execute it at the end of a build ▸ Open 30+ pull requests to projects to install this monstrosity ▸ Boom! Continuous Deployment!
  8. BUILDING TOOLS FOR SPINNAKER WHY? ▸ Open Source tools are

    1/3rd of the solution to any business problem ▸ Installing and configuring tools like Spinnaker is the easy part ▸ Educating, documenting, productionalizing, and on- boarding is a whole different ball game
  9. BUILDING TOOLS FOR SPINNAKER RULES AND REQUIREMENTS ▸ Pipeline configurations

    must have a source of truth that is version controlled in Git ▸ Pipelines must automatically update in Spinnaker when changes are pushed to Github ▸ Releases must be recorded for all environments for every project
  10. BUILDING TOOLS FOR SPINNAKER WHAT IS A PIPELINE? ▸ We

    wanted to use Spinnaker Pipeline's for all deployments ▸ However, Spinnaker didn't have a tool for "codifying" pipelines that supported everything we wanted ▸ Bummer, because we don't want engineers managing pipelines via the Spinnaker UI ▸ This allows drift from a set standard that we can build into tools ▸ Our decision: Build that missing tool.
  11. BUILDING TOOLS FOR SPINNAKER WHERE TO START? ▸ Spinnaker has

    a nifty "Edit as JSON" feature for Pipeline's in the UI ▸ We configured pipelines for projects by hand and then took the resulting JSON
  12. BUILDING TOOLS FOR SPINNAKER CONVERTING THE JSON ▸ We then

    used that JSON to create concrete Go structs for our tool ▸ This tool became k8s-pipeliner
  13. GO(ING) NUTS FOR STRUCTS K8S-PIPELINER GO STRUCTS ▸ By defining

    what a Spinnaker pipeline is via Go structs, we now have a guaranteed JSON structure. ▸ We also can easily manipulate pipelines (more on that later). ▸ We can then render these struct values as JSON and send that payload to Gate (the Spinnaker API) for any operation we need to perform.
  14. CREATING OUR PIPELINE DEFINITION NOW WE JUST NEED A CONFIG

    SPEC ▸ k8s-pipeliner includes a set of pipeline config objects ▸ These values are what compose our pipeline.yml file that gets transposed into a Spinnaker Pipeline JSON payload
  15. GETTING INTO FLOW DEFINE PIPELINE FLOW, NOT SPECIFICS ▸ One

    thing we didn't want our pipeline.yml file to define is what gets deployed ▸ Instead, our spec only defines how something should be deployed, not the specifics of what. ▸ Our file references Kubernetes manifest files to define what get's deployed.
  16. GO(ING) NUTS FOR STRUCTS ONE PROBLEM... KUBERNETES V1 PROVIDER ▸

    Original Kubernetes provider had it's own flavor of Kubernetes objects as JSON ▸ This is because the provider hit the Kubernetes API with a Java client as opposed to just using kubectl (which is what v2 does) ▸ This caused massive pain creating these definitions ▸ We had to create every Spinnaker Kubernetes V1 object manually
  17. HAS JSON EVER MADE YOU THAT HAPPY? THIS JSON LETS

    US CONFIGURE PIPELINES IN THE UI ▸ We can take the output of this command, copy it, and paste it into the Spinnaker UI via the "Edit as JSON" option
  18. BADA BING BADA BOOM ▸ Our Spinnaker Pipeline never is

    managed via the UI (with the exception of pasting the JSON) ▸ All of the pipeline.yml files are checked into source control ▸ Reverts to the codebase allows us to revert pipelines easily ▸ Track record of who changed what in pipelines ▸ The wins are numerous.
  19. ALTERNATIVES CONSIDERED ▸ We could have configured every project manually

    and rolled that way without version control. ▸ We could have let teams own their own process. ▸ But the long term spend of that is enormous ▸ Configuring via the UI would be tedious and error prone ▸ Linear scale of time spent as we add more applications
  20. A GREAT START WE MADE THE CHANGE EASY By building

    k8s-pipeliner and creating concrete types to represent a Spinnaker pipeline, we set ourselves up for even bigger successes with little work.
  21. STICK SHIFT TO AUTOMATIC AVOIDING THE UI AS A SERVICE

    ▸ Disclaimer: I love Spinnaker. We use it for every project we deploy to Kubernetes (which is basically everything) ▸ But the UX for managing pipelines is clunky ▸ UI/UX is hard to get right for something that can do so much (See: AWS) ▸ Spinnaker suffers from this (great) problem because it can do so much.
  22. STICK SHIFT TO AUTOMATIC OUR IDEAL FLOW ▸ Instead of

    pasting JSON into a text field in the pipeline configuration page, this should be automatic. ▸ Whenever a merge is performed into master for a project, we'll send a Github webhook to an internal service ▸ That project will then clone the project, read the pipeline config file(s), and then update the application's pipeline
  23. The tidal mouth of a large river, where the tide

    meets the stream. WHAT IS ESTUARY ▸ Estuary is a simple HTTP server that receives GitHub webhooks, builds a pipeline config, and then updates the Spinnaker Pipeline via the Gate API. ▸ Written in Go ▸ Imports k8s-pipeliner to generate the JSON ▸ Can inject values into pipelines automatically as well
  24. SNOOPING AROUND FIGURING OUT THE API REQUEST ▸ We've configured

    Gate to authenticate via Github and A X509 Certificate ▸ Using the X509 Certificate allows us to send POST requests to update the pipeline from Estuary ▸ But what does this request look like exactly?
  25. SNOOPING AROUND FIGURING OUT THE API REQUEST ▸ Spinnaker has

    a Swagger file for it's API ▸ However... we found it easier to just look at what the UI sends in its XHR requests ▸ Once we figured that out, we can easily update the Pipeline
  26. AUTO PIPELINE UPDATE WHAT WE'LL SEE ▸ You'll see a

    simple pipeline.yml file get updated ▸ Estuary in the background receives the github webhook ▸ Estuary then clones and updates the pipeline accordingly
  27. LOG ME MAYBE WHAT ARE RELEASE LOGS ▸ A structured

    entry of what was deployed, when, and other metadata ▸ Stored forever, most recent first ▸ Can be used for identifying what release broke what ▸ Metrics! ▸ Release managers love it
  28. HOW? HOW DO YOU CREATE THESE LOGS? ▸ Spinnaker has

    a module called Echo that can send webhook requests on task events ▸ We've configured Echo to send webhooks to our "Release Management Software" ▸ Release Management Service parses the webhook and creates log entries when pipeline stages complete
  29. THE PAYLOAD HOW DO YOU EVEN GET THIS PAYLOAD? ▸

    We could not find a single page of documentation about what this payload looks like in full ▸ Little did we know a typical payload for one of our pipelines was 870kb of JSON (that's enormous) ▸ So, we just sent the payload to http://webhook.site
  30. USE THE WEBHOOK MODIFY ECHO'S CONFIG TO INCLUDE IT Kick

    off a pipeline (preferably one without sensitive data) and watch webhook.site fill up.
  31. CLOSING UP MY THOUGHTS ▸ All Open Source projects are

    puppets ▸ On their own, they're lifeless, they provide very little or no business value on their own ▸ We as engineers must be the puppeteers and give these projects the personality we want them to have ▸ Building tools around them is just one of those ways to give a project like Spinnaker the life we want it to have