Now I did already outline the problems.
Problems start,
when our containers are restarted.
Now, here in this application,
we got no obvious way of restarting a container
because I got no error at point
as I did have it in the past.
But of course there could be circumstances
where this container does restart.
Because maybe it gets so much traffic
that some process times out
and therefore the container crashes and needs to be restart.
There definitely are scenarios where this could happen.
There are always scenarios where your applications crash.
And when that container restarts,
because currently we're not using any volumes here
on this Kubernetes cluster,
all the data would be lost.
So the data which I'm getting here.
And that's something we wanna solve with volumes.
Now, if you search for Kubernetes volumes,
you should find an article from the official docs.
And of course there you can learn way more about it
if you want to.
But most importantly here,
you find the different types
of volumes which are supported.
And that's what I meant before.
Kubernetes, supports a broad variety
of volume types and drivers.
And the reason for that
is that you don't just run Kubernetes
on your local machine,
even though we technically
are doing this right now of course with minikube.
But even that is a separate virtual machine
on our local machine.
So it is like a different machine in the end.
But in reality,
of course it will also use kubernetes
to deploy your application
to some cloud provider or some data center.
And therefore you have a broad variety
of
ways of storing your data.
Because it's not just your local hard drive
as the case of just Docker volumes,
but instead maybe you are using AWS
and you wanna use their elastic block store service.
Which is a service we haven't used
up to this point in this course,
but which is another storage service that you have
or maybe you're using Microsoft Azure
and therefore you wanna use one of these services
or any other provider
or type of volume here.
And this list might look overwhelming.
Of course in reality,
you will not need all these types all the time.
It depends on how you're hosting your application
and the deeper you dive into Kubernetes of course,
the more you will know about these different options.
For
this course section,
we are going to focus on this CSI type.
We are going to dive into the emptyDir type
and we're going to have a look at the hostpath type.
And actually we're going to start with emptyDir
and have a look at the other types thereafter.
The key thing is that
all these types don't influence how volumes work
inside of a container.
There it's always just some path,
which is then also stored outside of the container.
So basically just like volumes work
with just Docker as well.
But the difference here just is that,
how the data is stored outside of the container
depends on which type or driver you use here.
So with that,
let's start with this emptyDir type here
and let's learn how we can configure a volume
with Kubernetes.