1

I am using eks to deploy pods to my nodegroups. This is my deployment file


 apiVersion: apps/v1
 kind: Deployment
 metadata:
   name: molding-app
   namespace: new-simulator
 spec:
   replicas: 3
   selector:
     matchLabels:
       app: my-app
   template:
     metadata:
       labels:
         app: my-app
     spec:
       containers:
       - name: eks-pods
         image: 088562811725.dkr.ecr.ap-south-1.amazonaws.com/eks_pods:latest
         ports:
         - containerPort: 8080
         - containerPort: 10010



I just wanted to know if there is anyway I could pass number of replicas through command line instead of writing it in the deployment file?

Anshul Walia
  • 547
  • 1
  • 5
  • 9

2 Answers2

1

You can do it adding parameter --replicas.

$ kubectl create deployment molding-app --image=088562811725.dkr.ecr.ap-south-1.amazonaws.com/eks_pods:latest --replicas=3 -n <namespace>
deployment.apps/molding-app created

Later you can change it using scale

$ kubectl scale deployment molding-app --replicas=10 -n <namespace>
deployment.extensions/molding-app scaled

More details can be found in Kubernetes documentation about scaling deployment.

PjoterS
  • 12,841
  • 1
  • 22
  • 54
1

You can scale it from command line by using

kubectl scale deployment molding-app --replicas=3 -n namespace
Dashrath Mundkar
  • 7,956
  • 2
  • 28
  • 42