Kubernetes 101 provides an overview of containers, Kubernetes architecture, and Kubernetes objects. It discusses how containers evolved from virtualization to improve efficiency. Kubernetes is introduced as a container orchestration tool to manage deployments, scaling, networking, security etc. of containers across clusters. Key Kubernetes components like the control plane, nodes, and objects like pods, deployments, services, storage and secrets are explained at a high level.
2. Who am I?
Peeyush Gupta
Sr. Developer Advocate @ DigitalOcean
#sig-contribex (@pensu91)
@pensu91
pgupta@digitalocean.com
3. Agenda
● Revisiting Containers
● Introduction to Kubernetes Architecture
● Kubernetes building blocks
● Kubernetes objects and workloads
● Q & A
4. How did we get here?
● This is how traditional
deployments models worked
when we only had bare metal
servers to run the workloads.
● There was very little to no
isolation and applications had to
be very careful in using the
resources.
5. How did we get here?
● To take advantage of increasing resources,
people started using hypervisors and
virtualization was born!
● The idea is to divide the server resources
and provide isolated environment to
applications
● This provided an easier and efficient way
of managing resources.
6. How did we get here?
● What’s next after virtualization?
● The next leap is to remove the redundant
Operating System layer.
● What if we can use the already existing
operating system?
● This was called containerization.
9. What are containers?
● A package of application code and all of its dependencies
○ Includes everything needed to run the application
● Built around two Linux kernel features
○ Namespaces: Process isolation
○ Cgroups: Resource limits
● Why are they important?
○ Resource efficient and fast
○ Portable across teams
11. Container Orchestration
● What if we have 10s, 100s, 1000s of running containers on multiple VMs?
● How to deploy, scale, restart, manage all of these containers?
● What problems do they solve?
○ Deployment
○ Management
○ Health Checks
○ Security
○ Networking
12. Kubernetes
● Also known as “K8s”
● Evolved out of Borg (Google’s internal container
cluster)
● One of the most famous open source project on
Github
● Features added regularly and frequently
● Governed by CNCF
13. Why Kubernetes
● Resource Efficient
○ Smart scheduler to distribute load on to the worker nodes.
● Increased Productivity
○ Improves the work flow of application and CI/CD pipeline.
● Scalability
○ Just one command to scale up or down the application.
● High Availability
○ Maintain high availability of applications using built-in services.
● Self-Healing
○ Auto restarts of failed application in order to maintain the state.
15. Kubernetes Components
● Control Plane
○ API server
○ Scheduler
○ Controllers
■ Kubernetes
■ Cloud
○ Etcd
● Nodes
○ Kubelet
○ Kube-proxy
16. How to connect to Kubernetes cluster
● Hit REST API directly
○ Can use curl, client libraries, etc.
● Kubectl
○ Command-line tool to interact with control plane
○ Abstracts away multiple REST API calls
○ Provides “get” “create” “delete” “describe”, etc. functionality
○ Filtering results
18. Namespaces
● An abstraction that allows you to divide a cluster into multiple scoped
“virtual clusters”
○ E.g. Each team gets its own Namespace with associated resource
quota
● Primary mechanism for scoping and limiting access
● Kubernetes usually starts with 3 Namespaces by default
○ default
○ kube-system
○ kube-public
19. ● The smallest unit of deployment
● Can contain more that 1 containers
● Pod runs as a single unit so all the
containers that are part of a pod
run on same node always.
● Network/Storage resources are
shared among containers in a pod
Pods
21. Deployment
● Object that can contain
your applications
● Run multiple replicas
● Replace the failed pods
with healthy ones
● Scale up/down pods and
update replicas
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
ports:
- containerPort 80
22. Services
● Services: Abstraction to expose an app
as a service (think microservices)
● Load balancing traffic
○ Routing to “healthy” / “available”
Pods
● Routing selection via Labels
● 3 types
○ Cluster IP
○ NodePort
○ LoadBalancer
Service
User
Node 1 Node 2
Replica 1 Replica 2
25. Storage
● Persistent Volume (PV
○ A storage volume that can be attached to pod
○ Can be created either by administrator (static provisioning) or create on the fly (dynamic
provisioning) via storage class
● Persistent volume claims (PVC
○ A request for storage by a user.
○ PVC consumes PV resource.
○ Storage class creates PV based on specification given in PVC
● Volume inside a single pod can also be used to communicate between
containers.
● Most of the storage providers now have CSI Container Storage
Interface) driver.
26. Configmaps and Secrets
● Configmaps
○ Used to store config data as key value pairs.
○ Can store env variables, config files etc.
● Secrets
○ Manage sensitive information such as password, auth tokens, ssh keys
etc.
○ Base-64 encoded, plugins available to encrypt as well.
● Configmaps and secrets can be used either as env variables
or mounted as volumes to the pod.
27. Helm
● Package manager for Kubernetes
● Helps developers to package, manage, deploy
applications and services to Kubernetes cluster.
● Packages are called helm charts.
● Helm client talks to chart repository to install.
● Also provides options to configure charts before
installing.
helm init
helm install stable/wordpress
28. What else?
● Autoscaling
● RBAC policies
● Resource quotas
● Kubernetes Extensions
● Logging and monitoring
● And much more...