Kubernetes - MacKittipat/note-developer GitHub Wiki

What is Kubernetes

  • Container Orchestrator
  • Tools for manage container such as deploy, scaling container.

Why Kubernetes

1. Moving from Monolith to Microservices

Monolith

  • Each component tightly coupled. Have to developed, deployed and managed as one entity.
  • Change to one part require a deployment of whole application.
  • Require powerful server when application is getting bigger.
  • Good with scale up but expensive.

Microservices : Each service run as independent process and communicate with other service through APIs.

  • There are too many deployable component. Difficult to manage and configure. We need automation tool, Kubernetes.

Kubernetes

  • Abstracts away the hardware infrastructure and expose whole data-center as single enormous computational resource.

2. Providing consistent environment to application.

Application can run in same environment during development and in production.

3. DevOps and NoOps

Developer are able to deploy application without knowing about hardware and infrastructure.

Container technologies

Virtual Machine vs Container

  • When software components start getting smaller and their numbers start to grow, you can’t give each of them their own VM.
  • Containers are much more lightweight. Allows you to run higher numbers of software components on the same hardware.
  • Run a container, nothing needs to be booted up, as is the case in VMs. A process run in a container starts up immediately.

Kubernetes Introduction

  • Allows you to easily deploy and manage containerized applications on top of it.
  • Enable you to run application on thousands server as it is single server.

Architecture

  • Master node : Host Kubernetes Control Plane for control and manage Kubernetes system
    • Kubernetes API server
    • Scheduler
    • Controller Manager
    • etcd
  • Worker node : This is where containerized application run.
    • Docker or other container runtime.
    • Kublet
    • Kubernetes Service Proxy

Run application in Kubernetes

Package it up to container image, push to image registry, and the post description of app to Kubernetes API server.

Benefit of using Kubernetes

  • Decouple app from infrastructure.
  • App are freely move around cluster at anytime.
  • Monitor app and automatically reschedule them to other node in case of node failure.
  • Auto scale.

Component

Pods

  • Container of container, abstraction of container.
  • Co-located group of container.
  • Container should have only one process.
  • Pods may have multiple container in the same node.
  • Pods allow you to run related processes together.
  • Container should not run multiple processes and Pod should not contain multiple containers if they don't need to run on the same machine.

Service

  • Provide permanent IP to Pod
  • Load balance Pod
  • Span across nodes in cluster.
  • Type
    • ClusterIP
      • Provide internal IP in the cluster
      • Use as internal LB of services in cluster. For example service A want to call Service B (3 pods), we can create ClusterIP in front of Service B to load balance to 3 pods.
      • LB for private Service or DB
    • NodePort
    • LoadBalancer
    • ExternalName

Ingress

  • Route to Service

ConfigMap

  • Store config

Secret

  • Store secret such as credential

Deployment

  • Define blueprint for Pod (Stateless app)
  • Ensure Pod is always up and running
    • If the Node hosting an instance goes down or is deleted, the Deployment controller replaces the instance with an instance on another Node in the cluster.
  • Scale Pod
  • Support multiple deployment strategy
    • Rolling (Default)
    • Blue-Green
    • Canary
    • Rollback

StatefulSet

  • Define blueprint for Pod (Stateful app such as Database)
  • Similar to Deployment but for Stateful app such as Database

References