Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Build_your_own_kubernetes_cluster_from_scratch_...

pocteo
March 31, 2020

 Build_your_own_kubernetes_cluster_from_scratch_-_Part_1.pdf

pocteo

March 31, 2020
Tweet

More Decks by pocteo

Other Decks in Technology

Transcript

  1. KUBERNETES, DEEP, DIVE Build your own kubernetes cluster from scratch

    - Part 1 Using Systemd to control Master/Worker components.
  2. Dridi Walid, [email protected] - Kubernetes Consultant / Trainer - Cloud

    Native Engineer @FnacDarty Linkedin: https://www.linkedin.com/in/dridi-walid Who am I ?
  3. 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
  4. 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
  5. 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
  6. 2. Pause Container (POD) Pause Nginx Redis Linux Network Namespace

    10.10.0.2 localhost:80 localhost:6379 /cache cache-volume POD
  7. 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:
  8. 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
  9. 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; } } }
  10. 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
  11. • 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
  12. 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
  13. 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.
  14. 5. Kubectl UI User Interface API CLI Command Line Interface

    Kubernetes Master Node 1 Node 1 Node 1 Node 1 Image Registry
  15. 5. Kubectl The configuration file is by default located in:

    Set the KUBECONFIG environment variable:
  16. Q&A