Reputation: 7642
I have a simple web app deployed on kubernetes.
I have two Pods and Service for them. Requests should be balanced among two pods. How I can verify this?
Maybe there are some tools or commands? When I hit (make request) my application, I want to see something like this in console:
request on pod1
request on pod2
request on pod2
Upvotes: 3
Views: 1616
Reputation: 44657
One way to do this would be add the podname or podip or hostname or some other identifier to an HTTP header before sending back a response from the pod to the client . Then in the client side you can inspect the header to check which pod responded for that particular request.
For example you could define env in your pod as below
env:
- name: MY_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
Then you could read the environment variables MY_POD_NAME
and MY_POD_IP
, add them into an http header, print them in logs.
Upvotes: 4
Reputation: 101
if your application is logging something during a request you can tail the logs from both of the container, you can use stern
kubectl logs pods-1 -f
Upvotes: 2