Kubernetes – practical development intro
NOTE
We skip the lecture this time :)
- Kubernetes: For orchestrating containerized apps.
- Docker: Great for managing a few containers.
- Orchestration Needs: For managing larger systems (100s or 1000+ containers).
- What Kubernetes Offers: Scheduling, load balancing, and distribution of containers.
Why Orchestration
- Container Limitations: Good for small scale; struggles with large systems.
- Benefits of Orchestration:
- Efficiently manage numerous containers.
- Automates deployment, scaling and operations.
Introduction to Kubernetes
- Origin: Developed from Google’s Borg and Omega systems.
- Naming: Greek for “Helmsman”, steering wheel logo.
- Language: Written in Go.
- Purpose: Built for handling large numbers of containers efficiently.
Learning kubectl and Basic Concepts
- kubectl: A command-line tool for Kubernetes.
- Cluster: Consists of a Control (“master”) and multiple Nodes.
- Nodes: Machines that run containerized applications.
Install minikube.
First Kubernetes Application
- Deploying an App: Using
kubectl run
command. - Behind the Scenes: Kubernetes schedules and runs the application on a suitable node.
- Pods: Smallest deployable units in Kubernetes, holding the containerized app.
Interacting with the Kubernetes Cluster
- Listing Nodes:
kubectl get nodes
. - Running Applications: Deploy using
kubectl run
. - Viewing Deployments:
kubectl get deployments
.
Pods and Container Interaction
- Pod Information: Retrieving pod details using
kubectl get pods
. - HTTP API Access: Using
kubectl proxy
for API access. - Exploring Pods:
curl
requests to pod endpoints.
Concepts: Pods, Nodes, Services, Deployments
Pods
- Atomic Unit: Smallest deployable unit in Kubernetes.
- Components: Consists of one or more containers (e.g., Docker) and shared resources like storage and networking.
- Characteristics: Co-located, co-scheduled containers within a Pod.
Nodes
- Definition: Worker machines (virtual or physical) in a Kubernetes cluster.
- Components: Contains Kubelet, Kube proxy, and a container runtime.
- Functionality: Managed by the Master, hosts multiple pods.
Deployments
- Purpose: Provides declarative updates for Pods and ReplicaSets.
- Functionality: A Deployment controller provides updated status information about the rollout, it will ensure the desired state matches the current state.
- Rolling Updates: Deployments support rolling updates to your application, allowing you to deploy a new version of your app with zero downtime.
- Rollbacks: If something goes wrong, Kubernetes provides the ability to rollback this change.
- Scaling: Deployments can help to scale your application horizontally with a declarative command, Kubernetes users don’t need to manually create new Pods, but instead they declare the number of Pods they want and Deployments ensure that this number is always met.
Services
- Purpose: Handles pod mortality; maintains app accessibility.
- ReplicaSet: Ensures pod replication for consistent application running.
- Service Types: ClusterIP, NodePort, LoadBalancer, ExternalName.
Scaling
We can scale our deployment and see the new pods being used.
What k8s is not
Data Storage
- Does not manage data storage volumes directly
- Does not replace traditional data management systems
Databases
- Not a database management solution
- Does not handle database installation, configuration, or management
Secret Management
- Limited capabilities in secret management
- Does not replace dedicated secret management tools
Networking and Load Balancing
- Does not replace dedicated load balancers and network configurators
- Limited control over low-level networking features
Application-Level Services
- Not designed for managing application-level services like message queues
- Does not replace specialized middleware solutions
- Does not automate the writing of custom application logic
- Requires manual intervention for specific business needs
Deploying broken software in many containers doesn’t make it any less broken.