Modify Running kubernetes Cluster

4/9/2018

I have created a yaml file for kubernetes cluster which holds two docker images(2 micro services). created a cluster from it . kubectl create -f pod.yaml Cluster is running now.

I wish to add another one new docker image(new micro services to get delpoyed) or remove an existing one docker image from that cluster.

Is it possible in the same cluster?

-- soundararajan.c
docker
kubernetes

2 Answers

4/9/2018

It is generally considered best practice that a pod contains only a single container/service. If that is the case, you can simply create another deployment configuration file to add a new service and apply it using kubectl.

If you wish to delete a deployments, you can use the kubectl delete deployment command.

-- Shoan
Source: StackOverflow

4/9/2018

I would hold from going into the part where you said which holds two docker images(2 microservices). which might be a separate discussion and is more subjective.

You can add another container spec to your YAML and apply it:

spec:
  containers:
  - name: container1
//.. more stuff
spec:
  containers:
  - name: container2
//.. more stuff
spec:
  containers:
  - name: container3    

But additionally define deploymentStrategy to be RollingUpdateDeployment so that not all pods are taken down at the same time and they are replaced in a controlled manner without affecting end-user traffic.

Of course if your two versions of the application (one with 2 containers and one with 3) are not compatible with rest of the system then this won't solve your problem.

In which case - it is best to stand up another deployment for new version of application and divert traffic using DNS/routing mechanisms to new version of application.

-- Vishal Biyani
Source: StackOverflow