Skip to content

Commit

Permalink
🌱 gate PRs to main (minio#256)
Browse files Browse the repository at this point in the history
Update the install-tackle script to handle installing the konveyor
operator using OLM via provided bundle image. With this, we should be
able to test...at a minimum ... that our operator installs as part of PR
checks.

Fixes minio#130

Signed-off-by: David Zager <david.j.zager@gmail.com>
  • Loading branch information
djzager authored Aug 15, 2023
1 parent 3ca20e5 commit e3ec193
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 122 deletions.
45 changes: 20 additions & 25 deletions .github/actions/install-tackle/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,58 @@ name: Install tackle operator
description: |
Install Tackle Operator.
inputs:
tackle-operator-index-image:
description: "image url for operator index"
operator-bundle-image:
description: "image url for operator bundle container image"
required: false
default: "quay.io/konveyor/tackle2-operator-index:latest"
tackle-hub-image:
default: "quay.io/konveyor/tackle2-operator-bundle:latest"
hub-image:
description: "image url for tackle-hub"
required: false
default: "quay.io/konveyor/tackle2-hub:latest"
tackle-pathfinder-image:
pathfinder-image:
description: "image url for pathfinder image"
required: false
default: "quay.io/konveyor/tackle-pathfinder:1.3.0-native"
tackle-ui-image:
ui-image:
description: "image url for tackle-ui"
required: false
default: "quay.io/konveyor/tackle2-ui:latest"
tackle-addon-admin-image:
addon-admin-image:
description: "image urd for admin addon"
required: false
default: "quay.io/konveyor/tackle2-addon:latest"
tackle-addon-analyzer-image:
addon-analyzer-image:
description: "image url for analyzer addon"
required: false
default: "quay.io/konveyor/tackle2-addon-analyzer:latest"
tackle-image-pull-policy:
image-pull-policy:
description: "Image Pull Policy"
required: false
default: "Always"
tackle-analyzer-container-cpu:
analyzer-container-cpu:
description: "The CPU request value for the analyzer task containers"
required: false
default: 0
tackle-analyzer-container-memory:
analyzer-container-memory:
description: "The memory request value for the analyzer task containers"
required: false
default: 0
# TODO(djzager): uncomment when supported
# tackle-operator-container-image:
# description: "image url for operator container"
# required: false
# default: "quay.io/konveyor/tackle2-operator:latest"
runs:
using: "composite"
steps:
# TODO(djzager): Need to figure out overriding operator image
# or maybe just installing manager via kustomize.
- name: Install tackle
run: |
export TACKLE_OPERATOR_INDEX_IMAGE="${{ inputs.tackle-operator-index-image }}"
export TACKLE_HUB_IMAGE="${{ inputs.tackle-hub-image }}"
export TACKLE_PATHFINDER_IMAGE="${{ inputs.tackle-pathfinder-image }}"
export TACKLE_UI_IMAGE="${{ inputs.tackle-ui-image }}"
export TACKLE_ADDON_ADMIN_IMAGE="${{ inputs.tackle-addon-admin-image }}"
export TACKLE_ADDON_ANALYZER_IMAGE="${{ inputs.tackle-addon-analyzer-image }}"
export TACKLE_IMAGE_PULL_POLICY="${{ inputs.tackle-image-pull-policy }}"
export TACKLE_ANALYZER_CONTAINER_REQUESTS_MEMORY="${{ inputs.tackle-analyzer-container-memory }}"
export TACKLE_ANALYZER_CONTAINER_REQUESTS_CPU="${{ inputs.tackle-analyzer-container-cpu }}"
export OPERATOR_BUNDLE_IMAGE="${{ inputs.operator-bundle-image }}"
export HUB_IMAGE="${{ inputs.hub-image }}"
export PATHFINDER_IMAGE="${{ inputs.pathfinder-image }}"
export UI_IMAGE="${{ inputs.ui-image }}"
export ADDON_ADMIN_IMAGE="${{ inputs.addon-admin-image }}"
export ADDON_ANALYZER_IMAGE="${{ inputs.addon-analyzer-image }}"
export IMAGE_PULL_POLICY="${{ inputs.image-pull-policy }}"
export ANALYZER_CONTAINER_REQUESTS_MEMORY="${{ inputs.analyzer-container-memory }}"
export ANALYZER_CONTAINER_REQUESTS_CPU="${{ inputs.analyzer-container-cpu }}"
make install-tackle
working-directory: ${{ github.action_path }}/../../..
shell: bash
39 changes: 39 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: PR Checks

on:
pull_request:
branches:
- main
- 'release-*.*'

env:
IMG: ttl.sh/konveyor-operator-${{ github.sha }}:1h
BUNDLE_IMG: ttl.sh/konveyor-operator-bundle-${{ github.sha }}:1h

jobs:
check-title:
runs-on: ubuntu-latest
steps:
- uses: konveyor/release-tools/cmd/verify-pr@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}

build-operator:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: make docker-build docker-push

build-bundle:
needs: build-operator
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: make bundle bundle-build bundle-push

operator-install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: make start-minikube
- run: OPERATOR_BUNDLE_IMAGE="${BUNDLE_IMG}" make install-tackle
18 changes: 0 additions & 18 deletions .github/workflows/verifyPR.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ catalog-push: ## Push a catalog image.

.PHONY: start-minikube
start-minikube:
export PATH=$(shell pwd)/bin:$$PATH; $(shell pwd)/hack/start-minikube.sh
$(shell pwd)/hack/start-minikube.sh

.PHONY: install-tackle
install-tackle:
export PATH=$(shell pwd)/bin:$$PATH; $(shell pwd)/hack/install-tackle.sh
$(shell pwd)/hack/install-tackle.sh
140 changes: 63 additions & 77 deletions hack/install-tackle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,119 +3,105 @@
set -e
set -x

TACKLE_OPERATOR_INDEX_IMAGE="${TACKLE_OPERATOR_INDEX_IMAGE:-quay.io/konveyor/tackle2-operator-index:latest}"
TACKLE_HUB_IMAGE="${TACKLE_HUB_IMAGE:-quay.io/konveyor/tackle2-hub:latest}"
TACKLE_PATHFINDER_IMAGE="${TACKLE_PATHFINDER_IMAGE:-quay.io/konveyor/tackle-pathfinder:1.3.0-native}"
TACKLE_UI_IMAGE="${TACKLE_UI_IMAGE:-quay.io/konveyor/tackle2-ui:latest}"
TACKLE_UI_INGRESS_CLASS_NAME="${TACKLE_UI_INGRESS_CLASS_NAME:-nginx}"
TACKLE_ADDON_ADMIN_IMAGE="${TACKLE_ADDON_ADMIN_IMAGE:-quay.io/konveyor/tackle2-addon:latest}"
TACKLE_ADDON_ANALYZER_IMAGE="${TACKLE_ADDON_ANALYZER_IMAGE:-quay.io/konveyor/tackle2-addon-analyzer:latest}"
TACKLE_IMAGE_PULL_POLICY="${TACKLE_IMAGE_PULL_POLICY:-Always}"
TACKLE_ANALYZER_CONTAINER_REQUESTS_MEMORY="${TACKLE_ANALYZER_CONTAINER_REQUESTS_MEMORY:-0}"
TACKLE_ANALYZER_CONTAINER_REQUESTS_CPU="${TACKLE_ANALYZER_CONTAINER_REQUESTS_CPU:-0}"
# Figure out where we are being run from.
# This relies on script being run from:
# - ${PROJECT_ROOT}/hack/install-tackle.sh
# - ${PROJECT_ROOT}/bin/install-tackle.sh
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__root="$(cd "$(dirname "${__dir}")" && pwd)"
__repo="$(basename "${__root}")"
__bin_dir="${__root}/bin"
__os="$(uname -s | tr '[:upper:]' '[:lower:]')"
__arch="$(uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')"

