Skip to content

Commit 8ea7c91

Browse files
jdestefano-mongojwilliams-mongo
authored andcommitted
DOCSP-4997 - One CRD upgrade procedure. (#19)
* DOCSP-4997 - One CRD update documentation. * DOCSP-4997 - One CRD upgrade procedure. * DOCSP-4997 - Tech review feedback. * DOCSP-4997 - Copy and tech review feedback.
1 parent bc26e7f commit 8ea7c91

File tree

5 files changed

+251
-17
lines changed

5 files changed

+251
-17
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.. note::
2+
3+
The |k8s-op-short| does not support changing the type of an existing
4+
configuration even though it will accept a valid configuration for a
5+
different type.
6+
7+
For example, if your MongoDB resource is a
8+
standalone, you cannot set the value of ``spec.type`` to
9+
``ReplicaSet`` and set ``spec.members``. If you do, the
10+
|k8s-op-short| throws an error and requires you to revert to the
11+
previously working configuration.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
1. Verify you have the ``.yaml`` configuration file for each MongoDB
2+
resource you have deployed.
3+
4+
.. Formating hack, need whitespace below too
5+
6+
| \
7+
| **Standalone Resources**
8+
9+
10+
If you have standalone resources but do not have the ``.yaml``
11+
configuration file for them, run the following command to generate
12+
the configuration file:
13+
14+
.. code-block:: sh
15+
16+
kubectl mst <standalone-name> -n <namespace> -o yaml > <standalone-conf-name>.yaml
17+
18+
.. Formating hack, need whitespace below too
19+
20+
| \
21+
| **Replica Set Resources**
22+
23+
24+
If you have replica set resources but do not have the ``.yaml``
25+
configuration file for them, run the following command to generate
26+
the configuration file:
27+
28+
.. code-block:: sh
29+
30+
kubectl get mrs <replicaset-name> -n <namespace> -o yaml > <replicaset-conf-name>.yaml
31+
32+
.. Formating hack, need whitespace below too
33+
34+
| \
35+
| **Sharded Cluster Resources**
36+
37+
38+
If you have sharded cluster resources but do not have the ``.yaml``
39+
configuration file for them, run the following command to generate
40+
the configuration file:
41+
42+
.. code-block:: sh
43+
44+
kubectl get msc <shardedcluster-name> -n <namespace> -o yaml > <shardedcluster-conf-name>.yaml
45+
46+
#. Edit each ``.yaml`` configuration file match the new |k8s-crd|:
47+
48+
- Change the ``kind`` to ``MongoDB``
49+
- Add the ``spec.type`` field and set it to ``Standalone``,
50+
``ReplicaSet``, or ``ShardedCluster`` depending on your resource.
51+
52+
.. include:: /includes/fact-cannot-change-type.rst
53+
54+
After you edit each ``.yaml`` file, it should look like the following
55+
example:
56+
57+
.. tabs-deployments::
58+
59+
tabs:
60+
- id: standalone
61+
content: |
62+
.. literalinclude:: /reference/k8s/example-standalone-minimal.yaml
63+
:language: yaml
64+
:emphasize-lines: 3,13
65+
66+
- id: repl
67+
content: |
68+
.. literalinclude:: /reference/k8s/example-replica-set-minimal.yaml
69+
:language: yaml
70+
:emphasize-lines: 3,14
71+
72+
- id: shard
73+
content: |
74+
.. literalinclude:: /reference/k8s/example-sharded-cluster-minimal.yaml
75+
:language: yaml
76+
:emphasize-lines: 3,17
77+
78+
.. warning::
79+
80+
If you change the ``metadata.name`` field you will lose your
81+
resource's data.

source/includes/upgrade-one-crd.rst

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
1. After you upgrade the |k8s-op-short|, verify you have four CRDs by
2+
running the following command:
3+
4+
.. code-block:: sh
5+
6+
kubectl get crds
7+
8+
The following output contains the new ``mongodb.mongodb.com`` CRD and
9+
the version 0.9 CRDs:
10+
11+
.. code-block:: sh
12+
:copyable: false
13+
14+
NAME CREATED AT
15+
mongodb.mongodb.com 2019-03-27T19:30:09Z
16+
mongodbreplicasets.mongodb.com 2018-12-07T18:25:42Z
17+
mongodbshardedclusters.mongodb.com 2018-12-07T18:25:42Z
18+
mongodbstandalones.mongodb.com 2018-12-07T18:25:42Z
19+
20+
#. Remove the old resources from Kubernetes.
21+
22+
.. important::
23+
24+
Removing MongoDB resources will remove the database server pods
25+
and drop any client connections to the database. Connections are
26+
reestablished when the new MongoDB resources are created in
27+
Kubernetes.
28+
29+
Run each of the following commands to remove all MongoDB resources:
30+
31+
.. code-block:: sh
32+
33+
kubectl delete mst --all
34+
35+
.. code-block:: sh
36+
37+
kubectl delete mrs --all
38+
39+
.. code-block:: sh
40+
41+
kubectl delete msc --all
42+
43+
.. note::
44+
45+
MongoDB resources that have ``persistent: true`` set in their
46+
``.yaml`` configuration file will not lose data as it is stored in
47+
persistent volumes. The previous command only deletes pods
48+
containing MongoDB and not the persistent volumes containing the
49+
data. Persistent volume claims referencing persistent volumes stay
50+
alive and are reused by the new MongoDB resources.
51+
52+
#. Create the MongoDB resources again.
53+
54+
Use the ``.yaml`` resource configuration file to recreate each
55+
resource:
56+
57+
.. code-block:: sh
58+
59+
kubectl apply -f <resource-conf>.yaml
60+
61+
.. note::
62+
63+
If the old resources had ``persistent: true`` set and the
64+
``metadata.name`` haven't changed, the new MongoDB pods will
65+
reuse the data from the old pods.
66+
67+
Run the following command to check the status of each resource and
68+
verify that the ``phase`` reaches the ``Running`` status:
69+
70+
.. code-block:: sh
71+
72+
kubectl get mdb <resource-name> -n <namespace> -o yaml -w
73+
74+
For an example of this command's output, see
75+
:ref:`get-resource-status`.
76+
77+
| \
78+
79+
4. Delete the old CRDs.
80+
81+
Once all the resources are up and running, delete all of the v0.9
82+
CRDs as the |k8s-op-short| no longer watches them:
83+
84+
.. code-block:: sh
85+
86+
kubectl delete crd mongodbreplicasets.mongodb.com
87+
88+
.. code-block:: sh
89+
90+
kubectl delete crd mongodbshardedclusters.mongodb.com
91+
92+
.. code-block:: sh
93+
94+
kubectl delete crd mongodbstandalones.mongodb.com
95+
96+
Run the following command to verify the old CRDs were removed:
97+
98+
.. code-block:: sh
99+
100+
kubectl get crds
101+
102+
The output of the command above should look similar to the following:
103+
104+
.. code-block:: sh
105+
:copyable: false
106+
107+
NAME CREATED AT
108+
mongodb.mongodb.com 2019-03-27T19:30:09Z

source/reference/troubleshooting.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
:depth: 1
1313
:class: singlecol
1414

15+
.. _get-resource-status:
16+
1517
Get Status of MongoDB Resource
1618
------------------------------
1719

source/tutorial/install-k8s-operator.txt

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,37 @@ To create your |k8s| secret:
561561
Upgrade the |k8s-op-full|
562562
-------------------------
563563

564-
To upgrade to the latest version of the |k8s-op-full|:
564+
Version 0.10 of the |k8s-op-short| consolidates the
565+
``MongoDbStandalone``, ``MongoDbShardedCluster``, and
566+
``MongoDbReplicaSet`` |k8s-crds| into a
567+
single ``CustomResourceDefinition`` called ``MongoDB``.
568+
569+
Prerequisites
570+
~~~~~~~~~~~~~
571+
572+
.. important::
573+
574+
The following prerequisite steps are necessary if you already have
575+
resources managed by the |k8s-op-short| that you want to keep. If
576+
the resources had data persisted, then the persistent volumes are
577+
reused in the new resources created.
578+
579+
If you do not wish to retain data from previous deployments, skip
580+
this section and start from the :ref:`upgrade-k8s-operator-procedure`
581+
section.
582+
583+
.. include:: /includes/upgrade-one-crd-prereqs.rst
584+
585+
.. _upgrade-k8s-operator-procedure:
586+
587+
Procedure
588+
~~~~~~~~~
589+
590+
To upgrade to the latest version of the |k8s-op-short|:
591+
592+
1. Change to the directory in which you cloned the |k8s-op-short|
593+
repository. The following steps depend on how your environment is
594+
configured:
565595

566596
.. tabs::
567597

@@ -572,10 +602,7 @@ To upgrade to the latest version of the |k8s-op-full|:
572602

573603
.. _upgrade-k8s-operator-kubectl:
574604

575-
1. Change to the directory in which you cloned the
576-
|k8s-op-short| repository.
577-
578-
#. Upgrade the |k8s-crds| for MongoDB deployments using the
605+
2. Upgrade the |k8s-crds| for MongoDB deployments using the
579606
following kubectl_ command:
580607

581608
.. code-block:: sh
@@ -624,10 +651,7 @@ To upgrade to the latest version of the |k8s-op-full|:
624651

625652
.. _upgrade-k8s-operator-helm:
626653

627-
1. Change to the directory in which you cloned the
628-
|k8s-op-short| repository.
629-
630-
#. Upgrade the latest version of the |k8s-op-short| using the
654+
2. Upgrade the latest version of the |k8s-op-short| using the
631655
following ``helm`` command:
632656

633657
.. code-block:: sh
@@ -661,10 +685,7 @@ To upgrade to the latest version of the |k8s-op-full|:
661685
name: The Internet
662686
content: |
663687

664-
1. Change to the directory in which you cloned the
665-
|k8s-op-short| repository.
666-
667-
#. Upgrade the latest version of the |k8s-op-short|
688+
2. Upgrade the latest version of the |k8s-op-short|
668689
with modified pull policy values using the
669690
following ``helm`` command:
670691

@@ -690,10 +711,7 @@ To upgrade to the latest version of the |k8s-op-full|:
690711
name: Another Host
691712
content: |
692713

693-
1. Change to the directory in which you installed
694-
the |k8s-op-short|.
695-
696-
#. Upgrade the latest version of the |k8s-op-short|
714+
2. Upgrade the latest version of the |k8s-op-short|
697715
with modified pull policy values using the
698716
following ``helm`` command:
699717

@@ -710,3 +728,17 @@ To upgrade to the latest version of the |k8s-op-full|:
710728

711729
.. include:: /includes/list-table-k8s-helm-install-options-offline.rst
712730

731+
Recreate MongoDB Resources and Delete the Version 0.9 CRDs
732+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
733+
734+
.. include:: /includes/upgrade-one-crd.rst
735+
736+
Once the version 0.9 CRDs are deleted, the |k8s-op-full| upgrade is
737+
complete.
738+
739+
Troubleshooting
740+
~~~~~~~~~~~~~~~
741+
742+
To troubleshoot your |k8s-op-short|, see :ref:`review-k8s-op-logs`.
743+
744+
.. include:: /includes/fact-remove-k8s-resources-first.rst

0 commit comments

Comments
 (0)