Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Infrastructure Testing Using Kubernetes And Gol...
Search
Ran Tavory
May 06, 2019
Technology
120
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Infrastructure Testing Using Kubernetes And Golang
Ran Tavory
May 06, 2019
More Decks by Ran Tavory
See All by Ran Tavory
go-grpc-channelz: a Go based UI for gRPC's channelz
rantav
0
660
Code Review (Navy Hackathon)
rantav
0
120
Infrastructure testing using Kubernetes
rantav
0
610
Interview Workshop - Technical Questions
rantav
0
380
Code Review Best Practices
rantav
0
130
Code Review @ AppsFlyer
rantav
0
120
GraphQL at Yodas
rantav
2
190
Git for champs
rantav
0
190
Code Review at Yodas
rantav
0
220
Other Decks in Technology
See All in Technology
個人開発で育てる「大規模設計の苗床」 - AI時代の1人開発から始める業務への知識接続 / The Seedbed for Large-Scale Design - From AI-Era Solo Projects to Professional Knowledge
bitkey
PRO
1
280
AI時代のPlaywright活用(システムテストを自動化する ー 実行エンジンにPla ywrightを選んだ理由)
ynisqa1988
0
120
ソニー銀行におけるビジネスアジリティ向上のためのクラウドシフト戦略
srenext
0
680
Empower GenAI with Agile - あなたのアジャイルが生成AIのバフになる仕組み
hageyahhoo
1
210
公式ドキュメントの歩き方etc
coco_se
1
120
2年前に削除したPHPクラスが、 ある日突然決済をエラーにした
ykagano
1
260
凡エンジニアがこの先生きのこるためには。〜TypeScript完全に理解したい〜
alchemy1115
2
310
LLMやAIエージェントをソフトウェアに組み込むプラクティス
shibuiwilliam
2
410
「AIに依存している」と 「AIを使いこなしている」の違い
k8yasuma
0
110
壊して学ぶAWS CDK: そのcdk deployで消えるもの、残るもの
k_adachi_01
1
360
発表と総括 / Presentations and Summary
ks91
PRO
0
140
ファミコンでPHPを動かす / PHP on the Famicom
tomzoh
2
320
Featured
See All Featured
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
970
Raft: Consensus for Rubyists
vanstee
141
7.6k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
How to Talk to Developers About Accessibility
jct
2
370
Building Adaptive Systems
keathley
44
3.1k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
300
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
610
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.4k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Transcript
Infrastructure testing using Kubernetes @rantav
OR: Testing Kafka replication over the Atlantic using Golang, Kubernetes
and friends
Hello! I am Ran Tavory I work on multi-region at
appsflyer You can find me @rantav (twitter/gmail/facebook) 3
The Goal: Test Kafka Replication ⊙ Replicate 30MB - 300MB
of traffic per second ⊙ Validate correctness ⊙ Measure latency ⊙ Run test cases (failure scenarios) ◦ Broker crash, cluster resize, packet loss... 4
Kafka ? Queueing System Stream Processing Brokers Partitions 5
HOW ? High level design 6
Kafka Replication From https://github.com/AppsFlyer/kafka-mirror-tester 7
With a home-grown producer and consumer written in golang 8
WHAT DO WE WANT? 9 DOCUMENTATION HOW DO WE DO
IT?
WHAT DO WE WANT? 10 REPRODUCIBILITY HOW DO WE DO
IT?
WHAT DO WE WANT? 11 MONITORING HOW DO WE DO
IT?
KUBERNETES 12
You keep saying this word Kubernetes What does it mean?
13
A brief introduction to Kubernetes 14
CLUSTER MANAGER Kubernetes is a 15
NODES The host running a kubelet and a set of
Pods 16 It manages
PODS Pods consist of 1 or more containers 17 Nodes
contain
DEPLOYMENTS A set of stateless pods 18 Pods run
STATEFUL SET A set of stateful pods 19 Pods also
run
KUBECTL The k8s CLI 20 You control k8s using
“
$ make k8s-all 22
What does that do? ⊙ Provision VMs in AWS ⊙
Setup VPCs, Subnets, Routing Tables ⊙ Create Security Groups ⊙ Setup Load Balancers ⊙ Install Kubernetes (etcd, masters, nodes) ⊙ Setup Monitoring (Prometheus & Grafana and install dashboard) ⊙ Install Weave Scope ⊙ Install Kafkas (and test them) ⊙ Install uReplicator (and test it) ⊙ Install test programs ⊙ And more… (ASGs, DHCP etc) 23
$ kops create cluster \ --zones us-east-1a,us-east-1b,us-east-1c \ --node-count 40
\ --node-size i3.large \ --master-size m4.large \ --master-zones us-east-1a \ --networking calico \ --cloud aws 24
What are we building? us-east-1 25 eu-west-1
What are we building? us-east-1 40 nodes k8s cluster 26
eu-west-1 48 nodes k8s cluster
What are we building? us-east-1 40 nodes k8s cluster 30
brokers kafka cluster 27 eu-west-1 48 nodes k8s cluster 30 brokers kafka cluster
What are we building? us-east-1 40 nodes k8s cluster 30
brokers kafka cluster 28 eu-west-1 48 nodes k8s cluster 30 brokers kafka cluster 8 workers uReplicator
What are we building? us-east-1 40 nodes k8s cluster 30
brokers kafka cluster 10 producers 29 eu-west-1 48 nodes k8s cluster 30 brokers kafka cluster 8 workers uReplicator 4 consumers
30 End Result
31 Grafana Dashboard
32 Prometheus
33 Weave Scope
34 Weave Scope
35 Weave Scope
36 kubectl example
TEST IT. Let’s put all this to test now 37
$ kubectl \ --context us-east-1.k8s.local \ -n kafka-source \ delete
pod kafka-source-2 38 KILL A BROKER
39 KILL A BROKER
$ kubectl \ --context us-east-1.k8s.local \ -n kafka-source \ scale
\ statefulset kafka-source \ --replicas 29 40 RESIZE KAFKA CLUSTER
41 RESIZE KAFKA CLUSTER
$ kubectl \ --context eu-west-1.k8s.local \ -n ureplicator \ scale
deployment \ ureplicator-worker \ --replicas 9 42 ADD uREPLICATOR WORKER
43 ADD uREPLICATOR WORKER
$ make k8s-redeploy-tests 44 ADD NEW TOPIC
45 ADD NEW TOPIC
$ make k8s-kafka-shell-source $ bin/kafka-topics.sh --zookeeper zookeeper:2181 --alter --topic topic5
--partitions 300 46 ADD PARTITIONS
$ kubectl --context eu-west-1.k8s.local \ -n ureplicator port-forward \ ureplicator-controller-76ff85b889-l9mzl
9000 $ curl -X DELETE http://localhost:9000/topics/topic5 $ curl -X POST -d \ '{"topic":"topic5", "numPartitions":"300"}' \ http://localhost:9000/topics 47 ADD PARTITIONS (cont)
48 PACKET LOSS
49 PACKET LOSS
CODE DEEP DIVE Golang Producer/Consumer (just a few bites) 50
51 Producer Main loop
52 Rate limit in Golang The classic gobyexample
53 Rate limit in Golang The classic gobyexample What is
the problem here?
54 Rate limit in Golang Solution: Use package rate
55 Rate limit in Golang Other solutions: Juju and Uber
56 Producer: using channels and the c library librdkafka p.ProduceChannel()
<- m
57 Consumer Main loop Loop select until: signaled || done.
Process event
58 Consumer Process message
“ Question: How can multiple consumers validate message arrival order?
59
60 Producer Sequence numbers messageKey = seq % partitions perKeySeq
= seq / partitions
CODE DEEP DIVE Kubernetes, head first (just a few bites)
61
62 Kafka kind: StatefulSet replicas: 30
Kafka Main container 63 image ports resources probes
64 Kafka config
65 Metrics sidecar container
66 Kafka anti- affinity
67 uReplicator deployment
68 Producer deployment
69 Consumer deployment
70 Service monitoring
$ make k8s-delete-all 71
72
Thanks! Any questions? You can find me at @rantav &
[email protected]
73 This presentation: https://speakerdeck.com/rantav/infrastructure-testing-using-kubernetes- and-go The project: https://github.com/AppsFlyer/kafka-mirror-tester