Slide 1

Slide 1 text

Writing Tools in Go For Ops Engineers Go 1.6 Release Party

Slide 2

Slide 2 text

@y_uuk1 id:y_uuki Web Operations Engineer @Hatena

Slide 3

Slide 3 text

About 2.5 years since I met Go

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

Ready for production use

Slide 6

Slide 6 text

mkr Command Line Tool for Mackerel API

Slide 7

Slide 7 text

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)

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

IUUQZVVLJIBUFOBCMPHDPNFOUSZESPPU

Slide 12

Slide 12 text

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()

Slide 13

Slide 13 text

gokc Yet Another Keepalived Syntax Checker in Golang.

Slide 14

Slide 14 text

IUUQZVVLJIBUFOBCMPHDPNFOUSZHPLD

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

I believe Go is a good solution for ops engineers

Slide 17

Slide 17 text

Pros of Golang for ops engineer

Slide 18

Slide 18 text

1 Easy Distribution

Slide 19

Slide 19 text

Easy Distribution • One Binary • Escaping Dependency Problem

Slide 20

Slide 20 text

Why is “One binary” so important ?

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

2 Quick development on Server

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

3 Quick deployment as a result

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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