Kubernetes Deployments
Kubernetes Deployments are a key resource for managing stateless applications in a cluster. They provide declarative updates for Pods and ReplicaSets, allowing you to define the desired state of your application and ensure that it’s maintained. Deployments handle creating, updating, and scaling groups of Pods.
Listing Deployments
You can list deployments in various ways using kubectl get deployments.
List Deployments in the Current Namespace
kubectl get deploymentsList Deployments Across All Namespaces
kubectl get deployments --all-namespacesList Deployments in a Specific Namespace
kubectl get deployments -n <namespace-name>
# Example:
kubectl get deployments -n defaultFiltering Deployments
You can combine kubectl get deployments with grep or label selectors to find specific deployments.
Filtering by Name or Partial Name using grep
# Example: Find deployments containing 'unify' in their name across all namespaces
kubectl get deployments --all-namespaces | grep unifyFiltering by Label Selector
Using the -l or --selector flag to filter by labels is more robust and Kubernetes-native than grep.
# List deployments with the label 'app=my-app'
kubectl get deployments -l app=my-app -n <namespace-name>Describing a Deployment
To get detailed information about a specific deployment, including its events, replica status, and associated ReplicaSets and Pods, use kubectl describe deployment.
kubectl describe deployment <deployment-name> -n <namespace-name>
# Example:
kubectl describe deployment unify-controller -n uatScaling a Deployment
You can easily scale your deployments up or down to adjust the number of running pods.
# Scale a deployment to 3 replicas
kubectl scale deployment <deployment-name> --replicas=3 -n <namespace-name>