From 9fb741c35004682767d8aeda608eefb950df2007 Mon Sep 17 00:00:00 2001 From: Sebastian Sch Date: Mon, 29 Jul 2024 17:23:19 +0300 Subject: [PATCH] Fix virtual cluster redeploy script create a common helm deploy script to use Signed-off-by: Sebastian Sch --- hack/deploy-operator-helm.sh | 38 +++++++++++++++++++++ hack/run-e2e-conformance-virtual-cluster.sh | 32 ++--------------- hack/virtual-cluster-redeploy.sh | 17 ++++++--- 3 files changed, 52 insertions(+), 35 deletions(-) create mode 100755 hack/deploy-operator-helm.sh diff --git a/hack/deploy-operator-helm.sh b/hack/deploy-operator-helm.sh new file mode 100755 index 000000000..9a5e20a1a --- /dev/null +++ b/hack/deploy-operator-helm.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +set -xeo pipefail + +HOME="/root" +here="$(dirname "$(readlink --canonicalize "${BASH_SOURCE[0]}")")" +root="$(readlink --canonicalize "$here/..")" +domain_name=lab + +source hack/env.sh + +export ADMISSION_CONTROLLERS_ENABLED=true +export ADMISSION_CONTROLLERS_CERTIFICATES_CERT_MANAGER_ENABLED=true +export OPERATOR_LEADER_ELECTION_ENABLE=true +export SKIP_VAR_SET="" +export NAMESPACE="sriov-network-operator" +export OPERATOR_NAMESPACE="sriov-network-operator" +export CNI_BIN_PATH=/opt/cni/bin +export OPERATOR_EXEC=kubectl +export CLUSTER_HAS_EMULATED_PF=TRUE + +HELM_MODE=${HELM_MODE:-install} + +HELM_VALUES_OPTS="\ + --set images.operator=${SRIOV_NETWORK_OPERATOR_IMAGE} \ + --set images.sriovConfigDaemon=${SRIOV_NETWORK_CONFIG_DAEMON_IMAGE} \ + --set images.sriovCni=${SRIOV_CNI_IMAGE} \ + --set images.sriovDevicePlugin=${SRIOV_DEVICE_PLUGIN_IMAGE} \ + --set images.resourcesInjector=${NETWORK_RESOURCES_INJECTOR_IMAGE} \ + --set images.webhook=${SRIOV_NETWORK_WEBHOOK_IMAGE} \ + --set operator.admissionControllers.enabled=${ADMISSION_CONTROLLERS_ENABLED} \ + --set operator.admissionControllers.certificates.certManager.enabled=${ADMISSION_CONTROLLERS_CERTIFICATES_CERT_MANAGER_ENABLED} \ + --set sriovOperatorConfig.deploy=true" + +PATH=$PATH:${root}/bin +make helm +helm ${HELM_MODE} -n ${NAMESPACE} --create-namespace \ + $HELM_VALUES_OPTS \ + --wait sriov-network-operator ./deployment/sriov-network-operator-chart \ No newline at end of file diff --git a/hack/run-e2e-conformance-virtual-cluster.sh b/hack/run-e2e-conformance-virtual-cluster.sh index 8dbf51593..fbbc63c98 100755 --- a/hack/run-e2e-conformance-virtual-cluster.sh +++ b/hack/run-e2e-conformance-virtual-cluster.sh @@ -364,36 +364,8 @@ do ATTEMPTS=$((ATTEMPTS+1)) done - -source hack/env.sh - -export ADMISSION_CONTROLLERS_ENABLED=true -export ADMISSION_CONTROLLERS_CERTIFICATES_CERT_MANAGER_ENABLED=true -export SKIP_VAR_SET="" -export NAMESPACE="sriov-network-operator" -export OPERATOR_NAMESPACE="sriov-network-operator" -export CNI_BIN_PATH=/opt/cni/bin -export OPERATOR_EXEC=kubectl -export CLUSTER_HAS_EMULATED_PF=TRUE - - -HELM_VALUES_OPTS="\ - --set images.operator=${SRIOV_NETWORK_OPERATOR_IMAGE} \ - --set images.sriovConfigDaemon=${SRIOV_NETWORK_CONFIG_DAEMON_IMAGE} \ - --set images.sriovCni=${SRIOV_CNI_IMAGE} \ - --set images.sriovDevicePlugin=${SRIOV_DEVICE_PLUGIN_IMAGE} \ - --set images.resourcesInjector=${NETWORK_RESOURCES_INJECTOR_IMAGE} \ - --set images.webhook=${SRIOV_NETWORK_WEBHOOK_IMAGE} \ - --set operator.admissionControllers.enabled=${ADMISSION_CONTROLLERS_ENABLED} \ - --set operator.admissionControllers.certificates.certManager.enabled=${ADMISSION_CONTROLLERS_CERTIFICATES_CERT_MANAGER_ENABLED} \ - --set sriovOperatorConfig.deploy=true" - -PATH=$PATH:${root}/bin -make helm -helm install -n ${NAMESPACE} --create-namespace \ - $HELM_VALUES_OPTS \ - --wait sriov-network-operator ./deployment/sriov-network-operator-chart - +# Deploy the sriov operator via helm +hack/deploy-operator-helm.sh echo "## create certificates for webhook" cat < registry-login.conf internal_registry="image-registry.openshift-image-registry.svc:5000" - pass=$( jq .\"$internal_registry\".password registry-login.conf ) + pass=$( jq .\"image-registry.openshift-image-registry.svc:5000\".auth registry-login.conf ) + pass=`echo ${pass:1:-1} | base64 -d` + + # dockercfg password is in the form `:password`. We need to trim the `:` prefix + pass=${pass#":"} registry="default-route-openshift-image-registry.apps.${cluster_name}.${domain_name}" - podman login -u serviceaccount -p ${pass:1:-1} $registry --tls-verify=false + podman login -u serviceaccount -p ${pass} $registry --tls-verify=false export SRIOV_NETWORK_OPERATOR_IMAGE="$registry/$NAMESPACE/sriov-network-operator:latest" export SRIOV_NETWORK_CONFIG_DAEMON_IMAGE="$registry/$NAMESPACE/sriov-network-config-daemon:latest" @@ -44,6 +48,7 @@ else fi export ADMISSION_CONTROLLERS_ENABLED=true +export OPERATOR_LEADER_ELECTION_ENABLE=true export SKIP_VAR_SET="" export OPERATOR_NAMESPACE=$NAMESPACE export OPERATOR_EXEC=kubectl @@ -67,9 +72,11 @@ if [ $CLUSTER_TYPE == "openshift" ]; then export SRIOV_NETWORK_OPERATOR_IMAGE="image-registry.openshift-image-registry.svc:5000/$NAMESPACE/sriov-network-operator:latest" export SRIOV_NETWORK_CONFIG_DAEMON_IMAGE="image-registry.openshift-image-registry.svc:5000/$NAMESPACE/sriov-network-config-daemon:latest" export SRIOV_NETWORK_WEBHOOK_IMAGE="image-registry.openshift-image-registry.svc:5000/$NAMESPACE/sriov-network-operator-webhook:latest" + echo "## deploying SRIOV Network Operator" + hack/deploy-setup.sh $NAMESPACE +else + export HELM_MODE=upgrade + hack/deploy-operator-helm.sh fi -echo "## deploying SRIOV Network Operator" -hack/deploy-setup.sh $NAMESPACE - kubectl -n ${NAMESPACE} delete po --all