We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Chat

Now that everything is accessible via Gateway (at least while the tunnel is open), let's connect the web application front-end to the API.

Assignment

  1. Create a new ConfigMap for the web service. Add two new environment variables:
    1. WEB_PORT: 8080 (this was already the default, now we're just making it explicit)
    2. API_URL: http://synchatapi.internal
  2. Update the web application's deployment to use the new ConfigMap.

Once all that's applied to your cluster, you should be able to open the web application and actually use the chat interface (notice it's "synchat", not "synchatapi"):

http://synchat.internal

Make sure that you can enter a username and a message, and send a message as that user! Assuming it works, that's because the webpage is now sending messages via fetch requests to the api service. The api service saves those messages locally in memory.

To see what I mean, try the following:

  1. Create a few messages as different users.
  2. Refresh the page
  3. The messages should still be there because they're saved in the server's memory.
  4. Now, delete the api pod
  5. Once k8s replaces the deleted pod with a new one, refresh the page again.

Answer the question on the right when you're done.