How kubeop/k8s works
Main Components
• Ansible Control Node: The host where the playbooks and roles are executed.
• Inventory and Variable Configurations: The “inventory” file and the “group_vars/all.yml” which provide runtime parameters for nodes.
• Roles: Various modular components, each representing tasks for deploying Kubernetes elements:
• Core Roles: “master”, “worker”, “etcd”, “containerd” for setting up key cluster components.
• Network and Addons Roles: “network-plugins” (including subdirectories for calico, cilium, flannel, kube-router, etc.), “addons” (e.g., coredns, nodelocaldns, metrics-server, nvidia device plugin, helm).
• Utility Roles: “init” (for node initialization), “download” (for obtaining installation packages), “reset” (for cleaning up nodes), and additional roles such as “keepalived”, “haproxy”, “cert” (for certificate management) which handle special configurations.
• External Dependencies:
• Operating systems and supported platforms (AlmaLinux, RockyLinux, Ubuntu, Debian, etc.).
• External URLs and repositories (GitHub repositories for Kubernetes, etcd, containerd, and various network/application components).
Relationships and Interactions
• The Ansible Control Node communicates with various target nodes via SSH using the provided inventory.
• Each role in the file tree maps to a specific functionality (e.g., “roles/master” deploys and configures Kubernetes control-plane components; “roles/worker” installs and configures node-level services).
• The playbooks orchestrate tasks in a sequential pipeline: from pre-deployment disk partitioning (using the “fdisk.yml” play) to downloading packages (via “download.yml”) to actual cluster provisioning (via “cluster.yml”).
• Certain roles interact indirectly; for example, during certificate regeneration the “cert” role updates configurations across multiple nodes and services.
Architectural Patterns and Design Principles
• Modularity: The project is split into discrete roles for each cluster component, making it extensible and maintainable.
• Parameterization and Environment Abstraction: Configuration files (inventory, group_vars) abstract environment-specific details.
• Idempotence: Ansible playbooks are structured to ensure repeatable actions, illustrated by tasks like formatting disks, generating certificates, and redeploying services.
• Separation of Concerns: Separation between cluster initialization, core components installation, network plugin setup, and cluster expansion or upgrade processes.
• Automation Pipelines: The integration of GitHub workflows and release management indicates a CI/CD approach for deploying updates.
Relevant Technologies and Frameworks
• Ansible (as the automation engine) including the recommended version, along with Python.
• Kubernetes and its core components (API Server, Controller Manager, Scheduler, etcd, kubelet, kube-proxy).
• Container runtime (containerd) and CRI tools (crictl).
• Network plugins (Calico, Cilium, Flannel, Kube-Router).
• -ons such as coredns, metrics-server, GPU plugins, and helm.
• Supporting tools like haproxy and keepalived for load balancing and high availability.