Skip to content

Quick Start

Install prerequisites

Please verify that you have properly installed the prerequisites.

Install K8s using ansible

Clone repo

git clone git@github.com:pawelmarkowski/kubernetes-learning.git

If you want to enable customized list of modules you can do it by defining proper vars ansible/inventories/training/group_vars/all.yml

Install requirements (ansible role microk8s) using ansible-galaxy.

ansible-galaxy role install -r ansible/playbooks/roles/requirements.yml --force

Run playbook (on localhost)

ansible-playbook -i ansible/inventories/training/hosts.yml ansible/playbooks/microk8s.yml --extra-vars "variable_host=localhost" -K

and voilà! MicroK8s is up, and running!

Configure kubectl (K8s command line tool)

if you have config print: microk8s config and add it to .kube/config manually

cd $HOME
mkdir .kube
cd .kube
microk8s config > config

optionally, but I do not recommend that - you can specify alias for microk8s kubectl command:

vi ~/.bashrc
alias mkctl="sudo microk8s kubectl"

you can also specify default namespace

kubectl config set-context --current --namespace=<insert-namespace-name-here>

if you have multiple contexts in your configuration file, you can switch context (different K8s clusters) using:

kubectl config use-context <contextname>

Basic commands

kubectl get nodes

kubectl apply -f <file.yml>

kubectl edit deployment -n <namespace>

kubectl get deployments -n <namespace>

kubectl logs <podname>

Important - LoadBalancers does not work on microK8s

  • deployment is blueprint for creating the pods (all informations needed to create the pod). It manages a replicaset
  • replicaset automatically created, it manages the replicas of pods(we do not have to create or delete it, just use deployments)
  • pod is the smallest unit, abstraction of container

We manage deployment only. Everything "below" is managed by K8s.

basics of kubectl you can find here https://youtu.be/X48VuDVv0do?t=2715