One of the more advanced topics in DevOps is Kubernetes. I have been in a DevOps role for a while before I truly grasped the concept. In this blog, I attempt to explain the concept (hopefully it's clear!).
First, let us clarify some terminologies where a lot of engineers get confused.
Containers, Images, and Kubernetes
Containers - are lightweight deployable packages that has the minimum required dependencies, code, and configuration to run an application.
Image - is the blueprint of containers. Basically, it is a non-running container and is usually stored in a container registry like ECR (Elastic Container Registry), Artifactory, or Docker Hub.
Kubernetes - is a container orchestration "platform". It manages containers through all it's magic across clusters.
Kubectl Commands
Kubectl is a command line tool that allows interaction with a Kubernetes cluster. Before you can interact with Kubernetes in the cloud, you would need to setup a kubeconfig
file in your local machine with either aws eks
(for AWS) or az aks
(for Azure).
For AWS
aws configure
aws eks update-kubeconfig --region <aws-region> --name <cluster-name>
- Replace with your AWS region (ex. us-east-1).
- Replace with your EKS cluster name.
For Azure
az login
az aks get-credentials --resource-group <resource-group> --name <cluster-name>
- Replace with your Azure Resource Group name.
- Replace with your AKS cluster name.
After running these commands, you should have a kubeconfig file setup. For MAC, this usually lives on the following path: ~/.KUBE/config.
Below are some of the common kubectl
commands to know:
kubectl apply -f <file.yaml> -n <namespace>
→ Deploy a resource from a YAML manifest
kubectl logs -f <pod-name> -n <namespace>
→ View logs from a pod
kubectl exec -it <pod-name> -n <namespace> -- bash
→ Open an interactive shell in a running container
kubectl get events
→ Displays events such as pod scheduling, container creation, scaling actions, failures, or errors.
All the Commands
Below are some basic kubernetes resources and their corresponding kubectl commands.
- Pod – The smallest deployable unit in Kubernetes.
#List all pods
kubectl get pods -n <namespace>
#Get detailed info on a specific pod
kubectl describe pod <pod-name> -n <namespace>
- Deployment – Manages replicated pods and ensures their availability.
#List all deployments
kubectl get deployments -n <namespace>
#Detailed view of a deployment
kubectl describe deployment <deployment-name> -n <namespace>
#Save a definition to a file
kubectl get deployment <deployment-name> -n <namespace> -o yaml >> <file_name>
#Edit the deployment directly
kubectl edit deployment <deployment-name> -n <namespace>
- ReplicaSet – Ensures a specified number of pod replicas run at all times.
#View all replica sets
kubectl get replicasets
#Get details on a specific ReplicaSet
kubectl describe replicaset <replicaset-name>
- Service – Provides network access to a set of pods.
#View all services
kubectl get services
#Get detailed info on a service
kubectl describe service <service-name>
- ConfigMap – Stores configuration data in key-value pairs.
#List all ConfigMaps
kubectl get configmaps
#View details of a ConfigMap
kubectl describe configmap <configmap-name>
- Secret – Stores sensitive information like passwords or API keys.
#List all secrets
kubectl get secrets
#Get details on a secret
kubectl describe secret <secret-name>
- *PersistentVolume (PV) *– Represents storage in Kubernetes.
#View available persistent volumes
kubectl get pv
#Get details on a specific PV
kubectl describe pv <pv-name>
- PersistentVolumeClaim (PVC) – Requests storage from a PersistentVolume.
#View all PVCs
kubectl get pvc
#Get details of a PVC
kubectl describe pvc <pvc-name>
- Namespace – Provides a way to logically separate resources.
#View all namespaces
kubectl get namespaces
#Get details on a namespace
kubectl describe namespace <namespace-name>
- Node – Represents a worker machine in the cluster.
#View all nodes in the cluster
kubectl get nodes
#Get details on a node
kubectl describe node <node-name>
As always, concepts are easier to understand as you build a project in Kubernetes. Here is another blog I wrote previously that shows the container deployments with DevOps concepts: https://dev.to/aws-builders/build-a-container-package-for-your-react-app-with-docker-and-github-actions-4nf5.
Top comments (0)