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 full-size slide

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

    View full-size slide

  3. About 2.5 years
    since I met Go

    View full-size slide

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

    View full-size slide

  5. Ready for
    production use

    View full-size slide

  6. mkr
    Command Line Tool for Mackerel API

    View full-size 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 full-size slide

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

    View full-size 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 full-size slide

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

    View full-size slide

  11. IUUQZVVLJIBUFOBCMPHDPNFOUSZESPPU

    View full-size 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 full-size slide

  13. gokc
    Yet Another Keepalived Syntax Checker in
    Golang.

    View full-size slide

  14. IUUQZVVLJIBUFOBCMPHDPNFOUSZHPLD

    View full-size 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 full-size slide

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

    View full-size slide

  17. Pros of Golang
    for ops engineer

    View full-size slide

  18. 1
    Easy Distribution

    View full-size slide

  19. Easy Distribution
    • One Binary
    • Escaping Dependency Problem

    View full-size slide

  20. Why is “One binary”
    so important ?

    View full-size slide

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

    View full-size slide

  22. 2
    Quick development
    on Server

    View full-size slide

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

    View full-size 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 full-size slide

  25. 3
    Quick deployment
    as a result

    View full-size 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 full-size 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 full-size slide

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

    View full-size slide