Skip to content

Commit 7109535

Browse files
authored
Merge pull request #45083 from rh-max/srvls-serving-pvc-support
[SRVKS-887] Add Knative services PersistentVolumeClaim ConfigMap
2 parents 8bd0d65 + c9040b7 commit 7109535

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * serverless/admin_guide/serverless-configuration.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="serverless-enabling-pvc-support_{context}"]
7+
= Enabling PVC support
8+
9+
Some serverless applications need permanent data storage. To achieve this, you can configure persistent volume claims (PVCs) for your Knative services.
10+
11+
.Procedure
12+
13+
. To enable Knative Serving to use PVCs and write to them, modify the `KnativeServing` custom resource (CR) to include the following YAML:
14+
+
15+
.Enabling PVCs with write access
16+
[source,yaml]
17+
----
18+
...
19+
spec:
20+
config:
21+
features:
22+
"kubernetes.podspec-persistent-volume-claim": enabled
23+
"kubernetes.podspec-persistent-volume-write": enabled
24+
...
25+
----
26+
+
27+
* The `kubernetes.podspec-persistent-volume-claim` extension controls whether persistent volumes (PVs) can be used with Knative Serving.
28+
* The `kubernetes.podspec-persistent-volume-write` extension controls whether PVs are available to Knative Serving with the write access.
29+
30+
. To claim a PV, modify your service to include the PV configuration. For example, you might have a persistent volume claim with the following configuration:
31+
+
32+
[NOTE]
33+
====
34+
Use the storage class that supports the access mode that you are requesting. For example, you can the `ocs-storagecluster-cephfs` class for the `ReadWriteMany` access mode.
35+
====
36+
+
37+
.PersistentVolumeClaim configuration
38+
[source,yaml]
39+
----
40+
apiVersion: v1
41+
kind: PersistentVolumeClaim
42+
metadata:
43+
name: example-pv-claim
44+
namespace: my-ns
45+
spec:
46+
accessModes:
47+
- ReadWriteMany
48+
storageClassName: ocs-storagecluster-cephfs
49+
resources:
50+
requests:
51+
storage: 1Gi
52+
----
53+
+
54+
In this case, to claim a PV with write access, modify your service as follows:
55+
+
56+
.Knative service PVC configuration
57+
[source,yaml]
58+
----
59+
apiVersion: serving.knative.dev/v1
60+
kind: Service
61+
metadata:
62+
namespace: my-ns
63+
...
64+
spec:
65+
template:
66+
spec:
67+
containers:
68+
...
69+
volumeMounts: <1>
70+
- mountPath: /data
71+
name: mydata
72+
readOnly: false
73+
volumes:
74+
- name: mydata
75+
persistentVolumeClaim: <2>
76+
claimName: example-pv-claim
77+
readOnly: false <3>
78+
----
79+
<1> Volume mount specification.
80+
<2> Persistent volume claim specification.
81+
<3> Flag that enables read-only access.
82+
+
83+
[NOTE]
84+
====
85+
To successfully use persistent storage in Knative services, you need additional configuration, such as the user permissions for the Knative container user.
86+
====

serverless/admin_guide/serverless-configuration.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@ include::modules/serverless-https-redirect-global.adoc[leveloffset=+1]
2424
include::modules/serverless-url-scheme-external-routes.adoc[leveloffset=+1]
2525
// Kourier Gateway service type
2626
include::modules/serverless-kourier-gateway-service-type.adoc[leveloffset=+1]
27+
// Enabling PVC for Serving
28+
include::modules/serverless-enabling-pvc-support.adoc[leveloffset=+1]
2729

2830
ifdef::openshift-enterprise[]
2931
[id="additional-resources_knative-serving-CR-config"]
3032
[role="_additional-resources"]
3133
== Additional resources
3234
* xref:../../operators/understanding/crds/crd-managing-resources-from-crds.adoc[Managing resources from custom resource definitions]
35+
* xref:../../storage/understanding-persistent-storage.adoc#understanding-persistent-storage[Understanding persistent storage]
3336
endif::[]

0 commit comments

Comments
 (0)