Restart a pod on different node from a pod in Kubernetes

8/27/2019

I have deployed a spring boot application on a pod(pod1) on a node(node1). I have also deployed JMeter on another pod(pod2) on a different node(node2). I am trying to perform automated load testing from pod2. To perform load testing, I require to restart the pod1 for each test cases. How do I restart pod1 from pod2?

-- anushiya-thevapalan
gcloud
jmeter
kubernetes
load-testing
performance-testing

3 Answers

8/30/2019

If you have a deployment type workload you can go into in through Workloads > [Deployment name] > Managed Pods [Pod name] and delete the pod.

You can also do this with kubectl delete pod [pod name]

If you have a minimum number of pods for that deployment set then GKE will automatically spin up another pod, effectively restarting it.

https://cloud.google.com/kubernetes-engine/docs/concepts/deployment

-- Nicholas Elkaim
Source: StackOverflow

8/27/2019

Via kubectl:

Install kubectl and configure in the pod2 and then do kubectl delete pod1 via shell after every load-testing

Via Springboot:

Add actuator dependency

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

Enable shutdown

management.endpoint.shutdown.enabled=true

Request to shutdown

curl -X POST IP:port/actuator/shutdown

-- Tummala Dhanvi
Source: StackOverflow

8/27/2019

To restart or delete a pod from another pod you have to access the APIServer. There are many ways to do this check this link.

You also have to authorize the pod user to do this, build a Role and a Rolebinding entity.

-- EAT
Source: StackOverflow