Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Network Automation with Go

You're reading from   Network Automation with Go Learn how to automate network operations and build applications using the Go programming language

Arrow left icon
Product type Paperback
Published in Jan 2023
Publisher Packt
ISBN-13 9781800560925
Length 442 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Michael Kashin Michael Kashin
Author Profile Icon Michael Kashin
Michael Kashin
Nicolas Leiva Nicolas Leiva
Author Profile Icon Nicolas Leiva
Nicolas Leiva
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Part 1: The Go Programming Language
2. Chapter 1: Introduction FREE CHAPTER 3. Chapter 2: Go Basics 4. Chapter 3: Getting Started with Go 5. Chapter 4: Networking (TCP/IP) with Go 6. Part 2: Common Tools and Frameworks
7. Chapter 5: Network Automation 8. Chapter 6: Configuration Management 9. Chapter 7: Automation Frameworks 10. Part 3: Interacting with APIs
11. Chapter 8: Network APIs 12. Chapter 9: OpenConfig 13. Chapter 10: Network Monitoring 14. Chapter 11: Expert Insights 15. Chapter 12: Appendix : Building a Testing Environment 16. Index 17. Other Books You May Enjoy

Developing distributed applications

Building a distributed application, such as bgp-ping, can be a major undertaking. Unit testing and debugging can help spot and fix a lot of bugs, but these processes can be time-consuming. In certain cases, when an application has different components, developing your code iteratively may require some manual orchestration. Steps such as building binary files and container images, starting the software process, enabling logging, and triggering events are now something you need to synchronize and repeat for all the components that include your application.

The final developer experience tool that we will cover in this chapter was specifically designed to address the preceding issues. Tilt helps developers automate manual steps, and it has native integration with container and orchestration platforms, such as Kubernetes or Docker Compose. You let it know which files to monitor, and it will automatically rebuild your binaries, swap out container images, and restart existing processes, all while showing you the output logs of all applications on a single screen.

It works by reading a special Tiltfile containing a set of instructions on what to build and how to do it. Here’s a snippet from a Tiltfile that automatically launches a bgp-ping process inside one of the host containers and restarts it every time it detects a change to main.go:

local_resource('host-1',
  serve_cmd='ip netns exec clab-netgo-host-1 go run main.go -id host-1 -nlri 100.64.0.0 -laddr 203.0.113.0 -raddr 203.0.113.1 -las 65003 -ras 65000 -p',
  deps=['./main.go'])

The full Tiltfile has two more resources for the other two hosts in our lab network. You can bring up all three parts of the application with sudo tilt up:

Network-Automation-with-Go $ cd ch10/bgp-ping
Network-Automation-with-Go/ch10/bgp-ping $ sudo tilt up
Tilt started on http://localhost:10350/

Tilt has both a console (text) and a web UI that you can use to view the logs of all resources:

Figure 10.8 – Tilt

Figure 10.8 – Tilt

Any change to the source code of the bgp-ping application would trigger a restart of all affected resources. By automating a lot of manual steps and aggregating the logs, this tool can simplify the development process of any distributed application.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image