Merge "Helm release migration from v2 to v3 (r5,r6,r7,r8,dsR6,dsR7,dsR8)"

This commit is contained in:
Zuul 2023-08-04 20:51:41 +00:00 committed by Gerrit Code Review
commit 5a35c349cf
2 changed files with 188 additions and 114 deletions

View File

@ -1,57 +1,94 @@
.. _migrate-releases-from-helm-v2-to-helm-v3-9984e7aa7374: .. _migrate-releases-from-helm-v2-to-helm-v3-9984e7aa7374:
======================================== ========================================
Migrate Releases from Helm v2 to Helm v3 Migrate Releases from Helm v2 to Helm v3
======================================== ========================================
.. rubric:: |context| .. rubric:: |context|
After upgrading a cluster, end users' Helm releases are not upgraded from After upgrading a cluster, end users' Helm releases are not upgraded from
version 2. Run a custom script to migrate the end users' Helm releases or version 2. Run a custom script to migrate the end users' Helm releases or
installs to Helm v3. installs to Helm v3.
.. rubric:: |proc| .. rubric:: |proc|
#. Install the /helm-2to3 plugin. #. Install the /helm-2to3 plugin.
.. code-block:: none .. code-block:: none
~(keystone-admin)]$ mkdir plugin export HELM_LINTER_PLUGIN_NO_INSTALL_HOOK=true
wget https://github.com/helm/helm-2to3/releases/download/v0.9.0/helm-2to3_0.9.0_linux_amd64.tar.gz helm plugin install /usr/local/share/helm/plugins/2to3
pushd plugin/
tar -xvzf ../helm-2to3_0.9.0_linux_amd64.tar.gz #. Fetch existing helmv2 config.
mkdir bin
cp 2to3 bin .. code-block:: none
popd
export HELM_LINTER_PLUGIN_NO_INSTALL_HOOK=true cat >get_helmv2_config.sh<<'EOF'
helm plugin install ./plugin JSONPATH='{range .items[*]}{"\n"}{@.metadata.name}:{@.metadata.deletionTimestamp}{range @.status.conditions[*]}{":"}{@.type}={@.status}{end}{end}'
ARMADA_PODS=( $(kubectl get pods -n armada \
#. Move the helm2 config to helm3. --kubeconfig=/etc/kubernetes/admin.conf \
--selector=application=armada,component=api \
.. code-block:: none --field-selector status.phase=Running \
--output=jsonpath="$JSONPATH") )
~(keystone-admin)]$ helm 2to3 move config if [ $#ARMADA_PODS[@] -eq 0 ]; then
echo "$NAME: ERROR - Could not find armada pod."
#. Choose a Helm v2 release to migrate. exit 1
fi# Get first available Running and Ready armada pod, with tiller container
.. code-block:: none POD=""
for LINE in "$ARMADA_PODS[@]"; do
~(keystone-admin)]$ helmv2-cli -- helm list -a # match only Ready pods with nil deletionTimestamp
if [[ $LINE =~ ::.*Ready=True ]]; then
#. Migrate a helm2 release, for example, myApplication. # extract pod name, it is first element delimited by :
A=$( cut -d ':' -f 1 - <<< "$LINE" )
.. code-block:: none P=$A[0]
else
~(keystone-admin)]$ ./migrate_helm_release.py myApplication continue
fi
#. Check if it migrated successfully. kubectl --kubeconfig=/etc/kubernetes/admin.conf \
cp armada/$P:tmp/.helm "$HOME"/.helm -c tiller
.. code-block:: none RC=$?
if [ $RC -eq 0 ]; then
~(keystone-admin)]$ helm list -A -a echo "$NAME: helmv2 config copied to $HOME/.helm"
break
#. The migrated release should not appear in helm2. else
echo "$NAME: ERROR - failed to copy helm config from helmv2 (tiller) to host. (RETURNED: $RC)"
.. code-block:: none exit 1
fi
~(keystone-admin)]$ helmv2-cli -- helm list -a done
EOF
#. Move the helm2 config to helm3.
.. code-block:: none
~(keystone-admin)]$ helm 2to3 move config
#. Choose a Helm v2 release to migrate.
.. code-block:: none
~(keystone-admin)]$ helmv2-cli -- helm list -a
#. Migrate a helm2 release, for example, myApplication.
.. code-block:: none
~(keystone-admin)]$ migrate_helm_release.py myApplication
.. note::
The script ``migrate_helm_release.py`` is part of the |prod| release
package.
#. Check if it migrated successfully.
.. code-block:: none
~(keystone-admin)]$ helm list -A -a
#. The migrated release should not appear in helm2.
.. code-block:: none
~(keystone-admin)]$ helmv2-cli -- helm list -a

