$ show ghik/kubernetes-the-harder-way
This repository is a comprehensive guide and automation suite for setting up a production-like Kubernetes cluster on local machines (macOS/ARM64 and Linux/AMD64). It combines educational documentation with working bash scripts that automate the entire deployment process from VM provisioning to Kubernetes component installation. The codebase consists primarily of shell scripts for infrastructure automation (VM setup, network configuration, certificate generation, Kubernetes component deployment) and JSON/YAML configuration files for Kubernetes and TLS certificates. The architecture follows a multi-stage deployment pattern: host preparation → VM provisioning → security bootstrapping → control plane setup → worker node setup → cluster services installation. Key entry points include setupall.sh (master orchestration script), auth/genauth.sh (certificate generation), and various setup scripts for individual components (setupcontrol.sh, setupnode.sh, setupcluster.sh). The repository demonstrates solid DevOps engineering practices with idempotent scripts, proper error handling, and clear separation of concerns across different deployment stages.
The LLM identified 4 files worth highlighting for reuse:
Implements a complete PKI bootstrapping pattern for Kubernetes using cfssl. Generates CA, server certificates, client certificates, and kubeconfigs for all cluster components. The script demonstrates non-obvious skill in automating certificate lifecycle management with proper separation of concerns (CA config, CSR templates, kubeconfig generation). This component could be extracted and reused for any Kubernetes deployment requiring manual PKI setup.
Master orchestration script that coordinates the entire cluster deployment from absolute zero. Demonstrates sophisticated bash scripting with platform detection (macOS/Linux), parallel execution via background processes, proper environment variable management, and error handling. The script aggregates all other setup scripts and manages the deployment lifecycle. While tightly coupled to this specific guide, the orchestration pattern is reusable for other infrastructure automation projects.
Implements control plane component installation with proper systemd unit file generation. Demonstrates skill in configuring etcd cluster with mutual TLS, kube-apiserver with comprehensive security options, and controller components with leader election. The script shows deep understanding of Kubernetes architecture and security requirements. Could be adapted for other Kubernetes deployments with minimal modification.
Implements VM provisioning using QEMU with proper resource allocation, network configuration, and cloud-init integration. Demonstrates cross-platform compatibility (macOS/HVF vs Linux/KVM) and proper handling of virtualization acceleration. The script could be extracted for other VM-based infrastructure projects requiring automated provisioning.