TACKLE_FEATURE_AUTH_REQUIRED="${TACKLE_FEATURE_AUTH_REQUIRED:-false}"
# Update PATH for execution of this script
export PATH="${__bin_dir}:${PATH}"

NAMESPACE="${NAMESPACE:-konveyor-tackle}"
OPERATOR_BUNDLE_IMAGE="${OPERATOR_BUNDLE_IMAGE:-quay.io/konveyor/tackle2-operator-bundle:latest}"
HUB_IMAGE="${HUB_IMAGE:-quay.io/konveyor/tackle2-hub:latest}"
PATHFINDER_IMAGE="${PATHFINDER_IMAGE:-quay.io/konveyor/tackle-pathfinder:1.3.0-native}"
UI_IMAGE="${UI_IMAGE:-quay.io/konveyor/tackle2-ui:latest}"
UI_INGRESS_CLASS_NAME="${UI_INGRESS_CLASS_NAME:-nginx}"
ADDON_ADMIN_IMAGE="${ADDON_ADMIN_IMAGE:-quay.io/konveyor/tackle2-addon:latest}"
ADDON_ANALYZER_IMAGE="${ADDON_ANALYZER_IMAGE:-quay.io/konveyor/tackle2-addon-analyzer:latest}"
IMAGE_PULL_POLICY="${IMAGE_PULL_POLICY:-Always}"
ANALYZER_CONTAINER_REQUESTS_MEMORY="${ANALYZER_CONTAINER_REQUESTS_MEMORY:-0}"
ANALYZER_CONTAINER_REQUESTS_CPU="${ANALYZER_CONTAINER_REQUESTS_CPU:-0}"
FEATURE_AUTH_REQUIRED="${FEATURE_AUTH_REQUIRED:-false}"

if ! command -v kubectl >/dev/null 2>&1; then
echo "Please install kubectl"
exit 1
kubectl_bin="${__bin_dir}/kubectl"
mkdir -p "${__bin_dir}"
curl -Lo "${kubectl_bin}" "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/${__os}/${__arch}/kubectl"
chmod +x "${kubectl_bin}"
fi

# Create namespace
cat << EOF | kubectl apply -f -
apiVersion: v1
kind: Namespace
metadata:
name: konveyor-tackle
EOF
if ! command -v operator-sdk1 >/dev/null 2>&1; then
operator_sdk_bin="${__bin_dir}/operator-sdk"
mkdir -p "${__bin_dir}"

