Kubernetes

Table of content

Main concepts

Container Runtime Interface (CRI)

The CRIis the service that will handle the container created by Kubernetes.

The most famous one is Docker but others can be used such as containerd that is today officialy pushed by Kubernetes.

Docker is now depracted by Kubernetescause it does not expose a standardized API. Moreover, Docker is not a CRI but a wrapper allowing to easily manage the containerd CRI.

This, if you are deploying a brand new Kubernetes infrastructure, it is recommended to use containerd.

Master Node

This node is used to orchestrate all nodes.

It hosts the Kubernetes API.

Pod Network Controller (PNC)

A Pod Network is a way to allow communication between different nodes in the cluster.

Installing a PNC is a way to save a lot of time by discharging the network configuration to another service.

Several PNC exist. The most famous are :

  • Flannel : this PNC is a layer 3 controller based on VLAN
  • Calico : this PNC is a layer 2 controller base on NAT et supporte les networkPoliciesde Kubernetes via le fichier /etc/calico/calicoctl.cfg

Services

The services allows to expose an application running on pods

kubectl expose deployment/${deployementName} --type="NodePort" --port ${appPort} --target-port

Commands

List nodes

kubectl get nodes

List pods

kubectl get pods ${options}
  • --all-namespaces : display all pods whatever their namespaces
  • -l app=$appName : display the pods related to an application. The $appName must be the one set on application the deployment file.

Display information about a pod

kubectl describe pod ${podName}

The ${podName} is the name displayed by the get pods command.


Describe deployment

kubectl describe deployment ${deploymentName}

Execute command on a pod

kubectl exec -ti ${podName}

Install

Install the CRI

# Install contnaird
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
sudo echo "deb [arch=amd64] https://download.docker.com/linux/debian buster stable" > /etc/apt sources.list.d/docker.list
sudo apt update
sudo apt install containerd
sudo rm /etc/containerd/config.toml
sudo systemctl restart containerd

Install Kubernetes

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg |  apt-key add -
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list
apt update
apt install kubeadm kubelet kubectl -y

Network

sudo modprobe overlay
sudo br_netfilter
sudo modprobe br_netfilter
sudo swapoff -a
sudo sysctl -w net.ipv4.ip_forward=1
sudo sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf
sudo sysctl -p /etc/sysctl.conf

Init the master node

sudo kubeadm init --cri-socket /run/containerd/containerd.sock --pod-network-cidr=10.244.0.0/16
sudo mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Install the PNC

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

Resources

results matching ""

    No results matching ""

    results matching ""

      No results matching ""