single node setup

  • hardware based

    • kind
    • minikube
    • microk8s
    • kubeadm
  • cloud based

    • gcm
    • awx
    • azure
  • browser based

    • kodekloud.com

minikube

  • single node k8s cluster
  • downloads a iso
  • vbox or kvm (also docker)
  • needs: hypervisor, minikube and kubectl
  • check if virtualisation possible in /proc/cpuinfo

using minikube

# start minikube using kvm driver
> minikube start --driver=kvm2

# get minikube status
> minikube status

# get all pods
> kubectl get pod -A

# show dashboard (local installation)
> minikube dashboard

# create a test deployment
> kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4

# expose deployment using kubectl
> kubectl expose deployment hello-minikube --type=NodePort --port=8080

# get service ip using minikube
> minikube service hello-minikube --url
  >> http://192.168.49.2:31688

# show deployment
> kubectl get services hello-minikube

# opens al ocal browser to check deployment (local installation)
> minikube service hello-minikube

# forward port using kubectl
> kubectl port-forward service/hello-minikube 7080:8080

# create loadbalancer deployment
> kubectl create deployment balanced --image=k8s.gcr.io/echoserver:1.4
> kubectl expose deployment balanced --type=LoadBalancer --port=8080
# open tty2 and run (user must be part of the sudo group)
> minikube tunnel (usermod -aG kube wheel)
# show balanced services
> kubectl get services balanced
---
NAME       TYPE           CLUSTER-IP       EXTERNAL-IP      PORT(S)          AGE
balanced   LoadBalancer   10.109.217.183   10.109.217.183   8080:32361/TCP   14m
---

# delete service
> kubectl delete service hello-minikube

other minikube managing commands

# list services
> minikube service list

# get node ip address
> minikube ip

# pause minikube instantly
> minikube pause

# unpause minikube instantly
> minikube unpause

# stop minikube
> minikube stop
> minikube stop --all

# setup max avail memory
> minikube config set memory 16384

# list addons
> minikube addons list

# enable addon
> minikube addons enable ingress

# make kvm to the default driver
> minikube config set driver kvm2 

# start a multi node instance using kvm
> minikube start --nodes 3 -p multinode-demo --driver kvm2

# show status
> minikube status -p multinode-demo

# addon for multinode demo
> minikube addons enable ingress -p multinode-demo

# deploy a second cluster - in this case a older one
> minikube start -p aged --kubernetes-version=v1.16.1

# many options
> minikube start \
  --namespace=default \
  -p multinode-demo \
  --driver=kvm2 \
  --addons=ingress \
  --cpus=4 \
  --kvm-gpu=false \
  --nodes=3

# delete minikube deployments
> minikube delete --all
# or
> minikube delete -p multinode-demo
# under kvm you have to remove the network too
> virsh net-undefine --network mk-multinode-demo # wont work alone
# delete bridge manual
> ifconfig virbr0-nic down
> brctl delbr virbr0-nic

see also official: minikube/start

AlmaLinux

edit /etc/yum.repos.d/kubernetes.repo for kubectl repo

[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

install kubectl

dnf install kubectl

get minikube

# get bin
> curl -OL https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64

# move bin
> mv minikube-linux-amd64 /usr/local/bin/minikube

# make it executable
> chmod +x /usr/local/bin/minikube

minikube wont run at root - you have to create a user depending on your driver for this