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,890 points
89 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,280 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
1,252 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 in Kubernetes by Sirajul
• 37,080 points
41 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
2,978 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,280 points
851 views
+1 vote
4 answers