kubernetes stop deployment code example

Example 1: kubernetes get deployments

# Get pods in default namespace
kubectl get deployments

#Get Pods in my-namespace
kubectl get deployments -n my-namespace

#Get Pods in all namespaces
kubectl get deployments --all-namespaces

Example 2: kubectl restart deployment

kubectl rollout restart deployment yourDeploymentName

Example 3: k8s roll back to previous deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: example-deployment
spec:
  replicas: 3
  revisionHistoryLimit: 100
  selector:
    matchLabels:
      name: app
  template:
    metadata:
      labels:
        name: app
    spec:
      containers:
      - name: app
        image: learnk8s/hello:1.0.0