Confusion around Kubernetes pod replicas in terms of synchronising content

7/10/2018

I'm learning Kubernetes. I have a 3 node cluster, to which I have deployed nginx with 3 replicas. Therefore I have 3 replicated nginx pods.

I have provisioned a Load Balancer server to access these pods and exposed Port 80 - all this works fine.

That is, until I try to update the website. I think maybe I'm confused about how the Pods sync.

For example, On one of the pods I have changed the the default index.html page. I did this by connecting to the shell on one of the pods and physically changing this file. Perhaps foolishly, I expected this change to be replicated to the other pods and for this change to be visible when accessing the service via the load balancer. However, it is not. I occasionally access this changed page, but I guess that's only because the Load Balancer is doing some sort of round robin on the replicas.

So my questions as a newcomer to Kubernetes are, how do the replicas sync? Can you force the others to sync with another replica? Should it be automatic?

I should add that I have looked through the Kubernetes documentation and haven't really found the answer I'm looking for, so any help would be appreciated.

Also, I am running Kubernetes on GCP.

-- Molenpad
google-cloud-platform
kubernetes
nginx

1 Answer

7/10/2018

Pods are considered disposable groupings of containers. You should not modify them directly instead use a Deployment

Kubernetes deployments

There is a very nice interactive tutorial regarding updating.

The gist is.

  1. Create a new image and push this image.
  2. Set the image of your deployment to this new images.

This will initiate a rolling update.

-- Gerben
Source: StackOverflow