Where's My DevOps API

Where's My DevOps API

We love APIs, they are the living breathing soul of our solutions. An integral step to delivering an working API, is moving it through the deployment pipeline and monitoring its health once it arrives. We love to craft our APIs and make sure they are easily consumable for consumers. But what about our DevOps tooling that delivers these solutions time and again to production? How can we apply our learnings from the APIs we have built to the APIs we consume when deploying and monitoring our solutions?

Presented at API Days Melbourne 2016

http://au.apidays.io/

C4c74e5212f470baa1abe68d8e4fff45?s=128

Matthew Erbs

March 01, 2016
Tweet

Transcript

  1. Where's my DevOps API? @matthewerbs | github/merbla

  2. Did someone say DevOps?

  3. "To succeed, YOU need to use MY Super Duper DevOps

    tool" 1 A Consultant
  4. hmmm..

  5. What is DevOps?

  6. DevOps is not just about tools or automation. Patrick Debois

  7. What do we do?? 4 Build an app 4 Deploy

    an app 4 Monitor an app 4 Do it ALL again!
  8. Communication

  9. A little secret?

  10. DevOps ❤ APIs

  11. G'day I'm Matthew

  12. If it's not in Production it did not happen!

  13. Let's be honest

  14. Stuff breaks!

  15. Ingredients for an Application Pipeline 4 A smattering of Tools

    4 A sticky Deployment 4 A lumpy Hosting Platform 4 A serve of Operational Tooling 4 An API or App to deploy
  16. None
  17. The Tools

  18. application/vnd.github.v3+json

  19. Authentication OAuth2 Token OAuth2 Client Secret/Key

  20. HyperMedia!

  21. Commits GET /repos/merbla/api-days-au/git/commits/xxx { "url": "https://api.github.com/repos/merbla/api-days-au/git/commits/XXX", "author": { "name": "Matthew

    Erbs", "email": "matthew.erbs@thetinytechcompany.io" ... }, ... "message": "How good was the keynote at API Days Oz! #banksy", "tree": { "url": "https://api.github.com/repos/merbla/api-days-au/git/trees/YYY", ... } ... }
  22. Discoverability import "github.com/octokit/go-octokit/octokit" func main() { client := octokit.NewClient(nil) url,

    err := octokit.UserURL.Expand(octokit.M{"user": "merbla"}) ... user, result := client.Users(url).One() ... fmt.Println(user.ReposURL) // https://api.github.com/users/merbla/repos }
  23. ETAGS PLEASE!

  24. Event Streams curl -I https://api.github.com/users/merbla/events HTTP/1.1 200 OK X-Poll-Interval: 60

    ETag: "a18c3bded88eb5dbb5c849a489412bf3" curl -I https://api.github.com/users/merbla/events \ -H 'If-None-Match: "a18c3bded88eb5dbb5c849a489412bf3"' HTTP/1.1 304 Not Modified X-Poll-Interval: 60
  25. Every API needs Em!jis GET /emojis { "+1": "https://github.global.ssl.fastly.net/images/icons/emoji/+1.png?v5", "-1":

    "https://github.global.ssl.fastly.net/images/icons/emoji/-1.png?v5", "100": "https://github.global.ssl.fastly.net/images/icons/emoji/100.png?v5", ... } !
  26. Deployment Time

  27. Create the Stack

  28. AWS Cloud Formation

  29. Create Stack (AWS) $ curl https://cloudformation.us-east-1.amazonaws.com/ ?Action=CreateStack &StackName=MyStack &TemplateBody=[Template Document]

    &NotificationARNs.member.1=arn:aws:sns:us-east-1:1234567890:my-topic &Parameters.member.1.ParameterKey=AvailabilityZone &Parameters.member.1.ParameterValue=us-east-1a &Version=2010-05-15 &SignatureVersion=2 &Timestamp=2010-07-27T22%3A26%3A28.000Z &AWSAccessKeyId=[AWS Access KeyID] &Signature=[Signature]
  30. OOOPS! 4 AlreadyExists: HTTP Status Code: 400 4 InsufficientCapabilities: HTTP

    Status Code: 400 4 LimitExceeded: HTTP Status Code: 400
  31. None
  32. Create Stack (OpenStack) $ curl -s -H "X-Auth-Token: $OS_TOKEN" -XPOST

    https://mystack/v1/{tenant_id}/stacks -d '{ "stack": "mystack" "template":"mytemplate", "parameters": { "a": "Value", "b": "3" } }' Error Codes - 400, 401, 409, 500
  33. Create Stack (OpenStack) Response { "stack": { "id": "xxx-stackid", "links":

    [ { "href": "http://mystack/v1/my-tenant/stacks/teststack/xxx-stackid", "rel": "self" } ] } }
  34. . Platform

  35. $ docker pull my-awesome-api OR $ docker run my-awesome-api

  36. $ docker images GET /images/json?all=0

  37. $ docker ps GET /containers/json?all=0

  38. $ docker run golang POST /containers/create?fromImage=golang

  39. $ docker kill my-container POST /containers/my-container/kill

  40. The Ops View

  41. Two competing paradigms Push vs Pull

  42. Data In (Elastic) $ curl -XPUT -l "http://myelastic/git/event/xxx-eventid" -d '{

    "commit": "7638417db6d59f3c431d3e1f2ff33637155684cd", "message": "Matthew commited some code!", "user": "merbla" }'
  43. Data In (Splunk) $ curl -XPOST -k https://mysplunk:8088/services/collector -H 'Authorization:

    Splunk mytoken' -d '{ "source": "github", "index": "git", "event": { "commit": "7638417db6d59f3c431d3e1f2ff33637155684cd" "message": "Matthew commited some code!", "user": "merbla" } }'
  44. Data Out (Elastic) $ curl -XGET -k 'http://myelastic/git/event/_search?q=user:merbla'

  45. Data Out (Splunk) $ curl -XGET -k 'https://mysplunk/services/search/jobs' -d search='index=git

    user=merbla'
  46. The Comms

  47. Slack

  48. Post a message (Web Hook) curl -XPOST -k https://hooks.slack.com/services/merbla/apidays/token -H

    'Content-type: application/json' -d '{ "text":"Is this talk nearly over? I need lunch!" }'
  49. The APP API

  50. APIs Everywhere 4 Tooling 4 Deployment 4 Operational Monitoring 4

    Communication
  51. My Thoughts...

  52. DevOps media types?

  53. Authentication Story

  54. SAY N! to TOOL WARS! #banksy

  55. Tooling patches holes

  56. Where are my link relations? !

  57. Don't forget

  58. DevOps ❤ APIs

  59. APIs ❤ DevOps

  60. Resources developer.github.com/v3/ docs.docker.com/engine/reference/api/docker_remote_api/ developer.openstack.org/api-ref.html elastic.co/guide/en/elasticsearch/reference/current dev.splunk.com/restapi

  61. Thankyou! Questions?? matthew@thetinytechcompany.io | @matthewerbs