Skip to content

Commit 98ed42d

Browse files
Anthony Sansonejwilliams-mongo
authored andcommitted
(DOCSP-6412) Add PV resize tutorial
1 parent 63dd9ce commit 98ed42d

File tree

3 files changed

+231
-16
lines changed

3 files changed

+231
-16
lines changed
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
---
2+
stepnum: 1
3+
level: 4
4+
ref: select-resource
5+
title: Create or identify a persistent |k8s-custom-resource|.
6+
content: |
7+
8+
Use an existing database resource or create a new one with persistent
9+
storage. Wait until the peristent volume gets to the ``Running``
10+
state.
11+
12+
.. example::
13+
14+
A database resource with persistent storage would include:
15+
16+
.. code-block:: yaml
17+
:linenos:
18+
:emphasize-lines: 13-15
19+
20+
apiVersion: mongodb.com/v1
21+
kind: MongoDB
22+
metadata:
23+
name: <my-replica-set>
24+
spec:
25+
members: 3
26+
version: 4.0.4
27+
project: my-project
28+
credentials: my-credentials
29+
type: ReplicaSet
30+
podSpec:
31+
memory: 300M
32+
persistence:
33+
single:
34+
storage: 1G
35+
36+
---
37+
stepnum: 2
38+
level: 4
39+
ref: insert-data
40+
title: Insert data to the database that the resource serves.
41+
content: |
42+
43+
a. Start |mongo| in the |k8s| cluster.
44+
45+
.. code-block:: sh
46+
47+
$kubectl exec -it <my-replica-set>-0 \
48+
/var/lib/mongodb-mms-automation/mongodb-linux-x86_64-4.0.4/bin/mongo
49+
50+
b. Insert data into the ``test`` database.
51+
52+
.. code-block:: javascript
53+
:copyable: false
54+
55+
<my-replica-set>:PRIMARY> use test
56+
57+
switched to db test
58+
59+
<my-replica-set>:PRIMARY> db.tmp.insert({"foo":"bar"})
60+
61+
WriteResult({ "nInserted" : 1 })
62+
63+
---
64+
stepnum: 3
65+
level: 4
66+
ref: patch-pv
67+
title: Patch each persistence volume.
68+
content: |
69+
70+
Invoke the following commands for the entire replica set:
71+
72+
.. code-block:: sh
73+
74+
kubectl patch pvc/"data-<my-replica-set>-0" -p='{"spec": {"resources": {"requests": {"storage": "2Gi"}}}}'
75+
kubectl patch pvc/"data-<my-replica-set>-1" -p='{"spec": {"resources": {"requests": {"storage": "2Gi"}}}}'
76+
kubectl patch pvc/"data-<my-replica-set>-2" -p='{"spec": {"resources": {"requests": {"storage": "2Gi"}}}}'
77+
78+
Wait until each |k8s-pvc| gets to the following condition:
79+
80+
.. code-block:: yaml
81+
82+
- lastProbeTime: null
83+
lastTransitionTime: "2019-08-01T12:11:39Z"
84+
message: Waiting for user to (re-)start a pod to finish file
85+
system resize of volume on node.
86+
status: "True"
87+
type: FileSystemResizePending
88+
---
89+
stepnum: 4
90+
level: 4
91+
ref: update-crd
92+
title: Update the database resource with a new storage value.
93+
content: |
94+
95+
.. example::
96+
97+
To update the disk size of the replica set to 2 GB, change the
98+
``storage`` value in database resource specification:
99+
100+
.. code-block:: yaml
101+
:linenos:
102+
:emphasize-lines: 15
103+
104+
apiVersion: mongodb.com/v1
105+
kind: MongoDB
106+
metadata:
107+
name: <my-replica-set>
108+
spec:
109+
members: 3
110+
version: 4.0.4
111+
project: my-project
112+
credentials: my-credentials
113+
type: ReplicaSet
114+
podSpec:
115+
memory: 300M
116+
persistence:
117+
single:
118+
storage: 2G
119+
120+
---
121+
stepnum: 5
122+
level: 4
123+
ref: recreate-statefulsets
124+
title: Recreate the StatefulSets.
125+
content: |
126+
127+
a. Delete a |k8s-statefulset| resource.
128+
129+
.. code-block:: sh
130+
131+
kubectl delete sts --cascade=false <my-replica-set>
132+
133+
b. Recreate a |k8s-statefulset| resource with the new volume size.
134+
135+
|k8s-op-short| deletes the |k8s-statefulset|, but the pods remain
136+
unchanged and running.
137+
138+
.. code-block:: sh
139+
140+
kubectl apply -f my-replica-set-vol.yaml
141+
142+
c. Wait until this StatefulSet achieves the ``Running`` state.
143+
144+
---
145+
stepnum: 6
146+
level: 4
147+
ref: update-pods
148+
title: Update the pods in a rolling fashion.
149+
content: |
150+
151+
Invoke the following command:
152+
153+
.. code-block:: sh
154+
155+
kubectl rollout restart sts <my-replica-set>
156+
---
157+
stepnum: 7
158+
level: 4
159+
ref: validate-pv-change
160+
title: Validate data exists on the updated |k8s-pvc|.
161+
content: |
162+
163+
If the |k8s-pvs| were reused, the data that you inserted in **Step
164+
2** can be found on the databases stored in |k8s-pvs|:
165+
166+
.. code-block:: sh
167+
168+
$ kubectl exec -it <my-replica-set>-1 \
169+
/var/lib/mongodb-mms-automation/mongodb-linux-x86_64-4.0.4/bin/mongo
170+
171+
.. code-block:: javascript
172+
:copyable: false
173+
174+
<my-replica-set>:PRIMARY> use test
175+
switched to db test
176+
177+
<my-replica-set>:PRIMARY> db.tmp.count()
178+
1

