Start the Deployment
Now that we have a working backend, we will add a frontend that provides a better user experience for our calculator app.
Create the configuration
We need a deployment and a service to deploy the frontend. This is pretty
similar to the backend configuration. Start by copying the backend.yml to
frontend.yml.
Change the deployment
- The deployment name, selector and label should be calculator-frontend.
- The image name for the frontend is quay.io/kubernetes-workshop/calculator-frontend:v1.
- The frontend container does listen on port 3000.
 Tip: Search for the port8080to find all places where the port is referenced.
- The frontend uses an environment variable CALCULATOR_BACKEND_BASE_URLwhich is used to configure the base url of the backend. Set this to the url of the backend servicehttp://calculator-backend.
 Usekubernetes-workshop/k8s-examples/deployment-with-env-vars.ymlas an example on how to configure environment variables.
Change the service
- Change the service name and selector to calculator-frontend.
- Use the right targetPortfor the frontend.
Deploy the configuration
Now we are ready to deploy everything.
- Run (like before) kubectl apply -f k8s-files/.
- Check the pods status kubectl get pods:
NAME                                   READY     STATUS              RESTARTS   AGE
calculator-backend-799f978d88-47v6b    1/1       Running             0          30m
calculator-backend-799f978d88-ncdch    1/1       Running             0          30m
calculator-backend-799f978d88-qz4k4    1/1       Running             0          30m
calculator-frontend-6b5d85558c-5smzr   1/1       Running             0           1m
calculator-frontend-6b5d85558c-hc78z   0/1       Running             0           1m
calculator-frontend-6b5d85558c-lfckh   0/1       ContainerCreating   0           1m
- Wait until all three pods are Ready: 1/1(check the status periodically).
- Use the link to access the frontend:
    $GCLOUD_SHELL_URL/api/v1/namespaces/default/services/calculator-frontend/proxy/
- Try out the UI, execute valid and invalid expressions and look at the response.
- Check with kubectl get podsand validate that everything works as you would expect.