Kubernetes Installation Methods
The Installation Landscape
There are several ways to get a Kubernetes cluster up and running, each with different trade-offs:
Installation Options
1. Managed Cloud Solutions
Cloud providers offer fully managed Kubernetes services:
- Pros: Fully managed, auto-upgrades, integrated with Google Cloud
- Cons: Vendor lock-in, limited Control Plane customization
- Best for: Production on Google Cloud
- Pros: AWS integration, managed Control Plane, high availability
- Cons: Additional cost, AWS-specific features
- Best for: Production on AWS
- Pros: Azure integration, free Control Plane, auto-scaling
- Cons: Azure ecosystem dependency
- Best for: Production on Azure
Managed Solution Benefits
- No Control Plane management overhead
- Automatic updates and security patches
- Built-in monitoring and logging
- High availability out of the box
- Quick to get started
2. Self-Hosted Solutions
For those requiring full control, self-hosted clusters are essential:
When to Self-Host
- On-premises requirements: Data must stay in your datacenter
- Regulatory compliance: Specific security/compliance needs
- Cost optimization: Existing hardware to utilize
- Full control: Need to customize every aspect
- Multi-cloud: Consistent deployment across providers
- Air-gapped environments: No internet connectivity
Self-Hosted Installation Tools
| Tool | Approach | Complexity | Best For |
|---|---|---|---|
| kubeadm | Official bootstrapping tool | Medium | Learning, manual setups |
| Kubespray | Ansible-based automation | Low-Medium | Production clusters, automation |
| kops | AWS-focused provisioning | Medium | AWS production clusters |
| Rancher | Complete platform | Low | Multi-cluster management |
| Manual | From scratch | Very High | Deep learning only |
Why Kubespray?
Kubespray is a crucial tool for self-hosted Kubernetes deployments:
Kubespray Advantages
- Standardization: Consistent, repeatable deployments
- Automation: Eliminates manual, error-prone tasks
- Ansible-based: Uses familiar automation tooling
- Production-ready: Battle-tested configurations
- Community support: Active development and maintenance
- Flexibility: Supports multiple platforms and configurations
- High availability: Multi-master setup support
The Kubespray Philosophy
Automation Focus
Kubespray's primary benefit is its ability to standardize and automate the labor-intensive process of assembling a Kubernetes cluster.
Instead of manually executing dozens of commands across multiple servers, you:
- Configure a host inventory once
- Set cluster parameters in YAML files
- Execute a single Ansible playbook
- Get a fully working cluster
What Kubespray Automates
Manual Steps (That Kubespray Handles)
Without automation tools, setting up a Kubernetes cluster requires:
With Kubespray
Key Takeaways
- Managed cloud solutions are convenient but offer less control
- Self-hosted clusters are needed for specific requirements
- Kubespray automates the complex installation process
- Standardization ensures consistent, repeatable deployments
Kubespray: Under the Hood
What Kubespray Does
Kubespray is an Ansible-based tool that automates the complete Kubernetes cluster installation process.
Kubespray Workflow
Define your nodes (masters, workers, etcd) in inventory file
Set cluster parameters (network CIDR, CNI plugin, versions)
Execute cluster.yml playbook
Install packages, configure container runtime, set up networking
Create all necessary PKI certificates for secure communication
Launch API Server, Scheduler, Controller Manager via static pods
Configure and start etcd across master nodes
Configure kubelet on workers, join to cluster
Deploy CNI plugin (Calico, Flannel, etc.)
Verify all nodes are Ready, system pods are running
Kubespray Installation Example
Step 1: Prepare Infrastructure
Step 2: Clone Kubespray
Step 3: Configure Inventory
Step 4: Configure Cluster Variables
Step 5: Deploy Cluster
Step 6: Verify Cluster
Critical Tasks Automated by Kubespray
1. Package Installation
Kubespray installs all required packages on all nodes:
- Container runtime (Docker, containerd)
- Kubernetes binaries (kubelet, kubeadm, kubectl)
- Network tools and dependencies
- System utilities
2. Certificate Generation
Security certificates are automatically generated for:
- API Server (server and client certificates)
- etcd cluster communication
- Kubelet client certificates
- Service account signing keys
- Front proxy certificates
3. Control Plane via Static Pods
Control Plane components are deployed as static pods:
Static Pods
Static pods are managed directly by kubelet (not by API Server). Manifests are placed in /etc/kubernetes/manifests/
Kubespray creates static pod manifests for:
kube-apiserver.yamlkube-controller-manager.yamlkube-scheduler.yamletcd.yaml
Kubelet reads these files and ensures the pods are always running.
4. Network Configuration
Kubespray sets up the complete network stack:
- Installs and configures CNI plugin
- Sets up pod network CIDR
- Configures service network
- Deploys kube-proxy
- Sets up DNS (CoreDNS)
Kubespray Advantages
Why Use Kubespray
- Idempotent: Can run multiple times safely
- Upgradeable: Supports cluster upgrades
- Scalable: Easy to add/remove nodes
- Configurable: Extensive customization options
- Production-tested: Used by many organizations
- Multi-platform: Supports various Linux distributions
- HA-ready: Multi-master setup out of the box
Kubespray Considerations
- Requires Ansible knowledge for customization
- Initial setup more complex than managed solutions
- You're responsible for infrastructure
- Playbooks can take 15-30 minutes to run
- Need to manage Kubespray version compatibility
kubeadm: The Community Standard
The Evolution of Kubespray
Kubespray has largely transitioned to using kubeadm under the hood. This shift represents a reliance on the community-accepted method for bootstrapping Kubernetes clusters.
What is kubeadm?
kubeadm is the official Kubernetes tool for bootstrapping clusters. It's maintained by the Kubernetes project itself and follows best practices for cluster initialization.
Why kubeadm Became Standard
Standardization Benefits
- Official tool: Maintained by Kubernetes project
- Best practices: Implements recommended configurations
- Consistency: Same method across different tools
- Community adoption: Other tools (Kubespray, kops) use it
- Well-documented: Extensive official documentation
- Regularly updated: Stays current with Kubernetes versions
How kubeadm Works
Install container runtime (Docker/containerd), kubelet, kubeadm
Initialize Control Plane, generate certificates, start components
Apply CNI plugin manifest (Calico, Flannel, etc.)
Join worker nodes to cluster using token
kubeadm Commands
Initialize First Master
Join Worker Nodes
Kubespray Uses kubeadm
When you run Kubespray, you'll see kubeadm commands being executed:
kubeadm's Responsibilities
1. Certificate Management
kubeadm has become the de facto standard for certificate generation:
- Creates CA (Certificate Authority)
- Generates all component certificates
- Manages certificate renewal
- Follows best practices for PKI
2. Configuration Writing
kubeadm creates standard configuration files:
3. Component Deployment
Control Plane components are deployed following standards:
- Static pods for Control Plane
- Consistent flags and arguments
- Standard RBAC configurations
- Best practice security settings
State Tracking with ConfigMap
When scaling or modifying the cluster, kubeadm records changes in a special ConfigMap:
Industry Adoption
kubeadm as Standard
kubeadm's methods have become the de facto standard that other tools follow:
- Kubespray: Uses kubeadm for cluster bootstrapping
- Helm charts: Expect kubeadm-style certificate locations
- Operators: Follow kubeadm patterns
- Documentation: Tutorials assume kubeadm structure
- Tooling: Third-party tools expect kubeadm conventions
Migration Challenge
Legacy Kubespray Migrations
For older Kubespray users who installed clusters before the kubeadm transition:
- Original (pre-kubeadm) installation method is deprecated
- Migrating in-place is complex and risky
- Recommended path: Stand up a new cluster using kubeadm method
- Migrate applications to new cluster
- Decommission old cluster
Cluster Configuration Best Practices
Node Role Planning
Separation of Concerns
Properly separating Control Plane and worker responsibilities is critical for production clusters.
Bad Practice: Co-located Masters and Workers
While technically possible to configure a cluster where master and worker roles are co-located on the same nodes (e.g., in a small three-node cluster), this is strongly discouraged for production environments.
Why Separate Control Plane and Workers?
Recommended Architecture
Node Role Best Practices
- 3 dedicated Control Plane nodes for HA
- Taint Control Plane nodes to prevent workload scheduling
- 3+ worker nodes for workload distribution
- Similar hardware within each role category
- Monitor separately - different metrics for each role
Network Planning
Proper network configuration is critical for cluster scalability and performance.
Pod Network CIDR
Pod Network Sizing
Recommendation: Allocate at least a /24 CIDR block for pods on each node.
This means 256 IP addresses per node (minus network overhead).
Service Network CIDR
Service Network Sizing
Recommendation: Allocate a subnet large enough for approximately 5,000 addresses for Services.
Complete Network Configuration Example
| Network Type | CIDR | Size | Purpose |
|---|---|---|---|
| Node Network | 192.168.1.0/24 | 256 IPs | Physical/VM network |
| Pod Network | 10.233.64.0/18 | 16,384 IPs | Container IPs |
| Service Network | 10.233.0.0/18 | 16,384 IPs | Service ClusterIPs |
Network Planning Tips
- No overlap: Ensure networks don't overlap
- Plan for growth: Better to over-provision than run out
- Document everything: Keep network diagrams updated
- Consider multi-cluster: Reserve CIDR space for future clusters
Container Runtime Configuration
Docker Version Specification
Contemporary Requirement
Modern Kubespray requires explicitly specifying the container runtime version.
Docker Deprecation Note
Kubernetes deprecated Docker as a container runtime (dockershim removal in v1.24). Modern deployments should use:
- containerd: Recommended, lightweight
- CRI-O: Alternative, Kubernetes-focused
CNI Plugin Selection
Comparing Network Plugins
| Plugin | Performance | Features | Complexity |
|---|---|---|---|
| Calico | High | Network policies, BGP, IPIP | Medium |
| Flannel | Medium | Simple overlay network | Low |
| Weave Net | Medium | Encryption, multicast | Medium |
| Cilium | Very High | eBPF, advanced policies | High |
Recommendation: Calico
Why Calico?
Based on production experience, Calico is preferred over Weave Net:
- Better performance: Faster packet processing
- Network policies: Built-in security features
- Scalability: Handles large clusters well
- BGP support: Integration with datacenter networks
- Active development: Regular updates and improvements
- No significant advantages in Weave Net
Complete Production Configuration
Configuration Best Practices Summary
- Dedicated Control Plane: Never co-locate with workloads in production
- Pod network: At least /24 per node
- Service network: ~5,000 addresses (/19 recommended)
- Container runtime: Specify version explicitly (use containerd)
- CNI plugin: Calico for production (proven performance)
- Plan for growth: Over-provision network CIDRs
- Document everything: Keep configuration in version control
Summary & Next Steps
What We've Learned
- Managed cloud solutions (GKE, EKS, AKS) are convenient but offer less control
- Self-hosted clusters needed for on-premises, compliance, or full control
- Multiple tools available: kubeadm, Kubespray, kops, Rancher
- Ansible-based tool for automated cluster deployment
- Standardizes and automates complex installation process
- Handles package installation, certificates, Control Plane setup
- Production-ready with HA support
- Official Kubernetes bootstrapping tool
- Kubespray uses kubeadm under the hood
- Industry standard for certificate management and configuration
- Stores cluster state in ConfigMap
- Dedicated Control Plane nodes (never co-locate in production)
- Pod network: /24 per node minimum
- Service network: ~5,000 addresses
- Use containerd as container runtime
- Calico for network plugin
Quick Reference Guide
Kubespray Installation Commands
kubeadm Manual Installation
Recommended Configuration
Common Operations
Add Worker Node
Upgrade Cluster
Backup and Restore
Troubleshooting Tips
| Issue | Check | Solution |
|---|---|---|
| Nodes NotReady | CNI plugin status | Verify network plugin pods running |
| Pods not scheduling | kubectl describe pod | Check taints, resources, node status |
| API Server down | Static pod manifest | Check /etc/kubernetes/manifests/ |
| Certificate errors | Certificate expiration | Renew with kubeadm certs renew all |
| etcd issues | etcdctl endpoint health | Check etcd logs, verify quorum |
Next Steps
Continue Your Kubernetes Journey
- Practice: Deploy a test cluster with Kubespray
- Experiment: Try different CNI plugins and configurations
- Learn Helm: Package manager for Kubernetes applications
- Implement monitoring: Prometheus, Grafana for observability
- Security hardening: RBAC, Pod Security, Network Policies
- CI/CD integration: Automate deployments
- Advanced topics: Service Mesh, Operators, Custom Resources
Resources
Official Documentation
- Kubernetes: kubernetes.io/docs
- Kubespray: github.com/kubernetes-sigs/kubespray
- kubeadm: kubernetes.io/docs/setup/production-environment/tools/kubeadm/
- Calico: docs.projectcalico.org
Final Recommendations
Production Deployment Checklist
- ✓ Use Kubespray for automated, standardized deployment
- ✓ Separate Control Plane and worker nodes
- ✓ Plan network CIDRs with growth in mind
- ✓ Use containerd (not Docker) as runtime
- ✓ Choose Calico for network plugin
- ✓ Configure HA with 3+ Control Plane nodes
- ✓ Enable audit logging and monitoring
- ✓ Regular etcd backups
- ✓ Document your configuration
- ✓ Test upgrade procedures
- ✓ Implement proper RBAC
- ✓ Plan disaster recovery