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
• 6,480 points
28 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,000 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 in Kubernetes by Kashish
214 views
0 votes
3 answers

Using multiple commands in a kubernetes yaml file

Try something like this: containers: - name: ...READ MORE

answered Apr 23 in Kubernetes by lyza
2,278 views
0 votes
1 answer

Pods IP address from inside a container in the pod

Make sure that your pod yaml file ...READ MORE

answered Aug 29, 2018 in Kubernetes by Kalgi
• 35,750 points
29 views
0 votes
1 answer

Increasing the shm size of a kubernetes container

You cannot achieve this in kubernetes pod. ...READ MORE

answered Sep 12, 2018 in Kubernetes by ajs3033
• 7,000 points
340 views
0 votes
1 answer
0 votes
3 answers

Error while joining cluster with node

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

answered Jan 17 in Others by anonymous
457 views
+3 votes
1 answer
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,000 points
152 views
+1 vote
4 answers

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.