I've created a simple K8s deployment with the kubectl create
command
kubectl create -f k8-deployment.yaml
My k8-deployment.yaml
file looks like this
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: mage-di
name: mage-di
spec:
replicas: 1
selector:
matchLabels:
app: mage-di
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: mage-di
spec:
containers:
- image: astorm/mage-di
name: mage-di
imagePullPolicy: Never
resources: {}
status: {}
This results in a single pod being started.
I want to tell my k8 cluster that more pods are needed to handle an expected traffic spike.
How should I do this? If I look at kubectl help
I see there's an edit
command that allows me to edit a deployment object's configuration, but this requires an interactive editor. Also, I'm new to K8s and I'm unsure if editing a deployment in place and updating its replica count is enough to trigger the proper creation of new pods. If I look at other kubectl
commands I see there's also a rollout
, apply
and patch
command that might do what I want.
Is there a canonically accepted way to do what I want, or is K8s the sort of tech where I just need to experiment and hope for the best?
replicas:
field automatically. – Levee