How to install Kubernetes
Kubernetes is an open source software developed to manage and automate the operation of container virtualisation tools.
Table of Contents
- Environment requirements
- Configure SSH logins to machines
- Download k0sctl
- Install kubernetes on machines using k0sctl
- Kubernetes clients
Environment requirements
- Minimum 2 machines
My virtual machines I installed Ubuntu Lite on both machines.
I use WSL as machine for the installation.
- Minimum “4 GB RAM” preferably 8-16GB for more performance.
Configure SSH logins to machines
Use ssh-copy-id root@192.168.20.134
to avoid having to put passwords in the ssh login and facilitate the installation.
Download k0sctl
Download the software.
- You can download the software here: github.com/K0sctl
Create a configuration file, send the init output to a yaml file where we will configure it in our own way.
k0sctl init > k0sctl.yaml
In my case it is: k0sctl.yaml
apiVersion: k0sctl.k0sproject.io/v1beta1
kind: Cluster
metadata:
name: k0s-cluster
spec:
hosts:
- ssh:
address: 192.168.20.134
user: root
port: 22
keyPath: /home/erik/.ssh/id_rsa
role: controller+worker
privateInterface: ens33
- ssh:
address: 192.168.20.135
user: root
port: 22
keyPath: /home/erik/.ssh/id_rsa
role: worker
privateInterface: ens33
k0s:
version: 1.23.5+k0s.0
Install kubernetes on machines using k0sctl
when everything is ready run the program that configures the installation, automating the process
k0sctl apply --config k0sctl.yaml
Install kubernetes client on our machine
sudo apt install kubernetes-client
Send the kubernetes configuration to a file called kubeconfig.
k0sctl kubeconfig > kubeconfig
In order to use this configuration, we indicate with the KUBECONFIG variable where it is located.
export KUBECONFIG=/opt/kubernetes/kubeconfig
Kubernetes client
List active nodes:
kubectl get nodes
Check that they are already active
List information of the cluster to which we are connected:
kubectl cluster-info
List detailed information of all nodes: You can see the information such as the type of operating system, the use of cpu, ram, the configuration of the node…
kubectl describe node
Specify description of a node:
kubectl describe node kubernetes-1
Brief summary of the hardware:
kubectl top node