Now, before we dig into kubernetes
and volumes there is a certain term which I wanna clarify,
and that would be State.
You could kind of translate state with data,
in the end it's just data which is created
and used by your application which must not be lost.
And there are different kinds of such state.
There for example is user-generated data,
like to story where storing
or something like a user account which was created.
There also are intermediate results
which are derived by the app
and which are also needed
but which eventually will be lost and cleared.
Now the user-generated to data,
the user accounts and whatever your app is about
that data is typically stored in databases
but maybe also in files, Like in the example I gave you
where we store the data in this story text file.
Now for the intermediate results that
is often storage Just in memory
or in temporary database tables or files.
But whichever kind of data you're dealing with,
the key thing is that this data needs
to survive container restarts,
especially the data on the left side, of course,
and that is exactly what we have volumes for.
This is nothing new and nothing kubernetes specific,
I just want us to emphasize does again,
that is why we use volumes
because this data matters and must not be lost just
because a container is stopped and was removed.
And it does not matter if we're working with Docker locally
and with Docker and Docker compose,
or if we're working with kubernetes
because we wanna deploy that data onto a cluster.
Especially, if we work with kubernetes
and we are planning to deploy our application
we of course need to ensure that crucial data is not lost.
I mean, your application wouldn't be worth much
if your user data would suddenly be gone, right?
So that's why we have volumes
and of course we already know that solution.
As I mentioned, we already know volumes
and volumes still matter when working with kubernetes
because ultimately we're still dealing with containers.
So of course, this solution for persisting data
which we already learned about is not obsolete,
we still need it.
However, we of course have to keep in mind
that now when working with kubernetes,
it's kubernetes that runs our containers.
It's not us, we don't run Docker run
or a Docker Compose command.
Instead, we use kubernetes and we orchestrate
our cluster and our deployment with kubernetes
and kubernetes then creates these pods
which then run our containers.
So we don't directly launch our containers.
And therefore of course,
we can't provide a Docker compose file
and we can't add the dash V flag when using Docker run,
instead we need to configure Kubernetes such
that it adds volumes to our containers.
And that's exactly what we're going to dive into
in this module, in this course section.
How we can get Kubernetes to create and add volumes
to the containers it starts for us.