How will you install Kubernetes on bare metal and in the cloud?
sobes.tech AI
Answer from AI
For bare metal, I use kubeadm. First, I initialize the control plane nodes (kubeadm init), then add worker nodes (kubeadm join). I make sure to deploy a network plugin (such as Calico or Flannel). I consider the specifics of the network infrastructure and storage.
For cloud environments (such as AWS, GCP, Azure), I use managed Kubernetes services like EKS, GKE, or AKS. This relieves me from managing master nodes, scaling, and updates. The setup process involves creating a cluster via the cloud provider's web interface or CLI.
Differences:
| Bare Metal | Cloud |
|---|---|
| Full control | Managed service |
| Manual network and storage setup | Integrated with cloud resources |
| Responsibility for master nodes | Responsibility lies with the provider |
| More effort needed for High Availability | HA is usually built-in or easy to configure |
Example of kubeadm initialization:
# Initialize the control plane node
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
Example of joining a worker node:
# Command shown after initializing the control plane node
sudo kubeadm join <master-ip>:<master-port> --token <token> --discovery-token-ca-cert-hash sha256:<hash>
Using cloud CLI (AWS EKS):
# Example of creating an EKS cluster with eksctl
eksctl create cluster --name my-cluster --region eu-central-1 --node-type t3.medium --nodes 3
In both cases, after installation, kubectl must be configured to interact with the cluster.
# Configure kubectl
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Then, necessary applications, Helm charts are installed, and CI/CD is configured.