Cloud Native programming with Golang

Book description

Discover practical techniques to build cloud-native apps that are scalable, reliable, and always available.

About This Book
  • Build well-designed and secure microservices. Enrich your microservices with continous integration and monitoring.
  • Containerize your application with Docker
  • Deploy your application to AWS. Learn how to utilize the powerful AWS services from within your application
Who This Book Is For

This book is for developers who want to begin building secure, resilient, robust, and scalable Go applications that are cloud native. Some knowledge of the Go programming language should be sufficient.To build the front-end application, you will also need some knowledge of JavaScript programming.

What You Will Learn
  • Understand modern software applications architectures
  • Build secure microservices that can effectively communicate with other services
  • Get to know about event-driven architectures by diving into message queues such as Kafka, Rabbitmq, and AWS SQS.
  • Understand key modern database technologies such as MongoDB, and Amazon’s DynamoDB
  • Leverage the power of containers
  • Explore Amazon cloud services fundamentals
  • Know how to utilize the power of the Go language to access key services in the Amazon cloud such as S3, SQS, DynamoDB and more.
  • Build front-end applications using ReactJS with Go
  • Implement CD for modern applications
In Detail

Awarded as one of the best books of all time by BookAuthority, Cloud Native Programming with Golang will take you on a journey into the world of microservices and cloud computing with the help of Go.

Cloud computing and microservices are two very important concepts in modern software architecture. They represent key skills that ambitious software engineers need to acquire in order to design and build software applications capable of performing and scaling. Go is a modern cross-platform programming language that is very powerful yet simple; it is an excellent choice for microservices and cloud applications. Go is gaining more and more popularity, and becoming a very attractive skill.

This book starts by covering the software architectural patterns of cloud applications, as well as practical concepts regarding how to scale, distribute, and deploy those applications. You will also learn how to build a JavaScript-based front-end for your application, using TypeScript and React. From there, we dive into commercial cloud offerings by covering AWS. Finally, we conclude our book by providing some overviews of other concepts and technologies that you can explore, to move from where the book leaves off.

Style and approach

This book provides practical techniques, code examples, and architectural patterns required to build cloud native microservices in the Go language. It progresses through the subjects in a step-by-step manner. In each step, we cover the technical concepts behind it, the design considerations, and the code needed to build it.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Publisher resources

Download Example Code

