Imprint | Privacy Policy

Kubernetes

(Usage hints for this presentation)

IT Systems, Summer Term 2024
Dr. Jens Lechtenbörger (License Information)

1. Introduction

1.1. Core Questions

  • How to manage a cloud of computers?

Cloud of computers as abstract execution environment

1.2. Learning Objectives

  • Explain concepts for container orchestration in general and with Kubernetes
    • Including horizontal scaling for stateless servers
  • Explain digital sovereignty and cloud repatriation

1.3. Retrieval practice

Agenda

2. Container Orchestration

2.1. Orchestrator Features

  • Resource limit control
  • Scheduling
  • Load balancing
  • Health check
  • Fault tolerance
  • Autoscaling

(Source: (Casalicchio 2019))

3. Kubernetes (K8s)

3.1. Assorted Facts

  • “Datacenter as a Service”
    • Declarative description of cluster with compute, storage, networking

3.2. Architecture Diagram

Kubernetes Cluster Architecture

Kubernetes Cluster Architecture” by © 2024 The Kubernetes Authors under CC BY 4.0; from Kubernetes Documentation

3.3. Basic Concepts

  • Node, pod, container, controller: Previous slide
  • Resources
    • Entities representing state
    • Selected examples (full documentation):
      • Namespace: Working area, separates different environments
      • Pod: Collection of containers, unit of scheduling
      • Service: Abstraction for exposing network application with one or more pods; think of load balancer
      • Deployment: API object managing pods (including replication)
      • PersistentVolume: Piece of (cloud) storage
      • PersistentVolumeClaim: Request to create PersistentVolume

4. K8s Examples

4.1. Minikube Installation

4.2. Create K8s Cluster with nginx

minikube start # Just one node; use options for more
kubectl cluster-info
kubectl get nodes
kubectl get pods -A # Pods of all namespaces; so far, control plane
kubectl apply -f https://gitlab.com/oer/cs/programming/-/raw/main/k8s/nginx-deployment.yaml # Add nginx with 3 replicas
kubectl get pods -l run=my-nginx -o wide # Note names and IP addresses of pods
minikube ssh
curl <pod-ip-address> # Performs GET request to nginx in pod; shows HTML
exit
kubectl apply -f https://gitlab.com/oer/cs/programming/-/raw/main/k8s/nginx-service.yaml
minikube service nginx-service # Connect to nginx cluster
kubectl exec -it <pod-name-from-above> -- bash # Maybe change index.html of nginx
minikube delete --all
kubectl explain deployment
kubectl explain deployment.spec.selector

4.2.1. Sample Deployment

# SPDX-FileCopyrightText: 2024 Jens Lechtenbörger
# SPDX-License-Identifier: CC0-1.0

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      run: my-nginx
  replicas: 3
  template:
    metadata:
      labels:
	run: my-nginx
    spec:
      containers:
      - name: nginx-container
	image: nginx
	ports:
	- containerPort: 80

4.2.2. Sample Service

# SPDX-FileCopyrightText: 2024 Jens Lechtenbörger
# SPDX-License-Identifier: CC0-1.0

apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    run: my-nginx
  ports:
    - port: 80
      targetPort: 80
  type: LoadBalancer

4.3. Web App with Frontend and Backend

  • Stateful vs stateless servers

    • Stateless: No local state, can just spawn new replicas

    • Stateful: Maintain local state, need recovery in case of failures

      • E.g., database server, filesystem

4.4. Self-Study

5. Conclusions

5.1. Cloud Repatriation

  • Cloud repatriation: Bring workload back from cloud
  • Reasons
    • Rising cloud bills (depending on use, millions of Euro per year)
      • Instead, invest in own infrastructure and personnel
      • See (Murugesan 2024) for examples and discussion
    • Digital sovereignty
      • Public cloud is not “much easier” any more
      • Full control over private cloud
      • Security concerns, e.g., confidentiality of R&D data or proprietary code

5.2. Summary

  • Software architecture may contain numerous containers
    • Container orchestrator for management
      • Kubernetes as dominant software solution
        • Cluster with control plane and work nodes
        • Declarative description in YAML files
        • Reconciliation loops by controllers
        • Pods as units of scheduling, services for network access
      • “Datacenter as a service”
  • Cloud repatriation
    • Migration of cloud workloads “back home”
    • Cost and digital sovereignty
    • Kubernetes also as on-premise tool

Bibliography

Casalicchio, Emiliano. 2019. “Container Orchestration: A Survey.” In Systems Modeling: Methodologies and Tools, edited by Antonio Puliafito and Kishor S. Trivedi, 221–35. Cham: Springer International Publishing. https://doi.org/10.1007/978-3-319-92378-9_14.
Murugesan, Ganesh Kumar. 2024. “Cloud Services –- Boon or Bane: A Comprehensive Review.” In Southeastcon 2024, 108–12. https://doi.org/10.1109/SoutheastCon52093.2024.10500027.

License Information

Source files are available on GitLab (check out embedded submodules) under free licenses. Icons of custom controls are by @fontawesome, released under CC BY 4.0.

Except where otherwise noted, the work “Kubernetes”, © 2024 Jens Lechtenbörger, is published under the Creative Commons license CC BY-SA 4.0.