How to: Lab 8.2. Connect a frontend to a backend using services
In this lab, we will implement a naive example of a _backend-frontend_ microservices architecture - expose frontend to external traffic with `NodePort` Service while keeping backend hidden with `ClusterIP` Service.

> Note that live environments typically use [_Ingress_](#9-ingress) (covered in the next chapter) to expose applications to external traffic
Backend-Frontend
microservices architecture example
![backend-frontend microservice architecture](https://user-images.githubusercontent.com/17856665/187857523-8d0fd28f-d540-4453-bae9-ff5481d63e07.png)
1. Create a simple Deployment, as our `backend` app, with the following spec:
   - image `httpd` (for simplicity)
   - name `backend`
   - has Labels `app: backend` and `tier: webapp`
   - has Selectors `app: backend` and `tier: webapp`
2. Create a Service for the backend app with the following spec:
   - type `ClusterIP`
   - port 80
   - same name, Labels and Selectors as backend Deployment
3. Confirm you can access the app by `$CLUSTER-IP` or `$SERVICE_NAME`
4. Configure an [nginx upstream in `nginx/default.conf`](https://docs.nginx.com/nginx/admin-guide/load-balancer/dynamic-configuration-api/) to redirect traffic for the `/` route to the backend service
   ```sh
   # nginx/default.conf
   upstream backend-server {
       server backend; # dns service discovery within the same namespace use service name
   }

   server {
       listen 80;

       location / {
           proxy_pass http://backend-server;
       }
   }
   ```
5. Create a simple Deployment, as our `frontend` app, with the following spec:
   - image `nginx`
   - name `frontend`
   - has Labels `app: webapp` and `tier: frontend`
   - has Selectors `app: webapp` and `tier: frontend`
   - Remember that Services target Pods by Selector (the Label Selector of the Service must match the Label of the Pod)
   - mounts the nginx config file to `/etc/nginx/conf.d/default.conf` (use fullpath `$(pwd)/nginx/default.conf`)
   - see example [_hostPath volume mount manifest_](https://kubernetes.io/docs/concepts/storage/volumes/#hostpath-configuration-example)
6. Create a Service for the frontend app with the following spec:
   - type `NodePort`
   - port 80
   - same name, Labels and Selectors as frontend Deployment
   - Remember that Services target Pods by Selector
7. Confirm you can access the backend app from the Minikube Node `$(minikube ip):NodePort`
8. Delete created resources
lab 8.2 solution
```sh
kubectl create deploy backend --image=httpd --dry-run=client -o yaml > lab8-2.yaml
echo --- >> lab8-2.yaml
kubectl expose deploy backend --port=80 --dry-run=client -o yaml >> lab8-2.yaml
nano lab8-2.yaml
```

```yaml