#!/bin/bash

name_space=xmyd

kubectl get deployments -n ${xmyd} -o custom-columns='NAME:.metadata.name,REPLICAS:.spec.replicas' --no-headers > deployments_replicas.txt


scale_back_replicas(){
  while IFS= read -r line; do
    name=$(echo "$line" | awk '{print $1}')
    replicas=$(echo "$line" | awk '{print $2}')
    kubectl scale deployment "$name" --replicas="$replicas" -n ${name_space}
  done < deployments_replicas.txt
}

