An introduction to Kubernetes

Sacha Bernheim - April 16th 2024

About Me

  • Former Senior SRE at Padok
  • M2 Intern in Quantum Information at QAT Team

How to deploy?

C++ Java Golang Python Julia
Web Applications ? ? ? ? ?
Data Processing Applications ? ? ? ? ?
Others ? ? ? ? ?

Another industry had a similar issue...

Container Docker

How to deploy?

C++ Java Golang Python Julia
Web Applications
Data Processing Applications
Others

Is it enough?

  • Handling Failures and Restarts: How to ensure continuity?
  • Handling Cardinality: How to manage scaling?

Enter Kubernetes

Open-source solution for deploying softwares across multiple (Linux) machines.
Container orchestrator with an extensible declarative API

Kubernetes architecture overview

Kubernetes: A Declarative CRUD API

  • Establish new resources in etcd through the API.
  • Retrieve the current state of resources directly from etcd.
  • Modify resources in etcd via the API to match the desired state.
  • Erase resources from etcd when they're no longer needed.

Reconciliation Loops

  • Kubernetes controllers constantly monitor the state of resources.
  • Any discrepancies between the declared state and the actual state are addressed.
  • Automatically corrects deviations, ensuring reliability and stability.

Extensible API with CRDs

  • Define and manage your own resources, expanding Kubernetes capabilities.
  • Use CRDs to introduce custom operational knowledge and workflows. The open-source ecosystem is HUGE.
  • Tailor Kubernetes to meet the specific needs of your project.

Pod: The Atomic Unit

apiVersion: v1
kind: Pod
metadata:
  name: nginx-pod
  labels:
    app: nginx
spec:
  containers:
  - name: nginx-container
    image: nginx:1.14.2
    ports:
    - containerPort: 80
  • Host closely related containers that need to work together.
  • Generally ephemeral and created or destroyed to match the desired state.
  • Share data between containers in a Pod.

Deployments for Managing Pods

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
  • Deploy new versions of your application.
  • Easily revert to a previous version if something goes wrong.
  • Handle increasing load by scaling out pods.

Service: Consistent Access Point

apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  type: LoadBalancer
  • Pods within a cluster can access services through their stable endpoints.
  • Services can load-balance traffic to multiple Pod instances.
  • Expose Pods to the internet or keep them only within the cluster.

ConfigMap: Configuration Data

apiVersion: v1
kind: ConfigMap
metadata:
  name: app-config
data:
  log_level: "INFO"
  enable_debug: "true"
  • Store configuration files, command-line arguments, environment variables.
  • Update configurations without changing the container image.
  • Easily integrated with Pods to provide configuration data.

A lot of others resources

HorizontalPodAutoscaler, Namespace, RBAC resources, Secret, Ingress...

Useful references

It's Q&A time!