Updating a file in place

Rated 4.30/5 based on 621 customer reviews

You need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster.

If you do not already have a cluster, you can create one by using Minikube, or you can use one of these Kubernetes playgrounds: Make a note of the names of the running Pods.

David, You can't just update a few lines in the middle of a file.

Rather, you will have to write your changes at the appropriate point in the file, and then write the information that you want to write after the changes back to the file (for the rest of the file).

Later, you will see that these Pods get terminated and replaced by new ones.

At this point, each Pod has one Container that runs the nginx image.

I have to open a text file in c# and read few lines and then I need to update some lines in the middle of the file.

The Deployment terminated the old Pods and created two new Pods that comply with the updated Deployment spec. This is not always what happens when you use a strategic merge patch on a list. With a strategic merge patch, a list is either replaced or merged depending on its patch strategy.

The patch strategy is specified by the value of the A strategic merge patch is different from a JSON merge patch.

You cannot safely write to a file you are also reading, as any changes you make to the file could overwrite content you have not read yet.

To do it safely you'd have to read the file into a buffer, updating any lines as required, and then re-write the file.

Leave a Reply