start deployment or service by using name from kubernetes java client

11/28/2019

How can one start a service or deployment just by using name of the service or deployment from kubernetes java sdk? Suppose we have started and stopped the service or deployment once, so whether this can be achieved to just use the same name by which we have done the deployment or deployed the service. For eg :

  1. start a deployment by name nginx-deployment by using yaml file and then delete the deployment.
  2. now try to start the same deployment just by using the name of previous deployment from kubernetes java sdk.
  3. whether this can be achieved or not.
-- abhay_singh
kubernetes

1 Answer

11/28/2019

In kubernetes you can't stop a service, then to start it again (like in docker). Once a pod is killed, it will need to be re-created.

Now, if you delete a deployment, then you can re-create the same deployment, with the same name, with no problems.

If you are concerned about the state of the application, you can either use a StatefulSet or map the container content into an external volume. For example into the node.

-- suren
Source: StackOverflow