Skip to content
William Kennedy edited this page Nov 4, 2023 · 136 revisions

Ultimate Go: Service with Kubernetes 4.1

This course teaches you how to build production-level services in Go, leveraging the power of Kubernetes.

From the beginning of the course, you will pair-program with your instructor Bill Kennedy as he walks you through the design philosophies, architectural decisions, and best practices as they apply to engineering a production-ready Go service.

With each new feature that is added to the service, you will learn how to deploy and manage the Kubernetes environment used to run the service. Throughout the class, the code being worked on is pushed to a repository for personal access and review.

For further class information, please see the Class Schedule

Course Videos

Service 4.1

This branch of code in this repo denotes the code that was used in the filming of the 4.1 video course.

https://github.com/ardanlabs/service/tree/service4.1

The repo contains the code that was written in the filming of the 4.0 video course and there is a well specified commit message for each push you will see in the video.

https://github.com/ardanlabs/service4.1-video

Service 4

This branch of code in this repo denotes the code that was used in the filming of the 4.0 video course.

https://github.com/ardanlabs/service/tree/service4

The repo contains the code that was written in the filming of the 4.0 video course and there is a well specified commit message for each push you will see in the video.

https://github.com/ardanlabs/service4-video

Course Curriculum

1.0 - Introduction

Introduction to the class and all the engineering that you will learn.

  • 1.1: Design Philosophy, Guidelines, What to Expect
  • 1.2: Tooling to Install
  • 1.3: Images to Install

2.0 - Modules

A walkthrough of how the module ecosystem works. We talk about the engineering decisions you need to make as they relate to modules.

  • 2.1: Adding Dependencies
  • 2.2: Module Mirrors
  • 2.3: Checksum Database
  • 2.4: Vendoring
  • 2.5: MVS Algorithm
  • 2.6: Upgrading Dependencies

3.0 - Deploy First Mentality

We begin to build the service with a focus on the ability to deploy the service in Kuberenetes.

  • 3.1: Project Layers, Policies, and Guidelines
  • 3.2: Prepare Project
  • 3.3: Logging

4.0 - Kubernetes

We introduce Kubernetes and get a K8s environment up and running. At this point, everything we do runs in the K8s environment.

  • 4.1: Clusters, Nodes and Pods
  • 4.2: Start the Kubernetes Cluster
  • 4.3: Create/Build Dockerfile for the Service
  • 4.4: Create/Apply K8s Deployment for the Service

5.0 - Kubernetes Quotas

We introduce applying Quotas to the deployment and discuss the problems that can result.

  • 5.1: Understanding CPU Quotas
  • 5.2: Understanding the Go Scheduler
  • 5.3: Adjust GOMAXPROCS to maximize performance

6.0 - Finish Initial Service Startup/Shutdown

We finish the initial startup and shutdown of the service.

  • 6.1: Configuration
  • 6.2: Debugging / Metrics
  • 6.3: Shutdown Signaling and Load Shedding

7.0 - Web Framework

We build out our own router by extending an existing one. This gives us a framework for injecting business logic into the processing of requests. It also allows for more consistency in the handling of requests.

  • 7.1: Basic Structure of an HTTP Router
  • 7.2: Liveness and Readiness Handlers
  • 7.3: Customize the Router
  • 7.4: Middleware Support
  • 7.5: Sending Responses

8.0 - Middleware

We add middleware functions for business-level logic that needs to be injected into the processing of requests.

  • 8.1: Logging
  • 8.2: Error Handling
    • 8.2.1: Understanding what Error Handling Means
    • 8.2.2: Declaring Custom Error Types
    • 8.2.3: Consistent Handling and Response
  • 8.3: Panic Handling
  • 8.4: Metrics

9.0 - JSON Web Tokens (JWT)

We gain an understanding of how JWT's work and their shortcomings.

  • 9.1: Understanding JWT
  • 9.2: Private/Public Key Generation
  • 9.3: Token Generation
  • 9.4: Token Signature Validation

10.0 - Key Store

We create a simple key store for the project to store and retrieve the private key.

  • 10.1: Key Store Package

11.0 - Authentication / Authorization

We integrate authentication and authorization support into the project by developing a packages to generate and validate tokens. Then we integrate the packages into the application and test things are working.

  • 11.1: Auth Package
  • 11.2: Open Policy Agent
  • 11.3: Auth Unit Test
  • 11.4: Add Middleware

12.0 - Liveness and Readiness

We talk about the need for liveness and readiness probes and how to integrate them into the solution.

  • 12.1: Check Group Routes
  • 12.2: K8s Base Sales Changes

13.0 - Database Support

We add a Postgres database to our K8s environment. Then we write a small database package that provides support for using the SQLx package more effectively. Finally, integrate the database package on application startup.

  • 13.1: Kubernetes Support for Postgres
  • 13.2: Create Database Package
  • 13.3: Update Readiness Handler to Perform DB Checks

14.0 - Database Migrations and Seeding

We define our schema and provide support for migration schema changes over time. We also provide support for seeding the database. Finally, we add support in Kubernetes to run the migration and seeding on POD startup.

  • 14.1: Maintaining Database Schemas
  • 14.2: Seeding Data
  • 14.3: Add Init Containers to Automate Migrations

15.0 - Domain Driven Data Oriented Archiecture

We talk about the data driven data oriented architecture that is implemented in the project. We discuss the design philosophy, guidelines, and semantics of how the three layers of App, Business, and Storage work together.

  • 15.1: Architecture Review
  • 15.2: Data Flow Trust vs Non-Trust

16.0 - App, Business, and Storage Implementation

We implement the Create domain inside the App, Business, and Storage layers.

  • 16.1: Business Layer Support
  • 16.2: Database Migration Support
  • 16.3: Storage Layer Support
  • 16.4: App Layer Support
  • 16.5: Run Entire Project To Test

17.0 - Unit Testing

We add docker and unit testing support for writing unit tests against a real database and write the actual user package tests.

  • 17.1: Starting and Stopping Containers
  • 17.2: Starting and Stopping a Test
  • 17.3: Write Unit Test

18.0 - Query Support and App Layer Testing

We add query support to the system and write an application layer test.

  • 18.1: Add Business, Storage, and App Layer Query Support
  • 18.2: Add filtering, ordering, and paging
  • 18.2: Write App Layer Test

19.0 - Transactions

We talk about how to add transactions to the system that will allow for cross domain transactions.

  • 19.1: Design Philosophies, Policies, and Guidelines
  • 19.2: Transaction Interfaces and Support
  • 19.3: Transaction Middleware
  • 19.4: Storage, Business, and Application Integration

20.0 - Observability

We add tracing to the project by integrating Open Telemetry and Zipkin.

  • 20.1: Integrate OTEL Web Handler into the Framework
  • 20.2: Integrate OTEL into Service Startup
  • 20.3: Add Tracing Calls Inside Functions to Trace
  • 20.4: Kubernetes Support for Grafana, Prometheus, Tempo, Loki, and Promtail

21.0 - Review Service Project

Review service project and get it running

  • 21.1: Check For Dependcy Upgrades
  • 21.2: Rebuild and Run the Project
Clone this wiki locally