Modifying a deployment without editing the file manually

0 votes

I created a deployment for my application:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: myapp1
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: myapp
        image: 172.20.34.206:5000/myapp_img:2.0
        ports:
        - containerPort: 8080

Now to do a rolling update I do this:

  1. $ kubectl edit deployment/myapp1
  2. editor opens and I change the image version and save

Can this be automated? Can I do it just by running a command instead of opening, saving and deploying again? Eg:

$ kubectl edit deployment/myapp1 --image=172.20.34.206:5000/myapp:img:3.0

I thought using Kubernetes API REST but I don't understand the documentation.

Aug 24, 2018 in Kubernetes by shubham
• 7,340 points
2,457 views

1 answer to this question.

0 votes

You can try kubectl patch to do this:

kubectl patch deployment myapp-deployment -p \
  '{"spec":{"template":{"spec":{"containers":[{"name":"myapp","image":"172.20.34.206:5000/myapp:img:3.0"}]}}}}'

YAML format is also accepted here. Also check out Kubernetes issue #458. You can also try using the PATCH verb via the REST API.

answered Aug 24, 2018 by ajs3033
• 7,300 points

Related Questions In Kubernetes

0 votes
1 answer

How to start and stop a cluster on AWS using kops without stopping the instance

Export your KOPS_STAT_STORE variable export KOPS_STATE_STORE=s3://your-bucket-name Get your instances ...READ MORE

answered Jan 8, 2019 in Kubernetes by Kashish
9,408 views
0 votes
1 answer

How to determine what is the status of a deployment ?

You could use kubectl get deployment <deployment>.  If ...READ MORE

answered Jul 12, 2019 in Kubernetes by Sirajul
• 59,230 points
679 views
+1 vote
1 answer
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
15,571 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,058 views
0 votes
1 answer

What's the difference betweena a deployment and a stateful set?

Both the deployments and replication controllers are ...READ MORE

answered Oct 3, 2018 in Kubernetes by ajs3033
• 7,300 points
4,478 views
+1 vote
4 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP