Skip to content

Commit

Permalink
feat: deploy and functest make tasks
Browse files Browse the repository at this point in the history
This tasks are helpful when working wieh an external Kubernetes
cluster.

The 'deploy' task installs the bundles and their dependencies,
while the 'functest' task runs the function tests against the
cluster.

Signed-off-by: Nestor Acuna-Blanco <nestor.acuna@ibm.com>
  • Loading branch information
nestoracunablanco committed Jul 12, 2024
1 parent ac633f2 commit 6634e73
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
2 changes: 2 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ The following targets are provided by the `Makefile`
* `make kubeconform`: Install vendored `kubeconform` from `./tools` into `./_bin`.
* `make yq`: Install vendored `yq` from `./tools` into `./_bin`.
* `make golangci-lint`: Install `golangci-lint` version specified in `Makefile` into `./_bin`.
* `make deploy`: Deploy `common-instancetypes` to an external cluster.
* `make functest`: Run functest against an external cluster.

## Running Makefile targets within a container

Expand Down
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ YQ_PACKAGE ?= github.com/mikefarah/yq/v4
# Version of golangci-lint to install
GOLANGCI_LINT_VERSION ?= v1.55.2

# Kubeconfig default value
KUBECONFIG ?= ~/.kube/config

.PHONY: all
all: lint validate readme test-lint test

Expand All @@ -41,6 +44,14 @@ lint: generate
generate: kustomize yq
scripts/generate.sh

.PHONY: deploy
deploy: generate
scripts/deploy-kubevirt-and-cdi.sh && KUBECTL=kubectl scripts/sync.sh

.PHONY: functest
functest:
cd tests && KUBECONFIG=$(KUBECONFIG) go test -v -timeout 0 ./functests/... -ginkgo.v -ginkgo.randomize-all $(FUNCTEST_EXTRA_ARGS)

.PHONY: validate
validate: generate schema kubeconform
scripts/validate.sh
Expand Down
41 changes: 41 additions & 0 deletions scripts/deploy-kubevirt-and-cdi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
set -e

function latest_version() {
local repo="$1"
curl -s https://api.github.com/repos/kubevirt/${repo}/releases/latest | \
grep '"tag_name":' | \
sed -E 's/.*"([^"]+)".*/\1/'
}


# Deploying kubevirt
KUBEVIRT_VERSION=$(curl -L https://storage.googleapis.com/kubevirt-prow/devel/release/kubevirt/kubevirt/stable.txt)
KUBEVIRT_NAMESPACE=${1:-kubevirt}

kubectl apply -n ${KUBEVIRT_NAMESPACE} -f "https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_VERSION}/kubevirt-operator.yaml"
kubectl apply -n ${KUBEVIRT_NAMESPACE} -f "https://github.com/kubevirt/kubevirt/releases/download/${KUBEVIRT_VERSION}/kubevirt-cr.yaml"

kubectl patch -n ${KUBEVIRT_NAMESPACE} kubevirt kubevirt --type='json' -p '[{
"op": "add",
"path": "/spec/configuration/developerConfiguration/featureGates/-",
"value": "NUMA",
},{
"op": "add",
"path": "/spec/configuration/developerConfiguration/featureGates/-",
"value": "GPU",
}]'

echo "Waiting for Kubevirt to be ready..."
kubectl wait --for=condition=Available --timeout=600s -n ${KUBEVIRT_NAMESPACE} kv/kubevirt


# Deploying CDI
CDI_VERSION=$(latest_version "containerized-data-importer")
CDI_NAMESPACE=cdi

kubectl apply -n ${CDI_NAMESPACE} -f "https://github.com/kubevirt/containerized-data-importer/releases/download/${CDI_VERSION}/cdi-operator.yaml"
kubectl apply -n ${CDI_NAMESPACE} -f "https://github.com/kubevirt/containerized-data-importer/releases/download/${CDI_VERSION}/cdi-cr.yaml"

echo "Waiting for CDI to be ready..."
kubectl wait --for=condition=Available --timeout=600s -n ${CDI_NAMESPACE} cdi/cdi

0 comments on commit 6634e73

Please sign in to comment.