Table of contents

  1. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Conventions
    5. Reader feedback
    6. Customer support
      1. Downloading the example code
      2. Downloading the color images of this book 
      3. Errata
      4. Piracy
      5. Questions
  2. Modern Microservice Architectures
    1. Why Go?
    2. Basic design goals
    3. Cloud service models
    4. Cloud application architecture patterns
      1. The twelve-factor app
      2. What are microservices?
      3. Deploying microservices
      4. REST web services and asynchronous messaging
    5. The MyEvents platform
    6. Summary
  3. Building Microservices Using Rest APIs
    1. The background
      1. So, what are microservices?
        1. Microservices internals
    2. RESTful Web APIs
      1. Gorilla web toolkit
      2. Implementing a Restful API
        1. Persistence layer
        2. MongoDB
        3. MongoDB and the Go language
      3. Implementing our RESTful APIs handler functions
    3. Summary
  4. Securing Microservices
    1. HTTPS
      1. Symmetric cryptography
        1. Symmetric-key algorithms in HTTPS
      2. Asymmetric cryptography
        1. Asymmetrical cryptography in HTTPS
    2. Secure web services in Go
      1. Obtaining a certificate
        1. OpenSSL
        2. generate_cert.go
      2. Building an HTTPS server in Go
    3. Summary
  5. Asynchronous Microservice Architectures Using Message Queues
    1. The publish/subscribe pattern
    2. Introducing the booking service
    3. Event collaboration
    4. Implementing publish/subscribe with RabbitMQ
      1. The Advanced Message Queueing Protocol
      2. RabbitMQ quickstart with Docker
      3. Advanced RabbitMQ setups
      4. Connecting RabbitMQ with Go
      5. Publishing and subscribing to AMQP messages
      6. Building an event emitter
      7. Building an event subscriber
      8. Building the booking service
    5. Event sourcing
    6. Implementing publish/subscribe and event sourcing with Apache Kafka
      1. Kafka quickstart with Docker
      2. Basic principles of Apache Kafka
      3. Connecting to Kafka with Go
      4. Publishing messages with Kafka
      5. Consuming messages from Kafka
    7. Summary
  6. Building a Frontend with React
    1. Getting started with React
      1. Setting up Node.js and TypeScript
      2. Initializing the React project
    2. Basic React principles
      1. Kick-starting the MyEvents frontend
      2. Implementing the event list
        1. Bringing your own client
    3. Building the event list components
      1. Enabling CORS in the backend services
      2. Testing the event list
      3. Adding routing and navigation
      4. Implementing the booking process
    4. Summary
  7. Deploying Your Application in Containers
    1. What are containers?
    2. Introduction to Docker
      1. Running simple containers
      2. Building your own images
      3. Networking containers
    3. Working with volumes
      1. Building containers
        1. Building containers for the backend services
      2. Using static compilation for smaller images
      3. Building containers for the frontend
    4. Deploying your application with Docker Compose
    5. Publishing your images
    6. Deploying your application to the cloud
    7. Introduction to Kubernetes
      1. Setting up a local Kubernetes with Minikube
      2. Core concepts of Kubernetes
      3. Services
      4. Persistent volumes
      5. Deploying MyEvents to Kubernetes
        1. Creating the RabbitMQ broker
          1. Creating the MongoDB containers
          2. Making images available to Kubernetes
          3. Deploying the MyEvents components
          4. Configuring HTTP Ingress
    8. Summary
  8. AWS I – Fundamentals, AWS SDK for Go, and EC2
    1. AWS fundamentals
      1. The AWS console
      2. AWS command-line interface (CLI)
      3. AWS regions and zones
      4. AWS tags
      5. AWS Elastic Beanstalk
    2. AWS services
      1. AWS SDK for Go
        1. Configuring the AWS region
        2. Configuring AWS SDK authentication
          1. Creating IAM Users
          2. Creating IAM Roles
        3. The fundamentals of the AWS SDK for Go
          1. Sessions
          2. Service clients
          3. Native datatypes 
          4. Shared configuration
          5. Pagination methods
          6. Waiters
          7. Handling Errors
      2. Elastic Compute Cloud (EC2)
        1. Creating EC2 instances
        2. Accessing EC2 instances
          1. Accessing EC2 instances from a Linux or macOS machine
          2. Accessing EC2 from Windows
          3. Security groups
    3. Summary
  9. AWS II–S3, SQS, API Gateway, and DynamoDB
    1. Simple Storage Service (S3)
      1. Configuring S3
    2. Simple Queue Service (SQS)
    3. AWS API gateway
    4. DynamoDB 
      1. DynamoDB components
        1. Attribute value data types
      2. Primary keys
      3. Secondary indexes
      4. Creating tables
      5. The Go language and DynamoDB
    5. Summary
  10. Continuous Delivery
    1. Setting up your project
      1. Setting up version control
      2. Vendoring your dependencies
    2. Using Travis CI
    3. Deploying to Kubernetes
      1. Using GitLab
        1. Setting up GitLab
        2. Setting up GitLab CI
    4. Summary
  11. Monitoring Your Application
    1. Setting up Prometheus and Grafana
      1. Prometheus's basics
      2. Creating an initial Prometheus configuration file
      3. Running Prometheus on Docker
      4. Running Grafana on Docker
    2. Exporting metrics
      1. Using the Prometheus client in your Go application
      2. Configuring Prometheus scrape targets
      3. Exporting custom metrics
    3. Running Prometheus on Kubernetes
    4. Summary
  12. Migration
    1. What is a monolithic application?
    2. What are microservices?
    3. Migrating from monolithic applications to microservices
      1. Humans and technology
      2. Cutting a monolithic application to pieces
      3. How do we break the code?
      4. Glue code
    4. Microservices design patterns
      1. Sacrificial architecture
      2. A four-tier engagement platform
      3. Bounded contexts in domain-driven designs
      4. Data consistency
        1. Event-driven architecture for data consistency
        2. Events sourcing
        3. CQRS
    5. Summary
  13. Where to Go from Here?
    1. Microservices communications
      1. Protocol buffers
      2. GRPC
    2. More on AWS
      1. DynamoDB streams
      2. Autoscaling on AWS
      3. Amazon Relational Database Service
    3. Other cloud providers
      1. Microsoft Azure
      2. Google Cloud Platform
      3. OpenStack
    4. Running containers in the cloud
    5. Serverless architectures
    6. Summary

Product information

  • Title: Cloud Native programming with Golang
  • Author(s): Mina Andrawos, Martin Helmich
  • Release date: December 2017
  • Publisher(s): Packt Publishing
  • ISBN: 9781787125988