introduction to kubernetes - bolbeck.com
TRANSCRIPT
![Page 1: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/1.jpg)
Introduction to KubernetesJuan Peredo
https://www.linkedin.com/in/juanperedotech
![Page 2: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/2.jpg)
A couple walks into a bar...
![Page 3: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/3.jpg)
The food ordering process
![Page 4: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/4.jpg)
Kubernetes
![Page 5: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/5.jpg)
Images and containers
• Images package apps and all their dependencies
• Images can be shared using container registries like Docker Hub
• Containers are ephemeral image instances
• Kubernetes manages container lifecycle automatically
![Page 6: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/6.jpg)
Moving to Kubernetes
• Pods: Smallest deployment unit
• Replicaset: Controls number of pod instances
• Deployment: Where all the magic happens
![Page 7: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/7.jpg)
Adding dessert
Satellite resources helpful when running an app:
• Services: Port definition
• ConfigMaps: App Configuration
• Secrets: Sensitive data (64bit encoded)
• And many more ...
All resources defined using YAML manifests
![Page 8: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/8.jpg)
Getting started
![Page 9: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/9.jpg)
Basic anatomy of a YAML manifest
apiVersion: v1kind: [Service|Pod|Deployment|etc...]metadata: annotations: foo: bar labels: app: mylabel name: myname[spec|data]:
![Page 10: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/10.jpg)
Our first command
![Page 11: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/11.jpg)
apiVersion: v1kind: Podmetadata: creationTimestamp: null labels: run: mariadb name: mariadbspec: containers: - image: mariadb name: mariadb ports: - containerPort: 3306 ...
![Page 12: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/12.jpg)
Our second command
![Page 13: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/13.jpg)
apiVersion: apps/v1kind: Deploymentmetadata: labels: app: mariadb name: mariadbspec: replicas: 1 selector: matchLabels: app: mariadb template: metadata: labels: app: mariadb spec: containers: - image: mariadb name: mariadb ports: - containerPort: 3306 ...
![Page 14: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/14.jpg)
Demo time
• Goals
• Take an application all the way to deployment in K8s
• Everything as code
• Repo:
• https://bitbucket.org/Bolbeck/cwit_2020
![Page 15: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/15.jpg)
Demo roadmap
![Page 16: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/16.jpg)
Our application
![Page 17: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/17.jpg)
Running our app
• Build custom Node app image with Docker
• Run with Docker-compose
• Contains everything needed for our app
• Brings up our containers
• Creates the appropriate network
• Checked in with the rest of our code
![Page 18: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/18.jpg)
Demo roadmap
✔ Run app with Docker
➡ Write Kubernetes manifests
➡ Deploy to Kubernetes in Minikube
• Sidecar deployments
• Multi-environment manifests
![Page 19: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/19.jpg)
Kubernetes manifests
• Docker-compose defined our app with 3 services
• For K8s, we need to map those to multiple resource manifests:
• Deployments
• Services
• Persistent Volumes
• ConfigMaps
![Page 20: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/20.jpg)
Manual manifest creation
![Page 21: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/21.jpg)
Generating Kubernetes manifests
• Kompose generates manifests automagically!
!
• Based on dockercompose file
• Out of the box, generation gets you 90% there
• Run: kompose -f <path_to_dokercompose_file> convert
• Get Kompose at kompose.io
![Page 22: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/22.jpg)
Our app in K8s
• Application running:
• One container per Pod
• Network communication
• Accessible via browser
• Scaled up and down
• Is that where we want our Redis cache ?
![Page 23: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/23.jpg)
Demo roadmap
✔ Run app with Docker
✔ Write Kubernetes manifests
✔ Deploy to Kubernetes in Minikube
➡ Sidecar deployments
• Multi-environment manifests
![Page 24: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/24.jpg)
Caching as a sidecar
• Sidecar: provides additional functionality to main container
• Advantage: Treated as a local resource
• Disadvantage: Containers cannot be individually managed
• What we'll do:
• Remove our Redis deployment & service
• Add Redis to our Node deployment
• Change how Node discovers Redis
![Page 25: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/25.jpg)
Demo roadmap
✔ Run app with Docker
✔ Write Kubernetes manifests
✔ Deploy to Kubernetes in Minikube
✔ Sidecar deployments
➡ Multi-environment manifests
![Page 26: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/26.jpg)
Maintain manifest copies
![Page 27: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/27.jpg)
Kustomize
• YAML customization
• Merges YAML files
• Eases multi-configuration manifests maintenance
• Usage, either:
• Built-in as kubectl apply -k and kubectl kustomize
• Latest binary from Kustomize.io
![Page 28: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/28.jpg)
Demo roadmap
✔ Run app with Docker
✔ Write Kubernetes manifests
✔ Deploy to Kubernetes in Minikube
✔ Sidecar deployments
✔ Using secrets
✔ Multi-environment manifests
![Page 29: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/29.jpg)
K8s resources at a glance
![Page 30: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/30.jpg)
Rich ecosystem
![Page 31: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/31.jpg)
Key takeaways
![Page 32: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/32.jpg)
Questions ?
Thanks to the CWIT Conference & all the sponsors
![Page 33: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/33.jpg)
Appendix
![Page 34: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/34.jpg)
Photos
• Photo by DarkmoonArt_de at Pixabay
• Photo by Markus Spiske on Unsplash
• Photo by Wiktor Karkocha on Unsplash
![Page 35: Introduction to Kubernetes - bolbeck.com](https://reader033.vdocuments.mx/reader033/viewer/2022042710/6266cb0eed774c3e06676528/html5/thumbnails/35.jpg)
Photos
• Photo by Daniel Cheung on Unsplash
• Photo by Marcos Paulo Prado on Unsplash