Hi, in this video, we demonstrate how to use a hostPath volume as a shared storage between the two containers of a pod.
For the purpose of this demo, we've already configured a deployment.
The deployment runs a pod.
And the pod is configured with two containers and a shared volume.
So the deployment operator is called the blue-app.
We will be using this to also generate later a green-app deployment.
But if we're scrolling down to the spec section of...
...the pod template...
...right down here, we see that a volume has been defined: hostPath type.
Two containers are defined, an "nginx" and a "debian" container.
Both containers have mountPath directories but they're both mounting the same host-volume, host-volume, volume defined at the top here.
So one volume defined, two containers, both mounting the same volume.
Now, in addition the "debian" container is going to run a few commands.
Okay, first it will...
...create a file index.html in its own host-volume directory.
And in that file, it will write some text, "Welcome to BLUE App!".
And then it will go to sleep indefinitely.
Otherwise the "debian" container would terminate and we don't want that at least not as of yet.
So now let's try to deploy this.
So we're quitting them...
...and we'll run 'kubectl control apply'...
...to create the deployment.
But at the same time, we want to expose this deployment via a NodePort type service.
The nginx web server of the deployment is already exposing port 80.
So all we have to do is expose the deployment and specify that we want the NodePort type of service with 'kubectl get deploy,po,svc' for pods and services.
We can validate that our resources have been created.
So the deployment is up and running with one pod replica.
The pod, the blue-app pod, is up and running with both containers ready, the "nginx" container and the "debian" container as well.
And then the service "blue-app" has been created and it is a NodePort type service.
So now, we can use the 'minikube service list'...
...to display the URL of the NodePort type service.
So either from the command line, we could run curl and paste the URL, and here it is, we have "Welcome to BLUE App!".
And if we keep refreshing, we will consistently get the same response.
Now, if we want to do this in a browser, we can right-click on this link, open link and this will open a tab in our favorite browser.
So for now we've only set up the blue-app, but as homework I would invite you to set up a green-ap, pretty much the same way.
Have a deployment called the green-app...
...configure it in such manner that the "debian" container modifies the index.html file of...
...your web server by using a shared volume.
So by basically using the same pattern, we can easily configure a new application which should be the green-app.
And then later we are going to play with services and deployments for a Canary type of...
...deployment pattern.
So it's a very simple deployment.
What is important is to make sure that in the template of the pod, we have a volume defined and then the two containers, they're both mounting the same volume.
Otherwise they cannot share it.
Otherwise the "debian" container cannot override the index.html file, which is the home of the nginx web server.
All right, so this concludes our demo.
Thank you very much for watching and I will see everyone in the next video.
Информация по комментариям в разработке