Go for DevOps
Learn how to use the Go language to automate servers, the cloud, Kubernetes, GitHub, Packer, and Terraform
John Doak
David Justice
BIRMINGHAMMUMBAI
Go for DevOps
Copyright 2022 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Group Product Manager: Rahul Nair
Publishing Product Manager: Preet Ahuja
Senior Editor: Shazeen Iqbal
Content Development Editor: Romy Dias
Technical Editor: Shruthi Shetty
Copy Editor: Safis Editing
Project Coordinator: Ashwin Kharwa
Proofreader: Safis Editing
Indexer: Subalakshmi Govindhan
Production Designer: Joshua Misquitta
Marketing Coordinator: Sanjana Gupta
First published: June 2022
Production reference: 1010622
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-80181-889-6
www.packt.com
Monika, you are the North Star I guide my ship with and I love you with all my heart. I couldn't have done this without your support and guidance.
John Doak
To Deya, Will, Thor, and Tron, without whom my days would be as muted and monotone as this page.
David Justice
Contributors
About the authors
John Doak is the principal manager of Layer 1 Reliability Engineering at Microsoft. John led the development of the Azure Data Explorer and Microsoft Authentication Library Go SDKs. Previously, he was a Staff Site Reliability Engineer at Google. As part of network engineering, he created many of their first network automation systems. John led the migration of that group from Python to Go, developing Go training classes that have been taught around the world. He was a pivotal figure in transforming the network team to a network/systems group that integrated with SRE. Prior to that, he worked for Lucasfilm in video games and film. You can find his musings on Go/SRE topics and his Go classes on the web.
I'd like to thank Raleigh Mann who was my manager at both Lucasfilm and Google during most of my time there. His advice and steadfastness when standing beside me are why I still call him Boss today. Stephen Stuart, who gave me my initial foray into management, which I'm not sure I should thank or curse him for. Thanks to Less Lincoln, the man, the myth, the legend. Ive worked with Less for four years, hes as much a mystery box as when I first met him (and I think he likes it that way). Of course, I would never have gotten here without the love and support of my parents, I love you both. Thanks to Sarah Murphy, who was an early contributor to the book. And thanks to David Justice. Without his hard work and enthusiasm, I would not have been able to do this.
David Justice is the principal software engineer lead for the Azure K8s infrastructure and Steel Thread teams, which maintain a variety of CNCF and Bytecode Alliance projects. He is a maintainer of the Cluster API Provider Azure and a contributor to the Cluster API. Prior to that, David was the technical assistant to the Azure CTO, where he was responsible for Azure cross-group technical strategy and architecture. Early on at Microsoft, he was a program manager leading Azure SDKs and CLIs, where he transitioned all Azure services to describe them using OpenAPI specifications in GitHub and established automations to generate Azure reference docs, SDKs, and CLIs. Prior to working at Microsoft, David was the CTO of a mobile CI/CD SaaS called CISimple.
Thank you to my lovely, supportive wife, Deya, for encouraging me to pursue time-consuming activities such as writing a book, educational pursuits, start-ups, and her favorite, golf. Deya and Will, you will never know how much your love, hugs, and support powered me through late nights and droughts of creativity. This book would not be possible without the brilliance, reliability, and counter-perspectives of my coauthor, John, for whom the word example means a 30k-line robust application. Thank you to the whole Packt team and all the reviewers, but especially Romy Dias who edited my work into something more closely resembling English prose. Finally, thank you Dad and Papa for always believing in me.
About the reviewers
Trieu Pham is a software engineer with various technical ideas. His current focus and specialty are on API development, microservices, DevOps, and Golang. He has a bachelor's degree in mathematics and computer science, a master's degree in computer engineering, and a PhD in engineering.
Lukasz Sudol is a senior director of engineering at GumGum. He began working in the e-commerce industry by developing backend systems. During the past decade, his work has focused on developing high-availability application architectures for AdTech. He enjoys helping people to develop and working with interesting technologies.
I would like to thank my family, my fiancee Marcelina, and my friends who understand the time and commitment it takes to research and test engineering tools that are constantly changing. And to the reader, I hope my contribution will help you get through the book more easily.
Preface
When you get older it seems to me that most people reflect on their lives. How they got where they are, where they succeeded, and where they failed. I can say in all honesty that I've failed in my career. I know it is abnormal to start a book with an admission of failure, but I figure why start the book off with lies about succeeding beyond my wildest dreams?
My aspirations align more with Jimmy Buffet than Warren Buffet. Keeping my interest in anything for more than a few years is a challenge and my idea of a hard day's work is sipping a pia colada on a Hawaiian beach. Alas, I have failed in my ambitions. The closest to that dream I've gotten is working for a boss who always wore Hawaiian shirts and I don't think that counts.
This whole "expertise" in automation came out of my need to do as little work as possible. When I was a desktop support technician, I needed ways to build a lot of machines in a few hours instead of manually installing Windows and applications. I wanted to spend my days in the office playing video games, reading books, or walking around and talking to people. When I was a network engineer, I wanted people to stop paging me when I was comfortably sleeping in the switch closets around campus. So I wrote tools that allowed others to switch VLAN ports or clear security parameters from a network port without calling me. Why manually balance BGP traffic every week when I could write a program that used SFLOW data to do it?