# Create catalogsource
cat << EOF | kubectl apply -f -
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
name: konveyor-tackle
namespace: konveyor-tackle
spec:
displayName: Konveyor Operator
publisher: Konveyor
sourceType: grpc
image: ${TACKLE_OPERATOR_INDEX_IMAGE}
EOF
version=$(curl --silent "https://api.github.com/repos/operator-framework/operator-sdk/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
curl -Lo "${operator_sdk_bin}" "https://github.com/operator-framework/operator-sdk/releases/download/${version}/operator-sdk_${__os}_${__arch}"
chmod +x "${operator_sdk_bin}"
fi

# Create operatorgroup
cat << EOF | kubectl apply -f -
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: konveyor-tackle
namespace: konveyor-tackle
spec:
targetNamespaces:
- konveyor-tackle
EOF
install_operator() {
kubectl auth can-i create namespace --all-namespaces
kubectl create namespace ${NAMESPACE} || true
operator-sdk run bundle ${OPERATOR_BUNDLE_IMAGE} --namespace ${NAMESPACE}

# If on MacOS, need to install `brew install coreutils` to get `timeout`
timeout 600s bash -c 'until kubectl get customresourcedefinitions.apiextensions.k8s.io tackles.tackle.konveyor.io; do sleep 30; done' \
|| kubectl get subscription --namespace ${NAMESPACE} -o yaml konveyor-operator # Print subscription details when timed out
}

kubectl get customresourcedefinitions.apiextensions.k8s.io tackles.tackle.konveyor.io || install_operator

# Create, and wait for, subscription
cat << EOF | kubectl apply -f -
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: konveyor-operator
namespace: konveyor-tackle
spec:
channel: development
installPlanApproval: Automatic
name: konveyor-operator
source: konveyor-tackle
sourceNamespace: konveyor-tackle
EOF
# If on MacOS, need to install `brew install coreutils` to get `timeout`
timeout 600s bash -c 'until kubectl get customresourcedefinitions.apiextensions.k8s.io tackles.tackle.konveyor.io; do sleep 30; done' \
|| kubectl get subscription --namespace konveyor-tackle -o yaml konveyor-operator # Print subscription details when timed out

# Create, and wait for, tackle
kubectl wait \
--namespace konveyor-tackle \
--namespace ${NAMESPACE} \
--for=condition=established \
customresourcedefinitions.apiextensions.k8s.io/tackles.tackle.konveyor.io
cat <<EOF | kubectl apply -f -
kind: Tackle
apiVersion: tackle.konveyor.io/v1alpha1
metadata:
name: tackle
namespace: konveyor-tackle
namespace: ${NAMESPACE}
spec:
feature_auth_required: ${TACKLE_FEATURE_AUTH_REQUIRED}
hub_image_fqin: ${TACKLE_HUB_IMAGE}
pathfinder_image_fqin: ${TACKLE_PATHFINDER_IMAGE}
ui_image_fqin: ${TACKLE_UI_IMAGE}
ui_ingress_class_name: ${TACKLE_UI_INGRESS_CLASS_NAME}
admin_fqin: ${TACKLE_ADDON_ADMIN_IMAGE}
analyzer_fqin: ${TACKLE_ADDON_ANALYZER_IMAGE}
image_pull_policy: ${TACKLE_IMAGE_PULL_POLICY}
analyzer_container_requests_memory: ${TACKLE_ANALYZER_CONTAINER_REQUESTS_MEMORY}
analyzer_container_requests_cpu: ${TACKLE_ANALYZER_CONTAINER_REQUESTS_CPU}
feature_auth_required: ${FEATURE_AUTH_REQUIRED}
hub_image_fqin: ${HUB_IMAGE}
pathfinder_image_fqin: ${PATHFINDER_IMAGE}
ui_image_fqin: ${UI_IMAGE}
ui_ingress_class_name: ${UI_INGRESS_CLASS_NAME}
admin_fqin: ${ADDON_ADMIN_IMAGE}
analyzer_fqin: ${ADDON_ANALYZER_IMAGE}
image_pull_policy: ${IMAGE_PULL_POLICY}
analyzer_container_requests_memory: ${ANALYZER_CONTAINER_REQUESTS_MEMORY}
analyzer_container_requests_cpu: ${ANALYZER_CONTAINER_REQUESTS_CPU}
EOF
# Wait for reconcile to finish
kubectl wait \
--namespace konveyor-tackle \
--namespace ${NAMESPACE} \
--for=condition=Successful \
--timeout=600s \
tackles.tackle.konveyor.io/tackle \
|| kubectl get \
--namespace konveyor-tackle \
--namespace ${NAMESPACE} \
-o yaml \
tackles.tackle.konveyor.io/tackle # Print tackle debug when timed out

# Now wait for all the tackle deployments
kubectl wait \
--namespace konveyor-tackle \
--namespace ${NAMESPACE} \
--selector="app.kubernetes.io/part-of=tackle" \
--for=condition=Available \
--timeout=600s \
deployments.apps \
|| kubectl get \
--namespace konveyor-tackle \
--namespace ${NAMESPACE} \
--selector="app.kubernetes.io/part-of=tackle" \
--field-selector=status.phase!=Running \
-o yaml \
Expand Down

0 comments on commit e3ec193

Please sign in to comment.