View File

@ -1,57 +1,94 @@
.. _migrate-releases-from-helm-v2-to-helm-v3-a6066193c2a8: .. _migrate-releases-from-helm-v2-to-helm-v3-a6066193c2a8:
======================================== ========================================
Migrate Releases from Helm v2 to Helm v3 Migrate Releases from Helm v2 to Helm v3
======================================== ========================================
.. rubric:: |context| .. rubric:: |context|
After upgrading a cluster, end users' Helm releases are not upgraded from After upgrading a cluster, end users' Helm releases are not upgraded from
version 2. Run a custom script to migrate the end users' Helm releases or version 2. Run a custom script to migrate the end users' Helm releases or
installs to Helm v3. installs to Helm v3.
.. rubric:: |proc| .. rubric:: |proc|
#. Install the /helm-2to3 plugin. #. Install the /helm-2to3 plugin.
.. code-block:: none .. code-block:: none
~(keystone-admin)]$ mkdir plugin export HELM_LINTER_PLUGIN_NO_INSTALL_HOOK=true
wget https://github.com/helm/helm-2to3/releases/download/v0.9.0/helm-2to3_0.9.0_linux_amd64.tar.gz helm plugin install /usr/local/share/helm/plugins/2to3
pushd plugin/
tar -xvzf ../helm-2to3_0.9.0_linux_amd64.tar.gz #. Fetch existing helmv2 config.
mkdir bin
cp 2to3 bin .. code-block:: none
popd
export HELM_LINTER_PLUGIN_NO_INSTALL_HOOK=true cat >get_helmv2_config.sh<<'EOF'
helm plugin install ./plugin JSONPATH='{range .items[*]}{"\n"}{@.metadata.name}:{@.metadata.deletionTimestamp}{range @.status.conditions[*]}{":"}{@.type}={@.status}{end}{end}'
ARMADA_PODS=( $(kubectl get pods -n armada \
#. Move the helm2 config to helm3. --kubeconfig=/etc/kubernetes/admin.conf \
--selector=application=armada,component=api \
.. code-block:: none --field-selector status.phase=Running \
--output=jsonpath="$JSONPATH") )
~(keystone-admin)]$ helm 2to3 move config if [ $#ARMADA_PODS[@] -eq 0 ]; then
echo "$NAME: ERROR - Could not find armada pod."
#. Choose a Helm v2 release to migrate. exit 1
fi# Get first available Running and Ready armada pod, with tiller container
.. code-block:: none POD=""
for LINE in "$ARMADA_PODS[@]"; do
~(keystone-admin)]$ helmv2-cli -- helm list -a # match only Ready pods with nil deletionTimestamp
if [[ $LINE =~ ::.*Ready=True ]]; then
#. Migrate a helm2 release, for example, myApplication. # extract pod name, it is first element delimited by :
A=$( cut -d ':' -f 1 - <<< "$LINE" )
.. code-block:: none P=$A[0]
else
~(keystone-admin)]$ ./migrate_helm_release.py myApplication continue
fi
#. Check if it migrated successfully. kubectl --kubeconfig=/etc/kubernetes/admin.conf \
cp armada/$P:tmp/.helm "$HOME"/.helm -c tiller
.. code-block:: none RC=$?
if [ $RC -eq 0 ]; then
~(keystone-admin)]$ helm list -A -a echo "$NAME: helmv2 config copied to $HOME/.helm"
break
#. The migrated release should not appear in helm2. else
echo "$NAME: ERROR - failed to copy helm config from helmv2 (tiller) to host. (RETURNED: $RC)"
.. code-block:: none exit 1
fi
~(keystone-admin)]$ helmv2-cli -- helm list -a done
EOF
#. Move the helm2 config to helm3.
.. code-block:: none
~(keystone-admin)]$ helm 2to3 move config
#. Choose a Helm v2 release to migrate.
.. code-block:: none
~(keystone-admin)]$ helmv2-cli -- helm list -a
#. Migrate a helm2 release, for example, myApplication.
.. code-block:: none
~(keystone-admin)]$ migrate_helm_release.py myApplication
.. note::
The script ``migrate_helm_release.py`` is part of the |prod| release
package.
#. Check if it migrated successfully.
.. code-block:: none
~(keystone-admin)]$ helm list -A -a
#. The migrated release should not appear in helm2.
.. code-block:: none
~(keystone-admin)]$ helmv2-cli -- helm list -a