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

@ -16,15 +16,47 @@ installs to Helm v3.
.. code-block:: none
~(keystone-admin)]$ mkdir plugin
wget https://github.com/helm/helm-2to3/releases/download/v0.9.0/helm-2to3_0.9.0_linux_amd64.tar.gz
pushd plugin/
tar -xvzf ../helm-2to3_0.9.0_linux_amd64.tar.gz
mkdir bin
cp 2to3 bin
popd
export HELM_LINTER_PLUGIN_NO_INSTALL_HOOK=true
helm plugin install ./plugin
helm plugin install /usr/local/share/helm/plugins/2to3
#. Fetch existing helmv2 config.
.. code-block:: none
cat >get_helmv2_config.sh<<'EOF'
JSONPATH='{range .items[*]}{"\n"}{@.metadata.name}:{@.metadata.deletionTimestamp}{range @.status.conditions[*]}{":"}{@.type}={@.status}{end}{end}'
ARMADA_PODS=( $(kubectl get pods -n armada \
--kubeconfig=/etc/kubernetes/admin.conf \
--selector=application=armada,component=api \
--field-selector status.phase=Running \
--output=jsonpath="$JSONPATH") )
if [ $#ARMADA_PODS[@] -eq 0 ]; then
echo "$NAME: ERROR - Could not find armada pod."
exit 1
fi# Get first available Running and Ready armada pod, with tiller container
POD=""
for LINE in "$ARMADA_PODS[@]"; do
# match only Ready pods with nil deletionTimestamp
if [[ $LINE =~ ::.*Ready=True ]]; then
# extract pod name, it is first element delimited by :
A=$( cut -d ':' -f 1 - <<< "$LINE" )
P=$A[0]
else
continue
fi
kubectl --kubeconfig=/etc/kubernetes/admin.conf \
cp armada/$P:tmp/.helm "$HOME"/.helm -c tiller
RC=$?
if [ $RC -eq 0 ]; then
echo "$NAME: helmv2 config copied to $HOME/.helm"
break
else
echo "$NAME: ERROR - failed to copy helm config from helmv2 (tiller) to host. (RETURNED: $RC)"
exit 1
fi
done
EOF
#. Move the helm2 config to helm3.
@ -42,7 +74,12 @@ installs to Helm v3.
.. code-block:: none
~(keystone-admin)]$ ./migrate_helm_release.py myApplication
~(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.

View File

@ -16,15 +16,47 @@ installs to Helm v3.
.. code-block:: none
~(keystone-admin)]$ mkdir plugin
wget https://github.com/helm/helm-2to3/releases/download/v0.9.0/helm-2to3_0.9.0_linux_amd64.tar.gz
pushd plugin/
tar -xvzf ../helm-2to3_0.9.0_linux_amd64.tar.gz
mkdir bin
cp 2to3 bin
popd
export HELM_LINTER_PLUGIN_NO_INSTALL_HOOK=true
helm plugin install ./plugin
helm plugin install /usr/local/share/helm/plugins/2to3
#. Fetch existing helmv2 config.
.. code-block:: none
cat >get_helmv2_config.sh<<'EOF'
JSONPATH='{range .items[*]}{"\n"}{@.metadata.name}:{@.metadata.deletionTimestamp}{range @.status.conditions[*]}{":"}{@.type}={@.status}{end}{end}'
ARMADA_PODS=( $(kubectl get pods -n armada \
--kubeconfig=/etc/kubernetes/admin.conf \
--selector=application=armada,component=api \
--field-selector status.phase=Running \
--output=jsonpath="$JSONPATH") )
if [ $#ARMADA_PODS[@] -eq 0 ]; then
echo "$NAME: ERROR - Could not find armada pod."
exit 1
fi# Get first available Running and Ready armada pod, with tiller container
POD=""
for LINE in "$ARMADA_PODS[@]"; do
# match only Ready pods with nil deletionTimestamp
if [[ $LINE =~ ::.*Ready=True ]]; then
# extract pod name, it is first element delimited by :
A=$( cut -d ':' -f 1 - <<< "$LINE" )
P=$A[0]
else
continue
fi
kubectl --kubeconfig=/etc/kubernetes/admin.conf \
cp armada/$P:tmp/.helm "$HOME"/.helm -c tiller
RC=$?
if [ $RC -eq 0 ]; then
echo "$NAME: helmv2 config copied to $HOME/.helm"
break
else
echo "$NAME: ERROR - failed to copy helm config from helmv2 (tiller) to host. (RETURNED: $RC)"
exit 1
fi
done
EOF
#. Move the helm2 config to helm3.
@ -42,7 +74,12 @@ installs to Helm v3.
.. code-block:: none
~(keystone-admin)]$ ./migrate_helm_release.py myApplication
~(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.