source/tutorial/edit-deployment.txt

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ top-level :term:`sharded cluster <sharded cluster>` or
2020
sharded cluster, or an individual process within a replica set. You can
2121
also modify :term:`standalone <standalone>` processes.
2222

23+
Considerations
24+
--------------
25+
26+
- Changes cannot be made to individual members of a replica set or
27+
sharded cluster, only to the whole set or cluster.
28+
29+
- If a setting isn't available for a MongoDB Kubernetes resource,
30+
then the change must be made in the :opsmgr:`Ops Manager </>` or
31+
:cloudmgr:`Cloud Manager </>` application.
32+
33+
- .. include:: /includes/admonitions/fact-unsupported-mongod-options.rst
34+
35+
- Certain settings can only be configured using |k8s-op-short|. To
36+
review the list of settings, see
37+
:doc:`/reference/k8s-op-exclusive-settings`.
38+
2339
Prerequisites
2440
-------------
2541

@@ -45,25 +61,10 @@ Procedure
4561

4662
kubectl apply -f <standalone-conf>.yaml
4763

48-
Considerations
49-
--------------
50-
51-
- Changes cannot be made to individual members of a replica set or
52-
sharded cluster, only to the whole set or cluster.
53-
54-
- If a setting is not available for a MongoDB Kubernetes resource,
55-
then the change must be made in the |mms| or
56-
`Cloud Manager <docs.cloudmanager.com/current/>`__ application.
57-
58-
- .. include:: /includes/admonitions/fact-unsupported-mongod-options.rst
59-
60-
- Certain settings can only be configured using |k8s-op-short|. To
61-
review the list of settings,
62-
see :doc:`/reference/k8s-op-exclusive-settings`.
63-
6464
.. toctree::
6565
:titlesonly:
6666
:hidden:
6767

6868
/tutorial/upgrade-mdb-version
6969
/tutorial/scale-resources
70+
/tutorial/resize-pv-storage
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.. _k8s-resize-storage:
2+
3+
========================================
4+
Resize Storage for One Database Resource
5+
========================================
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
16+
Prerequisites
17+
-------------
18+
19+
Storage Class Must Support Resizing
20+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21+
22+
Make sure the |k8s-sc| and volume plugin provider that the |k8s-pvs|
23+
use supports resize:
24+
25+
.. code-block:: sh
26+
27+
kubectl patch storageclass/<my-storageclass> --type='json' \
28+
-p='[{"op": "add", "path": "/allowVolumeExpansion", "value": true }]'
29+
30+
If you don't have a StorageClass that supports resizing, ask your |k8s|
31+
administrator to help.
32+
33+
Procedure
34+
---------
35+
36+
.. include:: /includes/steps/resize-storage.rst

0 commit comments

Comments
 (0)