Skip to content

Commit b75435e

Browse files
committed
👻 Add hack/setup-*.sh scripts for convince
Helpful scripts to: 1. Setup a minikube instance with plugins and OLM 2. Setup the operator and create a Tackle instance Both scripts are based on the operator's hack scripts of similar names but modified to install the dev version without building anything locally first. Signed-off-by: Scott J Dickerson <[email protected]>
1 parent d929226 commit b75435e

File tree

2 files changed

+162
-0
lines changed

2 files changed

+162
-0
lines changed

hack/setup-minikube.sh

Whitespace-only changes.

hack/setup-operator.sh

+162
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
#!/bin/bash
2+
#
3+
# Based on:
4+
# - https://github.com/konveyor/operator/blob/main/hack/install-konveyor.sh
5+
# - https://github.com/konveyor/operator/blob/main/hack/install-tackle.sh
6+
# - https://konveyor.github.io/konveyor/installation/#installing-konveyor-operator
7+
#
8+
# By default, no authentication, and only use pre-built images
9+
#
10+
set -e
11+
set -oq pipefail
12+
13+
# use kubectl if available, else fall back to `minikube kubectl --`, else error
14+
KUBECTL=kubectl
15+
if ! command -v $KUBECTL >/dev/null 2>&1; then
16+
KUBECTL="minikube kubectl --"
17+
# kubectl_bin="${__bin_dir}/kubectl"
18+
# mkdir -p "${__bin_dir}"
19+
# curl -Lo "${kubectl_bin}" "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/${__os}/${__arch}/kubectl"
20+
# chmod +x "${kubectl_bin}"
21+
fi
22+
echo "kubectl command: ${KUBECTL}"
23+
24+
debug() {
25+
echo "Install Konveyor FAILED!!!"
26+
echo "What follows is some info that may be useful in debugging the failure"
27+
28+
$KUBECTL get namespace "${NAMESPACE}" -o yaml || true
29+
$KUBECTL get --namespace "${NAMESPACE}" all || true
30+
$KUBECTL get --namespace "${NAMESPACE}" -o yaml \
31+
subscriptions.operators.coreos.com,catalogsources.operators.coreos.com,installplans.operators.coreos.com,clusterserviceversions.operators.coreos.com \
32+
|| true
33+
$KUBECTL get --namespace "${NAMESPACE}" -o yaml tackles.tackle.konveyor.io/tackle || true
34+
35+
for pod in $($KUBECTL get pods -n "${NAMESPACE}" -o jsonpath='{.items[*].metadata.name}'); do
36+
$KUBECTL --namespace "${NAMESPACE}" describe pod "${pod}" || true
37+
done
38+
exit 1
39+
}
40+
trap 'debug' ERR
41+
42+
# Inputs for setting up the operator
43+
NAMESPACE="${NAMESPACE:-konveyor-tackle}"
44+
OPERATOR_INDEX_IMAGE="${OPERATOR_INDEX_IMAGE:-quay.io/konveyor/tackle2-operator-index:latest}"
45+
46+
# Either pass in the full Tackle CR, or specify individual bits
47+
TACKLE_CR="${TACKLE_CR:-}"
48+
49+
FEATURE_AUTH_REQUIRED="${FEATURE_AUTH_REQUIRED:-false}"
50+
HUB_IMAGE="${HUB_IMAGE:-quay.io/konveyor/tackle2-hub:latest}"
51+
UI_IMAGE="${UI_IMAGE:-quay.io/konveyor/tackle2-ui:latest}"
52+
UI_INGRESS_CLASS_NAME="${UI_INGRESS_CLASS_NAME:-nginx}"
53+
ADDON_ANALYZER_IMAGE="${ADDON_ANALYZER_IMAGE:-quay.io/konveyor/tackle2-addon-analyzer:latest}"
54+
IMAGE_PULL_POLICY="${IMAGE_PULL_POLICY:-Always}"
55+
ANALYZER_CONTAINER_REQUESTS_MEMORY="${ANALYZER_CONTAINER_REQUESTS_MEMORY:-0}"
56+
ANALYZER_CONTAINER_REQUESTS_CPU="${ANALYZER_CONTAINER_REQUESTS_CPU:-0}"
57+
58+
install_operator() {
59+
# Create the Konveyor Namespace
60+
$KUBECTL auth can-i create namespace --all-namespaces
61+
$KUBECTL create namespace ${NAMESPACE} || true
62+
63+
# Install the Konveyor CatalogSource, OperatorGroup, and Subscription
64+
cat <<EOF | $KUBECTL apply -f -
65+
---
66+
apiVersion: operators.coreos.com/v1alpha1
67+
kind: CatalogSource
68+
metadata:
69+
name: konveyor
70+
namespace: ${NAMESPACE}
71+
spec:
72+
displayName: Konveyor Operator
73+
publisher: Konveyor
74+
sourceType: grpc
75+
image: ${OPERATOR_INDEX_IMAGE}
76+
---
77+
apiVersion: operators.coreos.com/v1
78+
kind: OperatorGroup
79+
metadata:
80+
name: konveyor
81+
namespace: ${NAMESPACE}
82+
spec:
83+
targetNamespaces:
84+
- ${NAMESPACE}
85+
---
86+
apiVersion: operators.coreos.com/v1alpha1
87+
kind: Subscription
88+
metadata:
89+
name: konveyor-operator
90+
namespace: ${NAMESPACE}
91+
spec:
92+
channel: development
93+
installPlanApproval: Automatic
94+
name: konveyor-operator
95+
source: konveyor
96+
sourceNamespace: ${NAMESPACE}
97+
EOF
98+
99+
# If on MacOS, need to install `brew install coreutils` to get `timeout`
100+
timeout 600s bash -c "until $KUBECTL get customresourcedefinitions.apiextensions.k8s.io tackles.tackle.konveyor.io; do sleep 30; done" \
101+
|| $KUBECTL get subscription --namespace ${NAMESPACE} -o yaml konveyor-operator # Print subscription details when timed out
102+
103+
# $KUBECTL wait \
104+
# --namespace ${NAMESPACE} \
105+
# --for=condition=established \
106+
# customresourcedefinitions.apiextensions.k8s.io/tackles.tackle.konveyor.io
107+
}
108+
109+
install_tackle() {
110+
echo "Waiting for the Tackle CRD to become available"
111+
$KUBECTL wait \
112+
--namespace "${NAMESPACE}" \
113+
--for=condition=established \
114+
customresourcedefinitions.apiextensions.k8s.io/tackles.tackle.konveyor.io
115+
116+
echo "Waiting for the Tackle Operator to exist"
117+
timeout 2m bash -c "until $KUBECTL --namespace ${NAMESPACE} get deployment/tackle-operator; do sleep 10; done"
118+
119+
echo "Waiting for the Tackle Operator to become available"
120+
$KUBECTL rollout status --namespace "${NAMESPACE}" -w deployment/tackle-operator --timeout=600s
121+
122+
if [ -n "${TACKLE_CR}" ]; then
123+
echo "${TACKLE_CR}" | $KUBECTL apply --namespace "${NAMESPACE}" -f -
124+
else
125+
cat <<EOF | $KUBECTL apply --namespace "${NAMESPACE}" -f -
126+
kind: Tackle
127+
apiVersion: tackle.konveyor.io/v1alpha1
128+
metadata:
129+
name: tackle
130+
spec:
131+
feature_auth_required: ${FEATURE_AUTH_REQUIRED}
132+
hub_image_fqin: ${HUB_IMAGE}
133+
ui_image_fqin: ${UI_IMAGE}
134+
ui_ingress_class_name: ${UI_INGRESS_CLASS_NAME}
135+
analyzer_fqin: ${ADDON_ANALYZER_IMAGE}
136+
image_pull_policy: ${IMAGE_PULL_POLICY}
137+
analyzer_container_requests_memory: ${ANALYZER_CONTAINER_REQUESTS_MEMORY}
138+
analyzer_container_requests_cpu: ${ANALYZER_CONTAINER_REQUESTS_CPU}
139+
EOF
140+
fi
141+
142+
# Want to see in github logs what we just created
143+
$KUBECTL get --namespace "${NAMESPACE}" -o yaml tackles.tackle.konveyor.io/tackle
144+
145+
# Wait for reconcile to finish
146+
$KUBECTL wait \
147+
--namespace "${NAMESPACE}" \
148+
--for=condition=Successful \
149+
--timeout=600s \
150+
tackles.tackle.konveyor.io/tackle
151+
152+
# Now wait for all the tackle deployments
153+
$KUBECTL wait \
154+
--namespace "${NAMESPACE}" \
155+
--selector="app.kubernetes.io/part-of=tackle" \
156+
--for=condition=Available \
157+
--timeout=600s \
158+
deployments.apps
159+
}
160+
161+
$KUBECTL get customresourcedefinitions.apiextensions.k8s.io tackles.tackle.konveyor.io || install_operator
162+
install_tackle

0 commit comments

Comments
 (0)