k8s-controller

command module
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2025 License: GPL-3.0 Imports: 1 Imported by: 0

README ΒΆ

Kubernetes Controller

My implementation of the Golang Kubernetes Controller course from FWDays.

Visitor Go Reference GitHub Actions Workflow Status Repo size Updates

About

This project follows the step-by-step tutorial for building production-grade Kubernetes controllers in Go. Each step is implemented as a separate commit/branch with detailed explanations.

Course: Crash Course: Kubernetes controllers Instructors: @den-vasyliev (Principal SRE), @Alex0M (Senior Platform Engineer)

Quick Start

Prerequisites
One-Command Setup

Get a complete Kubernetes development environment running in seconds:

# Clone the repository
git clone https://github.com/Searge/k8s-controller.git
cd k8s-controller

# Initialize Podman machine and provision Kubernetes cluster
task init && task ssh -- 'cd /srv/app && go-task provision'

# Access your cluster
task ssh
kubectl get nodes
kubectl get all -A

This automated setup creates:

  • Podman machine with Fedora CoreOS
  • Complete single-node Kubernetes cluster (v1.30.0)
  • All control plane components (etcd, API server, scheduler, controller-manager)
  • Kubelet with containerd runtime
  • CNI networking with bridge plugin
  • PKI infrastructure with auto-generated certificates

Development Environment

The project includes a fully automated Kubernetes cluster setup for realistic controller development and testing. See ansible/README.md for detailed information about:

  • Automated cluster provisioning
  • Component configuration
  • Available Ansible tags for selective deployment
  • Troubleshooting and logging
Available Tasks

The project uses Taskfile for task automation:

# View all available tasks
task

# Development workflow
task dev          # Format, lint, test, build
task test-watch   # Run tests in watch mode
task docker-build # Build Docker image

# Environment management
task init         # Create and setup Podman machine
task ssh          # SSH into the machine
task provision    # Run Ansible provisioning
task reboot       # Restart the machine
task rm           # Remove the machine

Progress

  • Foundation

    • Golang CLI Application using Cobra
    • Structured logging with zerolog
    • HTTP server with FastHTTP
    • Comprehensive testing suite
    • Quality assurance with linters
    • Development environment automation
    • Documentation and examples
  • Kubernetes Integration (Next Steps)

    • List Kubernetes Deployments with client-go
    • Deployment Informer with client-go
    • JSON API Endpoint for deployments
    • controller-runtime Deployment Controller
    • Leader Election and Metrics
  • Advanced Features (Future)

    • Custom Resource (FrontendPage CRD)
    • Platform API (CRUD + Swagger)
    • JWT Authentication
    • OpenTelemetry Instrumentation
    • Helm Charts and GitOps

Architecture

C4Container
    title Kubernetes Controller Architecture

    Person(user, "DevOps Engineer", "Uses CLI")

    System_Boundary(app, "Controller Application") {
        Container(cli, "CLI Client", "Go, Cobra", "Command line interface")
        Container(server, "HTTP Server", "Go, FastHTTP", "REST API and UI")
        Container(controller, "Controller", "Go, controller-runtime", "Reconciliation logic")
        Container(informers, "Informers", "Go, client-go", "Watch and cache")
    }

    System_Ext(k8s, "Kubernetes API", "Manages cluster resources")

    Rel(user, cli, "Uses")
    Rel(cli, server, "Commands")
    Rel(server, k8s, "API calls")
    Rel(k8s, informers, "Events")
    Rel(informers, controller, "Cached data")
    Rel(controller, k8s, "Reconcile")

Project Structure

β”œβ”€β”€ ansible/              # Kubernetes cluster automation
β”‚   β”œβ”€β”€ README.md         # Detailed Ansible documentation
β”‚   β”œβ”€β”€ init.yml          # Initial system setup
β”‚   β”œβ”€β”€ provision.yml     # Main K8s provisioning
β”‚   └── templates/        # Service and config templates
β”œβ”€β”€ cmd/                  # CLI application code
β”œβ”€β”€ notebooks/            # Go learning notebooks
β”œβ”€β”€ scripts/              # Setup and utility scripts
β”œβ”€β”€ Taskfile.yaml        # Task automation
β”œβ”€β”€ Dockerfile           # Container image definition
└── README.md            # This file

πŸ“š Documentation

πŸ”— Resources

πŸ“„ License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

Built with ❀️ by @Searge

Documentation ΒΆ

Overview ΒΆ

Copyright Β© 2025 Sergij Boremchuk @Searge@hachyderm.io

Directories ΒΆ

Path Synopsis
Package cmd implements the command-line interface for the k8s-controller application.
Package cmd implements the command-line interface for the k8s-controller application.
pkg
logger
Package logger provides structured logging functionality using zerolog.
Package logger provides structured logging functionality using zerolog.
server
Package server provides HTTP server functionality for the k8s-controller application.
Package server provides HTTP server functionality for the k8s-controller application.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL