Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
toolbox: gpu-operator/deploy_from_operatorhub.sh: add --install-plan=…
Browse files Browse the repository at this point in the history
…Automatic|Manual flag
  • Loading branch information
kpouget committed Aug 6, 2021
1 parent e539e14 commit e0bb763
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 11 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

(Organized release by release)

Features of version 0.1.3 (July 2021)
-------------------------------------

New feature
~~~~~~~~~~~

- gpu_operator_deploy_from_operatorhub: allow overriding subscription.spec.installPlanApproval `#219<https://github.com/openshift-psap/ci-artifacts/pull/219>`_

- ``./toolbox/gpu-operator/deploy_from_operatorhub.sh`` can receive a new flag ``--install-plan=Manual|Automatic`` (``Manual`` is the default) to override the Subscription install-plan approval setting when deploying from OperatorHub.


Features of version 0.1.2 (July 2021)
-------------------------------------

Bug fixes
~~~~~~~~~

- Extra fix for the ``subscriptions`` conflict `#218 <https://github.com/openshift-psap/ci-artifacts/pull/218>`_


Features of version 0.1.1 (July 2021)
-------------------------------------

Expand Down
6 changes: 5 additions & 1 deletion docs/toolbox/gpu_operator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Deployment

.. code-block:: shell
toolbox/gpu-operator/deploy_from_operatorhub.sh [<version>] [<channel>]
toolbox/gpu-operator/deploy_from_operatorhub.sh [<version> [<channel>]] [--install-plan=Automatic|Manual]
toolbox/gpu-operator/undeploy_from_operatorhub.sh
**Examples:**
Expand All @@ -26,6 +26,10 @@ Deployment
- Installs ``v1.6.2`` from the ``stable`` channel
- ``./toolbox/gpu-operator/deploy_from_operatorhub.sh --install-plan=Automatic``
- Forces the install plan approval to be set to ``Automatic``.
**Note about the GPU Operator channel:**
- Before ``v1.7.0``, the GPU Operator was using a unique channel name
Expand Down
52 changes: 42 additions & 10 deletions toolbox/gpu-operator/deploy_from_operatorhub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@ THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source ${THIS_DIR}/../_common.sh

DEPLOY_FROM_BUNDLE_FLAG="--from-bundle=master"
INSTALL_PLAN="--install-plan="

usage() {
cat <<EOF
Deploys the GPU Operator from OperatorHub / OLM
Usage:
$0
$0 <version> [<channel>]
$0 $DEPLOY_FROM_BUNDLE_FLAG
$0 <version> [<channel>] [--install-plan=Automatic|Manual]
Flags:
-h, --help Display this help message
$DEPLOY_FROM_BUNDLE_FLAG Deploy the current master-branch version from the bundle image
See roles/gpu_operator_deploy_from_operatorhub/defaults/main/bundle.yml for the image path.
${INSTALL_PLAN}Automatic|Manual
When deploying from OperatorHub, set the Subscription 'installPlanApproval' to Automatic or Manual (default).
<empty> Deploy the latest version available in OperatorHub
Expand All @@ -44,19 +47,48 @@ if [[ "${1:-}" == "$DEPLOY_FROM_BUNDLE_FLAG" ]]; then
usage
exit 1
fi
elif [[ "$#" == 0 ]]; then

elif [[ "${1:-}" == "-"* && "${1:-}" != "$INSTALL_PLAN"* ]]; then
echo "FATAL: unexpected parameters ... ($@)"
usage
exit 1
elif [[ "$#" == 0 || "$#" == 1 && "$1" == "$INSTALL_PLAN"* ]]; then
echo "Deploying the GPU Operator from OperatorHub using the latest version available."
elif [[ "$#" == 1 || "$#" == 2 ]]; then
if [[ "${1:-}" == "$INSTALL_PLAN"* ]]; then
approval=$(echo $1 | cut -d= -f2)
if [[ "$approval" != "Manual" && "$approval" != "Automatic" ]]; then
echo "FATAL: invalid value for $1. Must be Manual or Automatic."
usage
exit 1
fi
ANSIBLE_OPTS="${ANSIBLE_OPTS} -e gpu_operator_installplan_approval=$approval"
echo "Deploying the GPU Operator from OperatorHub using InstallPlan approval '$approval'."
fi
else
ANSIBLE_OPTS="${ANSIBLE_OPTS} -e gpu_operator_operatorhub_version=$1"
echo "Deploying the GPU Operator from OperatorHub using version '$1'."
if [[ "$#" == 2 ]]; then
ANSIBLE_OPTS="${ANSIBLE_OPTS} -e gpu_operator_operatorhub_channel=$2"
echo "Deploying the GPU Operator from OperatorHub using channel '$2'."
shift
if [[ "$#" -ge 1 && "$1" != "-"* ]]; then
ANSIBLE_OPTS="${ANSIBLE_OPTS} -e gpu_operator_operatorhub_channel=$1"
echo "Deploying the GPU Operator from OperatorHub using channel '$1'."
shift
fi
if [[ "$#" -ge 1 ]]; then
if [[ "$1" != "$INSTALL_PLAN"* ]]; then
echo "FATAL: unknown flag: $1"
usage
exit 1
fi

approval=$(echo $1 | cut -d= -f2)
if [[ "$approval" != "Manual" && "$approval" != "Automatic" ]]; then
echo "FATAL: invalid value for $1. Must be Manual or Automatic."
usage
exit 1
fi
ANSIBLE_OPTS="${ANSIBLE_OPTS} -e gpu_operator_installplan_approval=$approval"
echo "Deploying the GPU Operator from OperatorHub using InstallPlan approval '$approval'."
fi
else
echo "FATAL: unexpected number of paramters (got '$@')"
usage
exit 1
fi

exec ansible-playbook ${ANSIBLE_OPTS} playbooks/gpu_operator_deploy_from_operatorhub.yml

0 comments on commit e0bb763

Please sign in to comment.