pod-a and pod-b running the busybox imagepod-b-service that targets pod-bkubectl exec to ping pod-b-service from pod-a to test communicationpod-a and pod-b running the busybox imagepod-b-service that targets pod-bkubectl exec to ping pod-b-service from pod-a to test communicationpod-a and pod-b using the busybox image. Each pod should run a simple command to sleep for 3600 seconds to keep them alive.Use two separate pod definitions separated by ---. Each pod uses the busybox image and runs sleep 3600.
pod-b-service that selects the pod with the label app: pod-b. Add the label app: pod-b to the pod-b pod metadata.Remember to add the label app: pod-b to the pod-b metadata and create a service with selector matching that label.
kubectl exec to run the command ping -c 3 pod-b-service inside the pod-a pod to test connectivity.Use kubectl exec pod-a -- ping -c 3 pod-b-service to check if pod-a can reach pod-b via the service.
kubectl exec pod-a -- ping -c 3 pod-b-service and display the output to confirm pod-to-pod communication.The ping output should show successful packets sent and received with 0% packet loss.
How do pods inside a Kubernetes cluster typically communicate with each other?
Which of the following is the correct way to define a Kubernetes Service to expose pods for pod-to-pod communication?
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app: myapp
ports:
- protocol: TCP
port: 80
targetPort: 8080app: myapp correctly matches pods with that label.app: myapp and forwards port 80 to 8080 -> Option Capp: myapp and forwards port 80 to 8080 [OK]Given two pods in the same namespace, pod-a and pod-b, where pod-b runs a web server on port 80, what is the expected output of this command run inside pod-a?
curl http://pod-b:80
Assuming pod-b is reachable by its pod IP but not by name.
pod-b by name will fail DNS resolution because pod names are not DNS entries.You have a service named backend exposing pods on port 8080. A pod tries to connect using curl http://backend:80 but gets a connection refused error. What is the likely cause?
You want to ensure stable pod-to-pod communication in a Kubernetes cluster where pods restart frequently and get new IPs. Which approach best solves this problem?
Pass the test and this pattern moves unknown