See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
1. Create the Service YAMI-:
- Define the service type as 'LoadBalancer' to expose it via a public IP
- Set the 'targetPort' to the port that the web server listens on inside the pods (let's assume it's 8080)-
- Set the 'port' to 8080, which will be the port used to access the service from outside the cluster.

2. Apply the Service: - Use 'kubectl apply -f web-app-service.yaml' to create the service- 3. Get the External IP: - Once the service iS created, use 'kubectl get services web-app-services to get the external IP address. This will be assigned by the cloud provider and will be available for users to access the application. 4. Test the Service: - Access the application using the external IP address and port 8080. For example, if the external IP is '123.45.67.89' , you would access the application through 'http://123.45.67.89:8080' ,