Human-friendly DNS powered by Golang We love to work in a casual - - PowerPoint PPT Presentation

human friendly dns powered by golang we love to work in a
SMART_READER_LITE
LIVE PREVIEW

Human-friendly DNS powered by Golang We love to work in a casual - - PowerPoint PPT Presentation

Human-friendly DNS powered by Golang We love to work in a casual environment that energizes us to revolutionize the fitness industry. Site Reliability Engineering @ eGym Scale Site Reliability Engineering @ eGym Site Reliability


slide-1
SLIDE 1

Human-friendly DNS powered by Golang

slide-2
SLIDE 2

We love to work in a casual environment that energizes us to revolutionize the fitness industry.

slide-3
SLIDE 3

Site Reliability Engineering @ eGym

  • Scale
slide-4
SLIDE 4

Site Reliability Engineering @ eGym

slide-5
SLIDE 5
slide-6
SLIDE 6

Site Reliability Engineering @ eGym

slide-7
SLIDE 7

Site Reliability Engineering @ eGym

slide-8
SLIDE 8

Room for more SREs :)

slide-9
SLIDE 9

Site Reliability Engineering @ eGym

  • Scale
  • Automate
  • Own reliability

○ 24/7 Monitoring ○ On-call

  • Consult teams
slide-10
SLIDE 10

DNS Basics

slide-11
SLIDE 11

DNS Basics

slide-12
SLIDE 12

Names

www egym de $NULL . . .

separator label

slide-13
SLIDE 13

DNS Hosts

www egym de . .

domain host Top-level domain

slide-14
SLIDE 14

DNS Name Spacing

int egym de . .

zone Sub zone

slide-15
SLIDE 15

DNS Name Spacing

https://en.wikipedia.org/wiki/Domain_Name_System

slide-16
SLIDE 16

DNS @ eGym

  • 20+ domains

○ and counting...

  • 18 delegations to sub zones

○ “team spaces”

  • 700+ resource records

○ without sub zone records Registrar Hoster Cloud DNS Delegation (NS RR) Zone File Deployment Change Scripts Scripts Scripts Read/Parse

slide-17
SLIDE 17
slide-18
SLIDE 18

Rethinking DNS @ eGym

Single Source Of Truth Production DNS (Cloud DNS) Tools Single Source of Truth

  • Version Controlled
  • Human Readable
  • Non-repetitive

Cloud DNS

  • Scales
  • API

Tools

  • Rollbacks
  • Replays
  • Automated (non-interactive mode)
  • Safeguards
slide-19
SLIDE 19

Rethinking DNS @ eGym

Single Source Of Truth Production DNS (Cloud DNS) Tools Single Source of Truth

  • Version Controlled
  • Human Readable
  • Non-repetitive

Cloud DNS

  • Scales
  • API

Tools

  • Rollbacks
  • Replays
  • Automated (non-interactive mode)
  • Safeguards

YAML Templates

slide-20
SLIDE 20
slide-21
SLIDE 21

DNS Tooling

  • PaPuDNS

○ Parses YAML-formatted zone information ○ Parses YAML-formatted templates ○ Applies templates ○ In-Memory database with all resource records ○ Fetches current zone information from Cloud DNS via API ○ Calculates difference ○ Pushes the changes (atomically)

  • dns-check

○ Parses YAML-formatted “expectations” ○ Checks via live DNS if expectations are meet ○ Does not (yet) use the same format/database

slide-22
SLIDE 22

Zones

github.com/egymgmbh/papudns zones:

  • zone: egym.coffee

description: Test zone. ttl: 300 templates:

  • gmail
  • website

names:

  • name: '@'

texts: data:

  • foobar-site-verification-123456
  • name: paloalto

forwarding: ttl: 60 target: flaky.cloud.example.com.

  • name: losangeles

addresses: literals:

  • 192.0.2.99
  • 2001:db8:200::99
  • Sets zone TTL
  • Pulls in “names” from templates
  • TXT resource record
  • CNAME resource record

(custom TTL)

  • A and AAAA resource records
slide-23
SLIDE 23

Templates

templates:

  • template: gmail

description: > This template adds Google mailservers to a zone. names:

  • name: '@'

mail: ttl: 604800 # 1 week = 604800 seconds mailservers:

  • mailserver: aspmx.l.google.com.

priority: 10

  • mailserver: alt1.aspmx.l.google.com.

priority: 20

  • name: google._domainkey

texts: data:

  • >

v=DKIM1; k=rsa; p=foobar123456

www egym de $NULL . . .

github.com/egymgmbh/papudns

slide-24
SLIDE 24

Go and YAML

  • Package yaml.v2

○ gopkg.in/yaml.v2

  • func Unmarshal(in []byte, out interface{}) (err error)

○ Byte stream to custom struct type ○ Struct fields are only unmarshalled if they are exported (have an upper case first letter), and are unmarshalled using the field name lowercased as the default key.

  • See demo!
slide-25
SLIDE 25

Go and DNS

  • Pure Go resolver

export GODEBUG=netdns=go # force pure Go resolver

  • Cgo resolver

export GODEBUG=netdns=cgo # force cgo resolver

  • Raw DNS queries

○ github.com/miekg/dns/

By default the pure Go resolver is used, because a blocked DNS request consumes only a goroutine, while a blocked C call consumes an operating system thread. https://golang.org/pkg/net/#Resolver

slide-26
SLIDE 26

On the wire: Pure Go resolver vs. Cgo resolver

16:33:52.097709 IP (tos 0x0, ttl 64, id 53695, offset 0, flags [DF], proto UDP (17), length 88) force.59722 > google-public-dns-a.google.com.domain : [bad udp cksum 0x7757 -> 0x35c8!] 18325+ [1au] AAAA? danrl.com. ar: . OPT UDPsize=4096 DO (60) 16:36:26.279509 IP (tos 0x0, ttl 64, id 15282, offset 0, flags [DF], proto UDP (17), length 88) force.55245 > google-public-dns-a.google.com.domain : [bad udp cksum 0x7757 -> 0x6724!] 10166+ [1au] AAAA? danrl.com. ar: . OPT UDPsize=4096 DO (60)

slide-27
SLIDE 27

Resolvers

  • See demo!
slide-28
SLIDE 28

CNAME

www.egym.de. dualstack.egym-server-1779992439.eu-west-1.elb.amazonaws.com. 2a01:578:3::36d9:cf8b 2a01:578:3::2e89:6e8a 2a01:578:3::36f7:bfb5 CNAME AAAA

slide-29
SLIDE 29

Putting it all together

  • DNS check

○ Install dns-check ○ Define expectations ○ Reality check

  • PaPuDNS

○ Install PaPuDNS ○ Define zone information ○ Deploy!

slide-30
SLIDE 30

Summary

  • We started building tools in Go

○ SRE ❤฀ Go

  • We intentionally NOT use goroutines for critical deployments

○ We want humans (slow) to be able to veto the tool’s actions (fast)

  • TODO: Use goroutines/channels for dns-check
  • TODO: Use single source of truth for monitoring, too

○ And see if that works well (debatable)

slide-31
SLIDE 31
  • career.egym.com (we are growing!)
  • code.egym.de (dev blog)
  • github.com/egymgmbh/papudns (deploy tool)
  • github.com/egymgmbh/dns-tools (monitoring tool)
  • @danrl_com (twitter)
  • danrl.com (my homepage)
  • github.com/danrl/playground-2017-08-gopher-meetup

(today’s code) What time is it? Time to socialize!