What is Kubernetes?
Kubernetes, often abbreviated as K8s, is a container orchestration platform that manages containerized
applications across a cluster of machines. It provides a framework to run distributed systems resiliently,
with scaling, failover, deployment patterns, and more.
Key Concepts
1. Cluster: A set of machines (nodes) running Kubernetes, managed by the master nodes.
2. Node: A single machine in the Kubernetes cluster.
3. Pod: The smallest and simplest Kubernetes object. A pod represents a single instance of a
running process in your cluster and can contain one or more containers.
4. Service: An abstraction which defines a logical set of pods and a policy by which to access them.
5. Deployment: A controller that provides declarative updates to applications.
6. Namespace: A way to divide cluster resources between multiple users.
Setting Up Kubernetes
1. Minikube: For local development, you can use Minikube, which runs a single-node Kubernetes
cluster on your personal computer.
Install Minikube: Follow the instructions on the Minikube GitHub page.
Start Minikube: Run minikube start.
2. kubectl: This is the command-line tool for interacting with the Kubernetes API.
Install kubectl: Instructions can be found on the Kubernetes website.
Verify installation: Run kubectl version --client.
Basic Operations
1. Deploy an Application:
Create a deployment: kubectl create deployment nginx --image=nginx
Check the deployment: kubectl get deployments
2. Expose the Application:
Expose the deployment: kubectl expose deployment nginx --port=80 --type=NodePort
Get the service: kubectl get services
3. Scale the Application:
Scale the deployment: kubectl scale deployment nginx --replicas=3
Check the pods: kubectl get pods
4. Update the Application:
Update the image: kubectl set image deployment/nginx nginx=nginx:1.16.1
Rollback if needed: kubectl rollout undo deployment/nginx
YAML Configuration
Kubernetes resources are typically defined using YAML files. Here is an example of a deployment YAML
file:
Apply the configuration using kubectl apply -f <filename>.yaml.
Monitoring and Logging
kubectl logs: Fetch logs for a pod: kubectl logs <pod-name>
kubectl top: Display resource usage: kubectl top nodes and kubectl top pods
Advanced Concepts
1. ConfigMaps and Secrets: Manage configuration data and sensitive information.
2. Persistent Volumes: Manage storage in Kubernetes.
3. Ingress: Manage external access to services in a cluster, typically HTTP.
4. Helm: Package manager for Kubernetes, helps in managing Kubernetes applications.
Learning Resources
Kubernetes Documentation
Kubernetes Academy
Kubernetes by Example
Kubernetes The Hard Way by Kelsey Hightower
Hands-On Practice
Try to deploy and manage a few simple applications on your Kubernetes cluster to get hands-on
experience. You can also use cloud-based Kubernetes services like Google Kubernetes Engine (GKE),
Amazon Elastic Kubernetes Service (EKS), or Azure Kubernetes Service (AKS) for more advanced
scenarios.