Slide 1

Slide 1 text

KUBERNETES, DEEP, DIVE Build your own kubernetes cluster from scratch - Part 1 Using Systemd to control Master/Worker components.

Slide 2

Slide 2 text

Dridi Walid, [email protected] - Kubernetes Consultant / Trainer - Cloud Native Engineer @FnacDarty Linkedin: https://www.linkedin.com/in/dridi-walid Who am I ?

Slide 3

Slide 3 text

1. Architecture Overview 2. Pause Container (POD) 3. ETCD 4. kube-apiserver 5. kubectl 6. kube-scheduler 7. kubelet 8. Run nginx pod 9. kube-proxy 10. kube-controller-manager 11. Q&A Agenda

Slide 4

Slide 4 text

Architecture Overview

Slide 5

Slide 5 text

1. Architecture Overview Node1 kube apiserver etcd controller manager scheduler kubectl kubelet Load Balancer End Users kubelet kube-proxy kube-proxy Node2 Container Runtime (Docker) Container Runtime (Docker) Pod1 Pod1 Developer Master Workers

Slide 6

Slide 6 text

Pause Container

Slide 7

Slide 7 text

2. Pause Container (POD) The ‘pause’ container is a container which runs a process that performs no function but sleeps forever and holds the network namespace for the pod. Pod should be the first process with PID 1 otherwise it throws an error. Kubernetes creates pause containers to acquire the respective pod’s IP address and set up the network namespace for all other containers to join that pod. Docker image used for pause container is http://gcr.io/google_containers/pause-amd64:3.0

Slide 8

Slide 8 text

2. Pause Container (POD) Pause Nginx Redis Linux Network Namespace 10.10.0.2 localhost:80 localhost:6379 /cache cache-volume POD

Slide 9

Slide 9 text

2. Pause Container (POD) Pause Nginx Ghost localhost IPC Network PID UTS(Hostname) ● IPC: Interprocess Communication ● Network: Virtual Network Interface ● PID: Process IDs ● UTS: Hostname Source: http://man7.org/linux/man-pages/man7/namespa ces.7.html Shared Linux Namespaces:

Slide 10

Slide 10 text

2. Pause Container (POD) IPC Pause docker images: Image: gcr.io/google_containers/pause-amd64:3.0 Source Code: https://github.com/kubernetes/kubernetes/tree/master/build/pause

Slide 11

Slide 11 text

2. Pause Container (POD) How to create a pod by using the pause container and sharing namespaces: Add nginx container to this pod to work as proxy to ghost container on port 2368: Start the pause container with Docker: // nginx.conf error_log stderr; events { worker_connections 1024; } http { access_log /dev/stdout combined; server { listen 80 default_server; server_name _; location / { proxy_pass http://127.0.0.1:2368; } } }

Slide 12

Slide 12 text

2. Pause Container (POD) How to create a pod by using the pause container and sharing namespaces: Add ghost container to this pod: Browse to localhost:8090, you should have ghost frontpage

Slide 13

Slide 13 text

2. Pause Container (POD) Inspect container IPs

Slide 14

Slide 14 text

2. Pause Container (POD) Resources: ● https://www.ianlewis.org/en/almighty-pause-container ● https://en.wikipedia.org/wiki/Linux_namespaces ● http://man7.org/linux/man-pages/man7/namespaces.7.html

Slide 15

Slide 15 text

ETCD

Slide 16

Slide 16 text

● Highly-available key value store thanks to Raft Distributed Consensus Protocol, ● Written in Go, ● Good for: ○ Shared configuration, ○ Service Discovery ● Simple http interface (Stored Objects are requested using curl) ● Watch specific keys for changes and react to changes in values, ● ... Features: 3. ETCD

Slide 17

Slide 17 text

Installation: 3. ETCD

Slide 18

Slide 18 text

3. ETCD Systemd unit:

Slide 19

Slide 19 text

Swagger documentation: 3. ETCD

Slide 20

Slide 20 text

3. ETCD

Slide 21

Slide 21 text

kube-apiserver

Slide 22

Slide 22 text

4. kube-apiserver API Server — The Gateway to Kubernetes ● Kubernetes objects are exposed via simple REST API through which basic CRUD operations are performed and API Server acts as the gateway to the platform. ● Internal components such as kubelet, scheduler, and controller access the API via the API Server for orchestration and coordination. ● The distributed key/value database, etcd, is accessible only through the API Server

Slide 23

Slide 23 text

4. kube-apiserver Installation:

Slide 24

Slide 24 text

Systemd unit: 4. kube-apiserver

Slide 25

Slide 25 text

Kubectl

Slide 26

Slide 26 text

5. Kubectl What’s kubectl: Is a client for the Kubernetes API, which is an HTTP API and every Kubernetes operation is exposed as an API endpoint and can be executed by an HTTP request to this endpoint.

Slide 27

Slide 27 text

5. Kubectl Installation:

Slide 28

Slide 28 text

5. Kubectl Developer k8S Cluster API SERVER ... localhost:800 Kubectl flow

Slide 29

Slide 29 text

5. Kubectl Kubectl version

Slide 30

Slide 30 text

5. Kubectl UI User Interface API CLI Command Line Interface Kubernetes Master Node 1 Node 1 Node 1 Node 1 Image Registry

Slide 31

Slide 31 text

5. Kubectl Get k8s version using a native curl http request

Slide 32

Slide 32 text

5. Kubectl The configuration file is by default located in: Set the KUBECONFIG environment variable:

Slide 33

Slide 33 text

kube-scheduler

Slide 34

Slide 34 text

6. kube-scheduler Installation:

Slide 35

Slide 35 text

Systemd unit: 6. kube-scheduler

Slide 36

Slide 36 text

kubelet

Slide 37

Slide 37 text

7. kubelet Installation:

Slide 38

Slide 38 text

7. kubelet Configuration:

Slide 39

Slide 39 text

Systemd unit: 7. kubelet

Slide 40

Slide 40 text

Run nginx pod

Slide 41

Slide 41 text

8. Run nginx pod Run nginx pod:

Slide 42

Slide 42 text

kube-proxy

Slide 43

Slide 43 text

9. kube-proxy Installation:

Slide 44

Slide 44 text

Systemd unit: 9. kube-proxy

Slide 45

Slide 45 text

kube-controller-manager

Slide 46

Slide 46 text

10. kube-controller-manager Installation:

Slide 47

Slide 47 text

Systemd unit: 10. kube-controller-manager

Slide 48

Slide 48 text

Q&A