Why kubernetes can make our life easier?

 

Fernando Ripoll

Docker?

The premise of docker

BUILD ONCE

RUN ANYWHERE

VMS vs containers?

How works?

Kubernetes?

Kubernetes

 

It is an open source system to manage containerised applications across multiple hosts, providing basic mechanisms for deployment, maintenance and

scaling of applications

 

Strengths of kubernetes

 

  • Velocity
     
  • Stateless
     
  • Declarative configuration
     
  • Self-healing platform
     
  • Immutability
     
  • Programable

Architecture

K8s is composed by a master and minions (nodes). A master contains the key components and nodes connect to it via an secure API thanks to an agent.

Master

 

  • API server
    It is the frontend control panel to manage kubernetes resources/objects
  • Control Manager
    It is in charge of maintain the desired state
  • Scheduler
    Select in which node a new container has to run
     
  • Etcd
    Is a distributed data storage used by kubernetes to store configuration and state

Nodes

 

  • Docker (or rkt)
    Underlying application container runtime
  • Kubelet
    Is the agent which talks with apiserver and performs actions requested and monitor the node containers
  • Kube-proxy
    Collaborates to maintain the VXLAN network

Networking

 

It uses a container networking provider to create a VXLAN

 

  • All containers can communicate with the rest without NAT
  • All nodes can communicate with all containers (and vice-versa) without NAT
  • Every container (pod) has a unique IP within the cluster
  • Developer has not to set up network configuration

Kubectl (CLI)

 

It is a command line interface for running commands against the cluster(s)

kubectl [command] [TYPE] [NAME] [flags]

DEMO

Objects and labels

 

They  are persistent entities used to represent the state of your cluster (defined as yaml or json docs).

Labels are key/value attached to objects for organazing and select group of objects

 apiVersion: #version of the Kubernetes API

 kind: #object type to create

 metadata: #name, labels, namespace

 spec: #Specification like container image, restart policy,...

Pod

The most basic resource 

  • Wraps an application container(s)
  • A unique IP (network)
  • Encapsulate storage
  • Represents a single unit of deployment
  • Can limit resources

Pod

Lets create a pod object definition

DEMO

 apiVersion: v1

 kind: Pod

 metadata:

    name: single-pod

 spec:

    containers:

    - name: my-awesome-app
      image: 172.17.4.1:5000/my-awesome-app:0.0.0

Pod

Lets create a pod object definition with multiple containers

DEMO

app

echo

  shared-data

Multi container pod example

curl

Replica set

Is a controller that helps to control pods

  • Before known as Replica Controller
  • Maintain a number of replicas
  • Used by deployment 
  • Managed by HPA (horizontal pod autoscaler) to scale
    number of replicas

Replica set

DEMO

 apiVersion: v1

 kind: ReplicaSet

 metadata:

    name: my-awesome-app

 spec:

    replicas: 3

    template:

      containers:

      - name: my-awesome-app
        image: 172.17.4.1:5000/my-awesome-app:0.0.2

Deployment

Is a controller one level up 

  • Control ReplicaSet resources
  • Do rollout of new or update of our containers
  • Do rollback of current deployments
  • Scale up/down containers

Deployment

The specification is the same as previous example

 apiVersion: v1

 kind: Deployment

 metadata:

    name: my-awesome-frontend-app

 spec:

    replicas: 2

    template:

      containers:

      - name: my-awesome-app
        image: 172.17.4.1:5000/my-awesome-frontend-app:0.0.1

DEMO

Service

Group a set of pods under an IP

  • Lets pods communicate between them
  • Decouple the service implementation
  • Match pods  by labels
  • Create the endpoints to route requests
  • Can resolve domains thanks to a DNS addon
  • There are three types of service
    • ClusterIP
    • NodePort
    • LoadBalancer

Service

 apiVersion: v1

 kind: Service

 metadata:

    name: mongo

 spec:

    selector:

​       db: mongo

    ports:

      - port: 27017

        protocol: TCP

DEMO

More objects

Other useful resources available

  • Secret
  • Daemon set
  • Job / Cron Job
  • Statefulset
  • Ingress
  • Config map
  • ...

Projects around

Interested projects running upon k8s

  • Service mesh (Istio/Envoy)
  • Open tracing (Jaeger)
  • Monitoring (prometheus)
  • Logging (ELK)
  • Open FAAS (serverless)
  • ...



    https://landscape.cncf.io

Thanks

 

Code available on 

https://github.com/pipo02mix/why_k8s_can_make_our_life_easier

 

@pipo02mix

info@tiatere.es

Made with Slides.com