Bite-Sized Kubernetes Part 1 - Introduction & Overview
Tags: kubernetes, devops, containers
Published: 2023-03-06 22:14:34

## Ahoy Sailor!☸️

Learning Kubernetes can be daunting!
"Cluster"... "Deployments"... "Services"... what?!

As a newcomer to these concepts one is faced with either of two choices:
  1. Watch a 20-hour long Udemy course
  2. Dive into the [docs](https://kubernetes.io/docs/home/) which is probably longer than the King James Bible. And with a million links leading to an altogether new concept.

So you end up with a couple of half-finished courses, thousands of tabs of the docs pages open, some youtube videos, but mostly a great deal of confusion and regret!

![Meme1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t4nylwukq7t5lalmrh8t.png)*Source: https://9gag.com/gag/amPPxpX*

Sooooo we decided to write a series of blog posts to help a young cadet like yourself, get abreast quickly with the important concepts in kubernetes, in bite-sized posts with only need-to-know "points" to grasp the essentials. Our goal here is to choose the path of least resistance to set sail!

Feel free, of course, to move on after you're done here, to the official documentation and/or a detailed course, or get your hands dirty and deploy your own apps, or maybe even get certified. But assuredly, whatever you choose, you'll be able to go in with a certain level of confidence!

## Kubernetes Overview
- A kubernetes or k8s "cluster" consists of a set of k8s "nodes" i.e. machines.
  - K8s cluster: set of k8s nodes grouped together.
  - K8s node: the physical/virtual machine on which k8s software and tools are installed.
- There are 2 types of nodes in a k8s cluster:
  - K8s worker node: machine where the containers will be launched by k8s.
  - K8s master node: responsible for managing the worker nodes.
- The master node is the node with the k8s "control plane" components installed, we'll understand this in more detail.
- The master node is responsible for the orchestration of containers on the worker nodes.
- Kubernetes comprises of the following main components:
  - `API server` 
     - The API server is the front-end for the Kubernetes control plane.
     - It exposes the Kubernetes API and allows us to interact with the k8s cluster.
  - `etcd service` 
     - etcd is a distributed key-value store that stores all the data used to manage the cluster.
     - It is used to store the configuration data, metadata and the current state of all the k8s objects in the cluster.
     - it is responsible for implementing logs within the cluster.
  - `kubelet` 
     - The kubelet is an "agent" that runs on each node in the cluster.
     - It makes sure that containers are running in a pod.
  - `container runtime`
     - The container runtime is the underlying software that is responsible for running containers e.g. docker. 
  - `controller`
     - It is responsible for making sure that the specified number of pods are running at any given time and bring up new containers.    
  - `scheduler`
     - It is responsible for making sure that the containers are running on the right node.
- The master node has the `kube-apiserver` installed, worker nodes have the `kubelet` agent installed.
- All info about worker nodes is stored in a key-value store on the master i.e. `etcd`.
- The `controller` and `scheduler` exist also, on the master.
- The `container runtime` like docker runs on the worker nodes.
- Some basic commands:
    ```bash
    # run 1000 instances of my-app
    $ kubectl run --replicas=1000 my-app

    # scale it up to 5000 instances
    $ kubectl scale --replicas=5000 my-app

    # update these 5000 instances in a rolling upgrade
    $ kubectl rolling-update my-app --image=<image name>:<image tag>

    # rollback updates
    $ kubectl rolling-update my-app --rollback

    # deploy an app on a cluster
    $ kubectl run <image name>

    # see info about the cluster
    $ kubectl cluster-info

    # list all nodes in the cluster
    $ kubectl get nodes
    ```
- We will now, over the next few posts, explore the "objects" in kubernetes, e.g. pods, deployments, services, etc.
- These are the entities in the k8s architecture that we will be working with to deploy an application on k8s.
- Following are the k8s objects that we'll be looking at:
<table>
<tr><th>OBJECT</th><th>DESCRIPTION</th></tr>
<tr><td>Pods</td><td>The lowest level, single instance of an application</td></tr>
<tr><td>ReplicaSets</td><td>The next level, manages a set of pods</td></tr>
<tr><td>Deployments</td><td>The next level, manages a set of ReplicaSets</td></tr>
<tr><td>Services</td><td>The next level, manages a set of deployments</td></tr>
<tr><td>Ingress</td><td>The next level, manages a set of services</td></tr>
<tr><td>Volumes</td><td>The next level, manages a set of ingress</td></tr>
<tr><td>Namespaces</td><td>The next level, manages a set of volumes</td></tr>
<tr><td>Cluster</td><td>The highest level, manages a set of namespaces</td></tr>
</table>

In Part 2 we shall start by taking a look at "pods" in kubernetes.
Thank you for reading, hope you're excited!  
  
**Anchors Aweigh!!!**⚓