Skip to content

Commit

Permalink
updates to kubernetes-statepersistence
Browse files Browse the repository at this point in the history
  • Loading branch information
Bharath Kaimal authored and Bharath Kaimal committed Jul 30, 2024
1 parent 5fc925f commit eb5c573
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 53 deletions.
24 changes: 12 additions & 12 deletions docs/openshift/state-persistence/index.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# State Persistence

State persistence in the context of Kubernetes/OpenShift refers to the ability to maintain and retain the state or data of applications even when they are stopped, restarted, or moved between nodes. This is achieved through the use of volumes, persistent volumes (PVs), and persistent volume claims (PVCs). Volumes provide a way to store and access data in a container, while PVs serve as the underlying storage resources provisioned by the cluster. PVCs act as requests made by applications for specific storage resources from the available PVs. By utilizing PVs and PVCs, applications can ensure that their state is preserved and accessible across pod restarts and migrations, enabling reliable and consistent data storage and retrieval throughout the cluster.
State persistence in the context of Kubernetes/OpenShift refers to the ability to maintain and retain the state or data of applications even when they are stopped, restarted, or moved between nodes.

## Resources
This is achieved through the use of volumes, persistent volumes (PVs), and persistent volume claims (PVCs). **Volumes** provide a way to store and access data in a container, while **PVs** serve as the underlying storage resources provisioned by the cluster. **PVCs** act as requests made by applications for specific storage resources from the available PVs. By utilizing PVs and PVCs, applications can ensure that their state is preserved and accessible across pod restarts and migrations, enabling reliable and consistent data storage and retrieval throughout the cluster.

## Resources

