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

Writing Tools in Go For Ops Engineers

Writing Tools in Go For Ops Engineers

Yuuki Tsubouchi (yuuk1)

February 18, 2016
Tweet

More Decks by Yuuki Tsubouchi (yuuk1)

Other Decks in Programming

Transcript

  1. Writing Tools in Go
    For Ops Engineers
    Go 1.6 Release Party

    View Slide

  2. @y_uuk1
    id:y_uuki
    Web Operations Engineer
    @Hatena

    View Slide

  3. About 2.5 years
    since I met Go

    View Slide

  4. My ops tools in Go
    • yuuki1/droot
    • yuuki1/grabeni
    • yuuki1/gokc
    • mackerelio/mkr

    View Slide

  5. Ready for
    production use

    View Slide

  6. mkr
    Command Line Tool for Mackerel API

    View Slide

  7. mkr
    • For programable server operations
    with Mackerel
    • JSON output (Enable to parse with jq)
    • Depends on mackerelio/mackerel-
    client-go
    • More useful on server (No need to
    pass an API Key)

    View Slide

  8. Grabeni
    An ops-friendly AWS Elastic Network
    Interface (ENI) attachment grabbing tool.

    View Slide

  9. Grabeni
    • Help a failover tool (Keepalived/
    MHA) switch a VIP
    • Depends on aws/aws-sdk-go
    • AWS API Retry/Max Attempts
    HSBCFOJHSBCFOJYYYYYYYYY

    View Slide

  10. Droot
    A super-easy application container engine
    with chroot without docker.

    View Slide

  11. IUUQZVVLJIBUFOBCMPHDPNFOUSZESPPU

    View Slide

  12. Droot
    • chroot an extracted archive from
    Docker images
    • Pull an archive from AWS S3
    • Atomic deploy with symlink and
    rename(2)
    • `docker export | s3 upload` by
    io.Pipe()

    View Slide

  13. gokc
    Yet Another Keepalived Syntax Checker in
    Golang.

    View Slide

  14. IUUQZVVLJIBUFOBCMPHDPNFOUSZHPLD

    View Slide

  15. gokc
    • Keepalived (well known with LVS)
    • Replace maoe/kc written in Haskell
    (Parser combinator)
    • Parser with yacc
    • Lexer with goroutine and channel

    View Slide

  16. I believe
    Go is a good solution
    for ops engineers

    View Slide

  17. Pros of Golang
    for ops engineer

    View Slide

  18. 1
    Easy Distribution

    View Slide

  19. Easy Distribution
    • One Binary
    • Escaping Dependency Problem

    View Slide

  20. Why is “One binary”
    so important ?

    View Slide

  21. • 1500+α Hosts
    • 500+α Roles
    • Services continued 15 years
    • Many Old OSs …
    Hatena

    View Slide

  22. 2
    Quick development
    on Server

    View Slide

  23. Quick Development on Server
    • GOOS=linux GOARCH=amd64 (or
    build on Docker)
    • scp ./binary [remote server]
    • ./binary

    View Slide

  24. Quick Development on Server
    • One binary & Cross compile
    • My ops tools aim to run on Linux
    servers.
    • ex. droot runs on Linux only

    View Slide

  25. 3
    Quick deployment
    as a result

    View Slide

  26. • Not mean that coding is just quick
    • Mean that no hesitation about
    coding because Go has the simple
    language specification
    Quick deployment

    View Slide

  27. Others
    • Concurrency by goroutine
    • `io.Pipe()`
    • Fast runtime rather than LL
    • Error handing by returning error type
    • `defer` statement
    • Easy to clear temp resources on failure

    View Slide

  28. Summary
    • Pros of Go for ops engineers
    • Easy binary distribution
    • Quick development on server
    • Quick deployment as a result

    View Slide