Single-Node Setup
Single-Node Cluster Installation¶
Setting up a single-node Kubernetes cluster is an essential first step for learning Kubernetes. This section covers three common methods: kubeadm, kops, and Minikube. Each approach has its use cases, from bare-metal setups to local development environments.
Using kubeadm (Manual Setup)¶
kubeadm is a tool for bootstrapping clusters, ideal for testing or small-scale deployments. It requires a clean Linux environment with prerequisites installed.
Prerequisites¶
- Linux distribution (Ubuntu, CentOS, etc.)
- Disable swap:
sudo swapoff -a - Ensure kernel is up to date
Step-by-Step¶
-
Install Kubernetes components:
-
Initialize the cluster:
This creates the API server, etcd, and kubelet services. The output includes akubeadm joincommand for worker nodes (not needed for single-node). -
Configure kubeconfig:
-
Install a CNI plugin (e.g., Calico):
-
Verify the cluster:
Using kops (Cloud-Native Setup)¶
kops (Kubernetes Operations) is designed for managing clusters on cloud providers like AWS, GCP, or Azure. It can also be used with local VMs, though it’s more suited for multi-node clusters.
Prerequisites¶
- Cloud provider account (or local VM setup)
- kops CLI installed
Step-by-Step¶
-
Create a cluster configuration (example for AWS):
-
Create and configure the cluster:
-
Access the cluster:
Note: For local VMs, replace S3 storage with a local path and adjust networking.
Using Minikube (Local Development)¶
Minikube is perfect for developers needing a lightweight, isolated Kubernetes environment. It runs a single-node cluster in a VM or Docker container.
Prerequisites¶
- Docker or a hypervisor (e.g., VirtualBox)
- Minikube CLI installed
Step-by-Step¶
-
Start Minikube:
Replacevirtualboxwithdockerif using Docker. -
Verify the cluster:
-
Deploy a sample app (e.g., Nginx):
-
Access the app:
Key takeaways¶
- kubeadm is ideal for manual, bare-metal setups but requires careful configuration.
- kops excels in cloud environments but is more complex for single-node use.
- Minikube is the simplest choice for local development, offering quick setup and teardown.
- All methods require attention to system requirements (e.g., swap disabled, kernel updates).