(Usage hints for this presentation)
IT Systems, Summer Term 2024
Dr. Jens Lechtenbörger (License Information)
(Source: (Casalicchio 2019))
Free container orchestrator
“Kubernetes logo” under Kubernetes Branding Guidelines; from GitHub
“Kubernetes Cluster Architecture” by © 2024 The Kubernetes Authors under CC BY 4.0; from Kubernetes Documentation
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
# 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
# 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
Stateful vs stateless servers
Stateless: No local state, can just spawn new replicas
Stateful: Maintain local state, need recovery in case of failures
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.