Cloud Native 14 min read

Kubernetes (K8s) from Beginner to Hands‑On: Complete 2026 Guide

This step‑by‑step tutorial walks you through preparing the environment, installing container runtimes, setting up a single‑master multi‑worker K8s cluster, deploying applications, managing configurations, enabling persistent storage, configuring health probes, applying namespaces and quotas, troubleshooting common pitfalls, and adding Prometheus‑Grafana monitoring, all with concrete commands and examples.

Golang Shines
Golang Shines
Golang Shines
Kubernetes (K8s) from Beginner to Hands‑On: Complete 2026 Guide

Kubernetes (K8s) is the de‑facto standard for container orchestration, automating deployment, scaling, operation, and failure recovery. This guide covers everything from environment preparation to advanced features, suitable for beginners and production‑grade use.

1. Prerequisites and Environment Setup

Understand three core concepts: Pod (smallest deployable unit), Node (master or worker server), and Controller (e.g., Deployment for pod lifecycle).

Configure hostnames, /etc/hosts, disable firewall, SELinux, and swap; set kernel parameters for networking and IP forwarding.

Install Containerd as the container runtime (Docker is deprecated) and configure it to use a domestic image registry and SystemdCgroup.

Add the Alibaba Cloud yum repository and install a stable Kubernetes version (v1.28.x), then enable and start kubelet.

2. Building the K8s Cluster (1 Master + Multiple Workers)

Initialize the master node with

# kubeadm init \
  --apiserver-advertise-address=192.168.1.100 \
  --image-repository=registry.aliyuncs.com/google_containers \
  --kubernetes-version=v1.28.3 \
  --service-cidr=10.96.0.0/12 \
  --pod-network-cidr=10.244.0.0/16

then configure kubectl for a regular user.

Deploy the Calico network plugin (download calico.yaml, adjust the pod CIDR, and apply).

Generate a join command on the master with kubeadm token create --print-join-command and execute it on each worker to add them to the cluster.

3. Core Operations

Deploy a sample Nginx application using a Deployment manifest with three replicas, resource limits, and a Service of type NodePort (port 30080) to expose it.

Common management commands: kubectl get pods, kubectl describe pod, kubectl logs, kubectl exec -it, scaling with kubectl scale deployment … --replicas=5, updating images with kubectl set image, and rolling back with kubectl rollout undo.

Configuration management via ConfigMap (plain text) and Secret (base64‑encoded) and mounting them into pods.

Persistent storage using PV and PVC (example 1 Gi volume) and mounting it in a Deployment.

Health checks: liveness, readiness, and startup probes defined in the pod spec.

Namespace isolation and resource quotas to limit pod count, CPU, and memory per namespace.

4. Common Pitfalls and How to Avoid Them

Image pull failures – use --image-repository with a domestic mirror.

Master node stuck in NotReady – ensure the network plugin is deployed and pod CIDR matches.

Worker join failures – regenerate token if expired and verify port 6443 is open.

Service unreachable – confirm Service selector matches pod labels and NodePort is within 30000‑32767 and allowed by the firewall.

PV/PVC binding issues – match accessModes and storage size, and ensure storageClassName consistency.

5. Monitoring and Troubleshooting

Basic kubectl commands: kubectl get componentstatuses, kubectl describe pod, kubectl top nodes, kubectl top pods.

Advanced monitoring with Prometheus Operator: apply manifests from the official repo and expose Grafana via NodePort (default credentials admin/admin).

6. Summary of Key Points

K8s cluster setup flow: environment init → container runtime → master init → network plugin → worker join.

Resource relationships: Deployment manages Pods, Service exposes them, ConfigMap/Secret handle configuration, PV/PVC provide persistence.

Avoid common issues by using domestic mirrors, ensuring network connectivity, matching labels and CIDRs, and checking firewall rules.

Following this tutorial enables you to build a functional K8s cluster from scratch, deploy applications, manage configurations and storage, and troubleshoot typical problems, laying a solid foundation for production‑grade deployments.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

monitoringdeploymentKubernetesdevopsprometheusgrafanak8scontainer orchestration
Golang Shines
Written by

Golang Shines

We share daily the latest Golang technical articles, practical resources, language news, tutorials, and real-world projects to help everyone learn and improve.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.