github.com/k8snetworkplumbingwg/sriov-network-operator@v1.2.1-0.20240408194816-2d2e5a45d453/hack/deploy-setup.sh (about)

     1  #!/bin/bash
     2  # This script inits a cluster to allow sriov-network-operator
     3  # to deploy.  It assumes it is capable of login as a
     4  # user who has the cluster-admin role
     5  
     6  # set -euxo pipefail
     7  
     8  source "$(dirname $0)/common"
     9  
    10  load_manifest() {
    11    local repo=$1
    12    local namespace=${2:-}
    13    export NAMESPACE=${namespace}
    14    if [ -n "${namespace}" ] ; then
    15      namespace="-n ${namespace}"
    16    fi
    17  
    18    pushd ${repo}/deploy
    19      if ! ${OPERATOR_EXEC} get ns $2 > /dev/null 2>&1 && test -f namespace.yaml ; then
    20        
    21        envsubst< namespace.yaml | ${OPERATOR_EXEC} apply -f -
    22      fi
    23      files="service_account.yaml role.yaml role_binding.yaml clusterrole.yaml clusterrolebinding.yaml configmap.yaml sriovoperatorconfig.yaml operator.yaml"
    24      for m in ${files}; do
    25        if [ "$(echo ${EXCLUSIONS[@]} | grep -o ${m} | wc -w | xargs)" == "0" ] ; then
    26          envsubst< ${m} | ${OPERATOR_EXEC} apply ${namespace:-} --validate=false -f -
    27        fi
    28      done
    29  
    30    popd
    31  }
    32  
    33  # This is required for when running the operator locally using go run
    34  rm -rf /tmp/_working_dir
    35  mkdir /tmp/_working_dir
    36  source hack/env.sh
    37  
    38  load_manifest ${repo_dir} $1