Activity: Running a Web Server with Synchronization

In the sidecar.yaml file, pod definition with two containers, namely server and sync, is provided. In the server container, httpd serves the source volume on port 80. In the sync container, git runs with every 30 seconds to synchronize the source volume. These two containers work independently; however, they are sharing the source volume to achieve file synchronization:

apiVersion: v1
kind: Pod
metadata:
name: sidecar
spec:
containers:
...
volumes:
- emptyDir: {}
name: source

Follow these steps to get the solution:

  1. Create the pod with the following command:
 kubectl apply -f sidecar.yaml 
  1. Check whether the pod is ready with the name sidecar:
 kubectl get pod sidecar 
  1. When the pod is ready, check the logs of synchronization sidecar container:
 kubectl logs sidecar -c sync
  1. Forward the server port of the pod to localhost with the following command:
 kubectl port-forward sidecar 8000:80
  1. Open localhost:8000 in the browser. It is expected to see a 2048 game.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.31.125