Kubernetes Mastery: Part 3 – Exploring Kubernetes Resources
Welcome back to the Kubernetes Mastery Series! In this third part, we’ll delve into the world of Kubernetes resources and how to manage them effectively.
Before we begin, ensure you have your Kubernetes cluster up and running. If you’ve been following along with the series, your KinD cluster should already be set up.
Pods, Deployments, and Services
1. List Pods
# List all pods in the default namespace
kubectl get pods
# List pods in a specific namespace
kubectl get pods -n <namespace>
2. Describe a Pod
# Describe a pod by name
kubectl describe pod <pod-name>
3. Scale Deployments
# Scale a deployment to a desired number of replicas
kubectl scale deployment/<deployment-name> --replicas=<desired-replicas>
4. Update Deployments
# Update the image of a deployment
kubectl set image deployment/<deployment-name> <container-name>=<new-image>
5. Create a Service
# Create a service to expose a deployment
kubectl expose deployment <deployment-name> --port=<port> --target-port=<target-port> --type=NodePort
ConfigMaps and Secrets
6. Create a ConfigMap
# Create a ConfigMap from literal values
kubectl create configmap <configmap-name> --from-literal=<key1>=<value1> --from-literal=<key2>=<value2>
7. Create a Secret
# Create a Secret from literal values
kubectl create secret generic <secret-name> --from-literal=<key1>=<value1> --from-literal=<key2>=<value2>
Persistent Volumes and Persistent Volume Claims
8. Create a Persistent Volume (PV)
# Create a Persistent Volume
kubectl apply -f pv.yaml
9. Create a Persistent Volume Claim (PVC)
# Create a Persistent Volume Claim
kubectl apply -f pvc.yaml
Namespaces
10. Create a Namespace
# Create a new namespace
kubectl create namespace <namespace-name>
These are just a few examples of how you can interact with Kubernetes resources. Kubernetes offers a rich set of resource types for managing applications and their configurations.
Stay tuned for the next part in our Kubernetes Mastery Series:
Part 4 – Deploying Stateful Applications