How to install Kubernetes

Erik
Written by Erik on
How to install Kubernetes

Kubernetes is an open source software developed to manage and automate the operation of container virtualisation tools.

Table of Contents

  1. Environment requirements
  2. Configure SSH logins to machines
  3. Download k0sctl
  4. Install kubernetes on machines using k0sctl
  5. Kubernetes clients

Environment requirements

  • Minimum 2 machines

My virtual machines I installed Ubuntu Lite on both machines. VM

I use WSL as machine for the installation.

  • Minimum “4 GB RAM” preferably 8-16GB for more performance.

wsl

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.

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

Installing

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-nodes

List information of the cluster to which we are connected:

kubectl cluster-info

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 

node-info

Brief summary of the hardware:

kubectl top node

hardware-info

Erik

Erik

Hi! Im Erik I love computer security and in my spare time I do bug bounty or research.
Every day I try to learn something new, no matter how small it is.