- Refer Here for official docs.
- Namespaces provide logical grouping.
- Generally in k8s cluster we will have two major namespaces
- default: This is default namespace where all the resources executed by user are created
- kube-system: In this namespace pods/resources w.r.t running kubernetes cluster will be executing.
Jobs & Cron Jobs
- Consider a scenario where you are expected to run some activity (script) which runs for a certain time and goes to completion.
- Many applications have batch jobs which run based on some schedules for a period of time.
- If we have to run some job based on schedule then cronjob is used.
- For cron syntax Refer Here
- Refer Here for the changes done.
- Run the job
- Run the cron job
- Run the download cron job
- To persist the data in the Read/Write Layer, docker has volumes.
- K8s supports volumes to persist the data. The types of volumes which are supported by k8s are
- This gives volume with the help of mnt namespace to the container.
- Volume’s lifecyle is equivalent to lifecycle of Pod
- Ephemeral Volume:
- This is also temporary volume used for containers where they require any persistent storage across Pod restarts/creations.
- Persistent Volume:
- This stores volumes and has no relation with life time of Pod.
- This uses Storage Classes which help for dynamic provisioing of storage (i.e. create azure managed disk or ebs volume or azure fileshare or aws elastic file system automatically) or admins manually provisioning storage and providing it as storage class.
- Projected Volumes
- Refer Here for volumes official docs
- Lets create a mysql pod with a k8s volume and insert some data into it.
- Login into pod
kubectl exec --it mysql-vol-pod -- mysql -u root -pand create some data (I have created a table)
- delete the pod and create the new pod and verify for the data.
- Volumes cannot persist the data above or beyond the lifecylce of Pod.
- SO we need to use Persistent Volumes.
K8s Persistent Volumes
- These help in persisting the data beyond the lifecycle of Pod
- To work with Persistent Volumes we need to understand the following in addition to Persistent Volumes.