# Kubernetes Workshop
---
# Agenda
- What is Kubernetes?
- What does it do?
- How does it work?
- lots of demos
---
# What is Kubernetes (k8s)?
---
A portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation.
https://kubernetes.io/docs/concepts/overview/
---
## What the %^$# does that mean?
---
A container orchestrator.
---
# What does it do?
---
It allows us to to manage our applications as containers, and orchestrate them by leveraging fancy rules, for example auto-healing, auto-scaling and rolling updates.
---
- Provides a runtime environment for containers
- Scales and load balances containers
- Abstracts away the underlying infrastructure
- Monitors and health checks containers
- Updates containers
- Provides service discovery and exposure
---
# But why should I care?
---
We care about this because with it, we can feed it our containerized application and be sure they will be run with minimal manual intervention.
---
Pros
- Using Kubernetes and its ecosystem can improve a team's productivity
- Helps making our application more stable/bulletproof
- Lots of community and professional support
---
Cons
- Steep Learning curve
- Administration overhead, especially if maintaining own cluster
- Not worth it for smaller applications/projects
---
# How does it work?
---
We run a number of services on all the machines (nodes) which make part of our cluster.
---
## High level overview

https://kubernetes.io/docs/concepts/architecture/
---
## Kubectl
To interact with the cluster, we use [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
```
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-1 Ready master 17h v1.25.4
k8s-2 Ready <none> 17h v1.25.4
k8s-3 Ready <none> 17h v1.25.4
```
---
## alias k = kubectl
:)
---
```
$ k get nodes
NAME STATUS ROLES AGE VERSION
k8s-1 Ready master 17h v1.25.4
k8s-2 Ready <none> 17h v1.25.4
k8s-3 Ready <none> 17h v1.25.4
```
---
## Kubernetes objects
Persistent entities in the Kubernetes ecosystem.
Such entities represent the state of the cluster, and are represented in YAML format.
```
---
apiVersion: ...
kind: ...
metadata:
name: ...
spec:
...
```
---
# Pods
- Smallest deployable units that can be managed by Kubernetes
- Groups 1 or more containers
- Meant to run a single instance of our application
https://kubernetes.io/docs/concepts/workloads/pods/
---
# Demo
Running a workload in a pod and inspecting it
---
# Deployments
- Provides updates to Pods
- Describe a desired state
- Used to run stateless workloads
https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
---
# Demo
Running a stateless workload
---
# Updating Deployments
- Provide rolling updates to pods
- Ensure pods are available at all times, even when failing updates
- Provide facilities to roll back deployments gone wrong
https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
---
# Demo
Updating a stateless workload
---
# Statefulsets
- Manage applications with state, like databases
- Provide unique network identifier
- Provide stable and persistent storage
- Ordered, graceful deployment and scaling
https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/
---
# Demo
Running a stateful workload
---
# ConfigMap
- Store non-confidential data in key-value pairs
- Pods can consume and use data from ConfigMaps
- Used to decouple environment config from container images
https://kubernetes.io/docs/concepts/configuration/configmap/
---
# Demo
Configuring a workload with a configmap
---
# Secrets
- Store small amounts of sensitive data such as password, token or keys
- Like configmaps, pods can consume values from secrets
- Data is encoded with base64 (😱)
https://kubernetes.io/docs/concepts/configuration/secret/
---
# Demo
Configuring a workload with a secret
---
# Common issues
- crashloopbackoff (CLBO)
- imagepull backoff
---
# Tools
K8s tools used by Rockhoppers:
- Sealed Secrets
- Kustomize
- ArgoCD
---
# Q&A
---
# Resources
- [kubernetes.io](https://kubernetes.io)
- [Cloud Native Devops with Kubernetes](https://www.amazon.com/Cloud-Native-DevOps-Kubernetes-Applications/dp/1492040762/ref=sr_1_1?crid=3F7BFMTNBRUL1&dchild=1&keywords=cloud+native+devops+with+kubernetes&qid=1607864321&sprefix=cloud+native+devops%2Caps%2C267&sr=8-1)
- [Kubernetes Up and Running](https://www.amazon.com/Kubernetes-Running-Dive-Future-Infrastructure/dp/1492046531/ref=sr_1_1?dchild=1&keywords=kubernetes+up+and+running&qid=1607864298&sr=8-1)
- [CKA course](https://github.com/kodekloudhub/certified-kubernetes-administrator-course)
- [The Almighty Pause Container](https://www.ianlewis.org/en/almighty-pause-container)
- [kubeadm](https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/)
- [k8s workshop](https://github.com/maiku1008/k8s-workshop)
---
## The end?
{"metaMigratedAt":"2023-06-17T23:23:15.962Z","metaMigratedFrom":"YAML","title":"Kubernetes workshop","breaks":true,"description":"a talk about kubernetes","contributors":"[{\"id\":\"f7d5c28d-2ad8-4fb0-a3a1-cebdc1d99279\",\"add\":7540,\"del\":2351}]"}