[Volumes :fontawesome-solid-globe:](https://kubernetes.io/docs/concepts/storage/volumes/){ .md-button target="_blank"}
[Volumes :fontawesome-solid-database:](https://kubernetes.io/docs/concepts/storage/volumes/){ .md-button target="\_blank"}

[Persistent Volumes :fontawesome-solid-globe:](https://kubernetes.io/docs/concepts/storage/persistent-volumes/){ .md-button target="_blank"}
[Persistent Volumes :fontawesome-solid-database:](https://kubernetes.io/docs/concepts/storage/persistent-volumes/){ .md-button target="\_blank"}

[Persistent Volume Claims :fontawesome-solid-globe:](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims){ .md-button target="_blank"}
[Persistent Volume Claims :fontawesome-solid-database:](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims){ .md-button target="\_blank"}

## References

Expand All @@ -25,16 +26,15 @@ spec:
requests:
storage: 1Gi
```
In this example, we define a PVC named my-pvc with the following specifications:
accessModes specify that the volume can be mounted as read-write by a single node at a time (ReadWriteOnce).
resources.requests.storage specifies the requested storage size for the PVC (1Gi).
In this example, we define a PVC named _my-pvc_ with the following specifications:
- _accessModes_ specify that the volume can be mounted as read-write by a single node at a time ("ReadWriteOnce")
- _resources.requests.storage_ specifies the requested storage size for the PVC ("1Gi")
## Activities
| Task | Description | Link |
| --------------------------------| ------------------ |:----------- |
| *** Try It Yourself *** | |
| Task | Description | Link |
| ----------------------------- | ------------------------------------------------------------ | :-------------------------------------------------------------------- |
| **_Try It Yourself_** | |
| Setting up Persistent Volumes | Create a Persistent Volume that's accessible from a SQL Pod. | [Setting up Persistent Volumes](../../labs/kubernetes/lab10/index.md) |
40 changes: 22 additions & 18 deletions docs/openshift/state-persistence/pv-pvc.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,23 @@ Pods access storage by using the claim as a volume. Claims must exist in the sam

PersistentVolumes binds are exclusive, and since PersistentVolumeClaims are namespaced objects, mounting claims with “Many” modes (ROX, RWX) is only possible within one namespace.



## Resources

=== "OpenShift"

[Persistent Storage :fontawesome-solid-globe:](https://docs.openshift.com/container-platform/4.13/storage/understanding-persistent-storage.html){ .md-button target="_blank"}
[Persistent Storage :fontawesome-solid-database:](https://docs.openshift.com/container-platform/4.13/storage/understanding-persistent-storage.html){ .md-button target="_blank"}

[Persistent Volume Types :fontawesome-solid-globe:](https://docs.openshift.com/container-platform/4.13/storage/understanding-persistent-storage.html#types-of-persistent-volumes_understanding-persistent-storage){ .md-button target="_blank"}
[Persistent Volume Types :fontawesome-solid-database:](https://docs.openshift.com/container-platform/4.13/storage/understanding-persistent-storage.html#types-of-persistent-volumes_understanding-persistent-storage){ .md-button target="_blank"}

[Expanding Peristent Volumes :fontawesome-solid-globe:](https://docs.openshift.com/container-platform/4.13/storage/expanding-persistent-volumes.html){ .md-button target="_blank"}
[Expanding Peristent Volumes :fontawesome-solid-database:](https://docs.openshift.com/container-platform/4.13/storage/expanding-persistent-volumes.html){ .md-button target="_blank"}

=== "Kubernetes"

[Persistent Volumes :fontawesome-solid-globe:](https://kubernetes.io/docs/concepts/storage/persistent-volumes/){ .md-button target="_blank"}
[Persistent Volumes :fontawesome-solid-database:](https://kubernetes.io/docs/concepts/storage/persistent-volumes/){ .md-button target="_blank"}

[Writing Portable Configurations :fontawesome-solid-globe:](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#writing-portable-configuration){ .md-button target="_blank"}
[Writing Portable Configurations :fontawesome-solid-database:](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#writing-portable-configuration){ .md-button target="_blank"}

[Configuring Persistent Volume Storage :fontawesome-solid-globe:](https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/){ .md-button target="_blank"}
[Configuring Persistent Volume Storage :fontawesome-solid-database:](https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/){ .md-button target="_blank"}

## References

Expand Down Expand Up @@ -69,16 +68,21 @@ metadata:
name: my-pod
spec:
containers:
- name: nginx
image: busybox
command: ['sh', '-c', 'echo $(date):$HOSTNAME Hello Kubernetes! >> /mnt/data/message.txt && sleep 3600']
volumeMounts:
- mountPath: "/mnt/data"
name: my-data
- name: nginx
image: busybox
command:
[
"sh",
"-c",
"echo $(date):$HOSTNAME Hello Kubernetes! >> /mnt/data/message.txt && sleep 3600",
]
volumeMounts:
- mountPath: "/mnt/data"
name: my-data
volumes:
- name: my-data
persistentVolumeClaim:
claimName: my-pvc
- name: my-data
persistentVolumeClaim:
claimName: my-pvc
```
=== "OpenShift"
Expand All @@ -103,4 +107,4 @@ spec:

``` Bash title="Get the Persistent Volume Claims"
kubectl get pvc
```
```
45 changes: 22 additions & 23 deletions docs/openshift/state-persistence/volumes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ A Kubernetes volume, on the other hand, has an explicit lifetime - the same as t

=== "OpenShift"

[Volume Lifecycle :fontawesome-solid-globe:](https://docs.openshift.com/container-platform/4.13/storage/understanding-persistent-storage.html#lifecycle-volume-claim_understanding-persistent-storage){ .md-button target="_blank"}
[Volume Lifecycle :fontawesome-solid-database:](https://docs.openshift.com/container-platform/4.13/storage/understanding-persistent-storage.html#lifecycle-volume-claim_understanding-persistent-storage){ .md-button target="_blank"}

=== "Kubernetes"

[Volumes :fontawesome-solid-globe:](https://kubernetes.io/docs/concepts/storage/volumes/){ .md-button target="_blank"}

[Volumes :fontawesome-solid-database:](https://kubernetes.io/docs/concepts/storage/volumes/){ .md-button target="_blank"}

## References

Expand All @@ -26,15 +25,15 @@ metadata:
name: my-pod
spec:
containers:
- image: busybox
command: ['sh', '-c', 'echo Hello Kubernetes! && sleep 3600']
name: busybox
volumeMounts:
- mountPath: /cache
name: cache-volume
- image: busybox
command: ["sh", "-c", "echo Hello Kubernetes! && sleep 3600"]
name: busybox
volumeMounts:
- mountPath: /cache
name: cache-volume
volumes:
- name: cache-volume
emptyDir: {}
- name: cache-volume
emptyDir: {}
```
```yaml
Expand All @@ -44,16 +43,16 @@ metadata:
name: test-pd
spec:
containers:
- image: bitnami/nginx
name: test-container
volumeMounts:
- mountPath: /test-pd
name: test-volume
- image: bitnami/nginx
name: test-container
volumeMounts:
- mountPath: /test-pd
name: test-volume
volumes:
- name: test-volume
hostPath:
# directory location on host
path: /data
# this field is optional
type: Directory
```
- name: test-volume
hostPath:
# directory location on host
path: /data
# this field is optional
type: Directory
```

0 comments on commit eb5c573

Please sign in to comment.