Activity: Running a Web Server after Content Preparation

In the init-container.yaml file, pod definition with one initialization and one main container, namely content and server, is provided. In the content container, "Welcome from Packt" is written into the index file. In the server container, nginx serves the source volume on port 80. These two containers work independently; however, they are sharing the workdir volume to achieve file preparation:

apiVersion: v1
kind: Pod
metadata:
name: init-container
spec:
initContainers:
-
...
volumes:
- name: workdir
emptyDir: {}

Follow these steps to get the solution:

  1. Create the pod with the following command:
kubectl apply -f init-container.yaml
  1. Check the state of the initialization container:
kubectl describe pod init-container
  1. When the pod is running, forward the server port of the pod to localhost with the following command:
kubectl port-forward init-container 8000:80 
  1. In another terminal, check the content of the server with the following command:
curl localhost:8000
  1. Run the following command for cleanup:
kubectl delete deployment go-client 
..................Content has been hidden....................

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