Kubernetes (K8s) Complete Guide: From Architecture to Cluster Setup and Resource Management
This guide walks developers through the evolution from physical and virtual deployments to containerization, explains Kubernetes architecture and core components, demonstrates building a one‑master‑two‑node cluster with kubeadm and Flannel, and details resource management using YAML with imperative and declarative kubectl commands.
This article provides a comprehensive exploration of Kubernetes from a developer's perspective, covering the evolution of application deployment methods and Kubernetes fundamentals.
Application Deployment Evolution:
The article traces three eras of deployment: 1) Traditional deployment - directly deploying applications on physical machines, which lacks resource boundaries and causes interference between programs; 2) Virtualization deployment - running multiple VMs on one physical machine, providing isolation but wasting resources due to additional OS overhead; 3) Containerization deployment - sharing OS while maintaining isolated environments with own filesystem, CPU, and memory, enabling cross-cloud deployment.
Kubernetes Introduction:
Kubernetes is an open-source container orchestration tool originally developed by Google (Borg system). It本质上是a server cluster that manages containers through programs running on each node. Key features include: self-healing (restarting containers within ~1 second of failure), elastic scaling, service discovery, load balancing, version rollback, and storage orchestration.
Kubernetes Components:
A K8s cluster consists of Master nodes (control plane) and Node nodes (data plane). Master components include: API Server (resource operation entry point), Scheduler (resource allocation), Controller Manager (cluster state maintenance), and Etcd (storage). Node components include: Kubelet (container lifecycle management), KubeProxy (service discovery and load balancing), and Docker (container operations).
Cluster Setup:
The article demonstrates setting up a one-master-two-node cluster using kubeadm. Steps include: environment initialization (disabling swap, SELinux, configuring kernel parameters), installing Docker (version 18.06.3), installing Kubernetes components (kubeadm, kubelet, kubectl version 1.17.4), preparing cluster images, initializing the cluster, joining nodes, and installing the Flannel network plugin.
Resource Management:
Kubernetes abstracts all content as resources. The article covers YAML syntax (scalars, objects, arrays) and three management approaches: 1) Imperative object management - direct kubectl commands; 2) Imperative object configuration - kubectl with YAML files; 3) Declarative object configuration - kubectl apply for create/update operations.
Tencent Cloud Developer
Official Tencent Cloud community account that brings together developers, shares practical tech insights, and fosters an influential tech exchange community.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.