How to expose this deployment externally?

To expose the web-app deployment externally, you can create a service using the kubectl expose command. Here’s how to do it:

  1. Expose the Deployment: Run the following command to create a service named web-service that exposes the deployment on port 80:

    kubectl expose deployment web-app --name=web-service --port=80 --target-port=80 --type=NodePort
    • --port=80: The port that the service will expose to external clients.
    • --target-port=80: The port on the container where the service will route the traffic.
    • --type=NodePort: This makes the service accessible on a specific port on each node in the cluster.
  2. Verify the Service: Check that the service was created successfully by running:

    kubectl get services web-service

This command will display details about the web-service, including the assigned NodePort, which you can use to access your application externally. If you have any more questions, feel free to ask!

0 Comments

no data
Be the first to share your comment!