chore: Rework test scripts (#1481)
* chore: Rework test scripts Signed-off-by: Anatolii Bazko <abazko@redhat.com>pull/1483/head
parent
eef01392b9
commit
16afae54dc
|
|
@ -16,32 +16,46 @@ export ECLIPSE_CHE_PREVIEW_PACKAGE_NAME="eclipse-che-preview-openshift"
|
|||
export ECLIPSE_CHE_CATALOG_SOURCE_NAME="eclipse-che-custom-catalog-source"
|
||||
export ECLIPSE_CHE_SUBSCRIPTION_NAME="eclipse-che-subscription"
|
||||
|
||||
waitForInstalledEclipseCheCSV() {
|
||||
unset ECLIPSE_CHE_INSTALLED_CSV
|
||||
while [[ -z ${ECLIPSE_CHE_INSTALLED_CSV} ]] || [[ ${ECLIPSE_CHE_INSTALLED_CSV} == "null" ]]; do
|
||||
sleep 5s
|
||||
discoverEclipseCheSubscription
|
||||
done
|
||||
}
|
||||
|
||||
waitForRemovedEclipseCheSubscription() {
|
||||
while [[ $(oc get subscription -A -o json | jq -r '.items | .[] | select(.spec.name == "'${ECLIPSE_CHE_PREVIEW_PACKAGE_NAME}'" or .spec.name == "'${ECLIPSE_CHE_STABLE_PACKAGE_NAME}'")') != "" ]]; do
|
||||
sleep 5s
|
||||
done
|
||||
}
|
||||
|
||||
useCustomOperatorImageInCSV() {
|
||||
local OPERATOR_IMAGE=$1
|
||||
findEclipseCheSubscription
|
||||
discoverEclipseCheSubscription
|
||||
oc patch csv ${ECLIPSE_CHE_INSTALLED_CSV} -n ${ECLIPSE_CHE_SUBSCRIPTION_NAMESPACE} --type=json -p '[{"op": "replace", "path": "/spec/install/spec/deployments/0/spec/template/spec/containers/0/image", "value": "'${OPERATOR_IMAGE}'"}]'
|
||||
}
|
||||
|
||||
getCheClusterCRFromCSV() {
|
||||
findEclipseCheSubscription
|
||||
getCheClusterCRFromInstalledCSV() {
|
||||
discoverEclipseCheSubscription
|
||||
oc get csv ${ECLIPSE_CHE_INSTALLED_CSV} -n ${ECLIPSE_CHE_SUBSCRIPTION_NAMESPACE} -o yaml | yq -r '.metadata.annotations["alm-examples"] | fromjson | .[] | select(.apiVersion == "org.eclipse.che/v2")'
|
||||
}
|
||||
|
||||
getCheVersionFromCSV() {
|
||||
findEclipseCheSubscription
|
||||
getCheVersionFromInstalledCSV() {
|
||||
discoverEclipseCheSubscription
|
||||
oc get csv ${ECLIPSE_CHE_INSTALLED_CSV} -n ${ECLIPSE_CHE_SUBSCRIPTION_NAMESPACE} -o yaml | yq -r '.spec.install.spec.deployments[0].spec.template.spec.containers[0].env[] | select(.name == "CHE_VERSION") | .value'
|
||||
}
|
||||
|
||||
findEclipseCheSubscription() {
|
||||
discoverEclipseCheSubscription() {
|
||||
ECLIPSE_CHE_SUBSCRIPTION_RECORD=$(oc get subscription -A -o json | jq -r '.items | .[] | select(.spec.name == "'${ECLIPSE_CHE_PREVIEW_PACKAGE_NAME}'" or .spec.name == "'${ECLIPSE_CHE_STABLE_PACKAGE_NAME}'")')
|
||||
ECLIPSE_CHE_SUBSCRIPTION_NAME=$(echo ${ECLIPSE_CHE_SUBSCRIPTION_RECORD} | jq -r '.metadata.name')
|
||||
ECLIPSE_CHE_SUBSCRIPTION_NAMESPACE=$(echo ${ECLIPSE_CHE_SUBSCRIPTION_RECORD} | jq -r '.metadata.namespace')
|
||||
ECLIPSE_CHE_INSTALLED_CSV=$(echo ${ECLIPSE_CHE_SUBSCRIPTION_RECORD} | jq -r '.status.installedCSV')
|
||||
}
|
||||
|
||||
getCatalogSourceBundles() {
|
||||
discoverCatalogSourceBundles() {
|
||||
local name=${1}
|
||||
local catalogService=$(kubectl get service "${name}" -n openshift-marketplace -o yaml)
|
||||
local catalogService=$(oc get service "${name}" -n openshift-marketplace -o yaml)
|
||||
local catalogIP=$(echo "${catalogService}" | yq -r ".spec.clusterIP")
|
||||
local catalogPort=$(echo "${catalogService}" | yq -r ".spec.ports[0].targetPort")
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ runTests() {
|
|||
useCustomOperatorImageInCSV "${CI_CHE_OPERATOR_IMAGE}"
|
||||
|
||||
make create-namespace NAMESPACE="eclipse-che"
|
||||
getCheClusterCRFromCSV | oc apply -n "${NAMESPACE}" -f -
|
||||
waitEclipseCheDeployed "$(getCheVersionFromCSV)"
|
||||
getCheClusterCRFromInstalledCSV | oc apply -n "${NAMESPACE}" -f -
|
||||
make wait-eclipseche-version VERSION="$(getCheVersionFromInstalledCSV)" NAMESPACE=${NAMESPACE}
|
||||
|
||||
bash <(curl -s https://raw.githubusercontent.com/eclipse/che/${CHE_REPO_BRANCH}/tests/devworkspace-happy-path/remote-launch.sh)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ runTests() {
|
|||
useCustomOperatorImageInCSV "${CI_CHE_OPERATOR_IMAGE}"
|
||||
|
||||
make create-namespace NAMESPACE="eclipse-che"
|
||||
getCheClusterCRFromCSV | oc apply -n "${NAMESPACE}" -f -
|
||||
waitEclipseCheDeployed "$(getCheVersionFromCSV)"
|
||||
getCheClusterCRFromInstalledCSV | oc apply -n "${NAMESPACE}" -f -
|
||||
make wait-eclipseche-version VERSION="$(getCheVersionFromInstalledCSV)" NAMESPACE=${NAMESPACE}
|
||||
}
|
||||
|
||||
initDefaults
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ runTests() {
|
|||
useCustomOperatorImageInCSV "${CI_CHE_OPERATOR_IMAGE}"
|
||||
|
||||
make create-namespace NAMESPACE="eclipse-che"
|
||||
getCheClusterCRFromCSV | oc apply -n "${NAMESPACE}" -f -
|
||||
waitEclipseCheDeployed "$(getCheVersionFromCSV)"
|
||||
getCheClusterCRFromInstalledCSV | oc apply -n "${NAMESPACE}" -f -
|
||||
make wait-eclipseche-version VERSION="$(getCheVersionFromInstalledCSV)" NAMESPACE=${NAMESPACE}
|
||||
}
|
||||
|
||||
initDefaults
|
||||
|
|
|
|||
|
|
@ -25,24 +25,34 @@ source "${OPERATOR_REPO}/.ci/oci-common.sh"
|
|||
#Stop execution on any error
|
||||
trap "catchFinish" EXIT SIGINT
|
||||
|
||||
# Uninstall Eclipse Che next version operator by removing subscription
|
||||
deleteEclipseCheNextSubscription() {
|
||||
findEclipseCheSubscription
|
||||
unset OPERATOR_TEST_NAMESPACE
|
||||
|
||||
# save .spec to recreate subscription later
|
||||
ECLIPSE_CHE_NEXT_SUBSCRIPTION_SPEC_SOURCE=$(oc get subscription ${ECLIPSE_CHE_SUBSCRIPTION_NAME} -n ${ECLIPSE_CHE_SUBSCRIPTION_NAMESPACE} -o "jsonpath={.spec.source}")
|
||||
ECLIPSE_CHE_NEXT_SUBSCRIPTION_SPEC_SOURCE_NAMESPACE=$(oc get subscription ${ECLIPSE_CHE_SUBSCRIPTION_NAME} -n ${ECLIPSE_CHE_SUBSCRIPTION_NAMESPACE} -o "jsonpath={.spec.sourceNamespace}")
|
||||
|
||||
oc delete csv ${ECLIPSE_CHE_INSTALLED_CSV} -n ${ECLIPSE_CHE_SUBSCRIPTION_NAMESPACE}
|
||||
oc delete subscription ${ECLIPSE_CHE_SUBSCRIPTION_NAME} -n ${ECLIPSE_CHE_SUBSCRIPTION_NAMESPACE}
|
||||
# Discover test namespace
|
||||
# Eclipse Che subscription is pre-created by OpenShift CI
|
||||
discoverOperatorTestNamespace() {
|
||||
discoverEclipseCheSubscription
|
||||
OPERATOR_TEST_NAMESPACE=${ECLIPSE_CHE_SUBSCRIPTION_NAMESPACE}
|
||||
}
|
||||
|
||||
# Install Eclipse Che next version operator by recreating subscription
|
||||
createEclipseCheNextSubscription() {
|
||||
# Delete Eclipse Che next version operator by deleting its subscription
|
||||
deleteEclipseCheNextVersionSubscription() {
|
||||
discoverEclipseCheSubscription
|
||||
|
||||
# save .spec to recreate subscription later
|
||||
ECLIPSE_CHE_NEXT_SUBSCRIPTION_SPEC_SOURCE=$(oc get subscription ${ECLIPSE_CHE_SUBSCRIPTION_NAME} -n ${OPERATOR_TEST_NAMESPACE} -o "jsonpath={.spec.source}")
|
||||
ECLIPSE_CHE_NEXT_SUBSCRIPTION_SPEC_SOURCE_NAMESPACE=$(oc get subscription ${ECLIPSE_CHE_SUBSCRIPTION_NAME} -n ${OPERATOR_TEST_NAMESPACE} -o "jsonpath={.spec.sourceNamespace}")
|
||||
|
||||
oc delete csv ${ECLIPSE_CHE_INSTALLED_CSV} -n ${OPERATOR_TEST_NAMESPACE}
|
||||
oc delete subscription ${ECLIPSE_CHE_SUBSCRIPTION_NAME} -n ${OPERATOR_TEST_NAMESPACE}
|
||||
}
|
||||
|
||||
# Install Eclipse Che next version operator by creating its subscription
|
||||
createEclipseCheNextVersionSubscription() {
|
||||
pushd "${OPERATOR_REPO}" || exit 1
|
||||
|
||||
make create-subscription \
|
||||
NAME=${ECLIPSE_CHE_SUBSCRIPTION_NAME} \
|
||||
NAMESPACE=${OPERATOR_TEST_NAMESPACE} \
|
||||
SOURCE=${ECLIPSE_CHE_NEXT_SUBSCRIPTION_SPEC_SOURCE} \
|
||||
SOURCE_NAMESPACE=${ECLIPSE_CHE_NEXT_SUBSCRIPTION_SPEC_SOURCE_NAMESPACE} \
|
||||
PACKAGE_NAME=${ECLIPSE_CHE_PREVIEW_PACKAGE_NAME} \
|
||||
|
|
@ -52,38 +62,62 @@ createEclipseCheNextSubscription() {
|
|||
popd
|
||||
}
|
||||
|
||||
# Uninstall Eclipse Che stable version operator by removing subscription
|
||||
deleteEclipseCheStableSubscription() {
|
||||
findEclipseCheSubscription
|
||||
# Install Eclipse Che stable version operator by creating its subscription
|
||||
createEclipseCheStableVersionSubscription() {
|
||||
pushd "${OPERATOR_REPO}" || exit 1
|
||||
|
||||
oc delete csv ${ECLIPSE_CHE_INSTALLED_CSV} -n ${ECLIPSE_CHE_SUBSCRIPTION_NAMESPACE}
|
||||
oc delete subscription ${ECLIPSE_CHE_SUBSCRIPTION_NAME} -n ${ECLIPSE_CHE_SUBSCRIPTION_NAMESPACE}
|
||||
make create-subscription \
|
||||
NAME=${ECLIPSE_CHE_SUBSCRIPTION_NAME} \
|
||||
NAMESPACE=${OPERATOR_TEST_NAMESPACE} \
|
||||
SOURCE="community-operators" \
|
||||
SOURCE_NAMESPACE="openshift-marketplace" \
|
||||
PACKAGE_NAME=${ECLIPSE_CHE_STABLE_PACKAGE_NAME} \
|
||||
CHANNEL="stable" \
|
||||
INSTALL_PLAN_APPROVAL="Auto"
|
||||
|
||||
popd
|
||||
}
|
||||
|
||||
# Uninstall Eclipse Che stable version operator by deleting its subscription
|
||||
deleteEclipseCheStableVersionSubscription() {
|
||||
discoverEclipseCheSubscription
|
||||
|
||||
oc delete csv ${ECLIPSE_CHE_INSTALLED_CSV} -n ${OPERATOR_TEST_NAMESPACE}
|
||||
oc delete subscription ${ECLIPSE_CHE_SUBSCRIPTION_NAME} -n ${OPERATOR_TEST_NAMESPACE}
|
||||
}
|
||||
|
||||
runTests() {
|
||||
deleteEclipseCheNextSubscription
|
||||
sleep 1m
|
||||
# Uninstall pre-created Eclipse Che next version operator (operands don't exist)
|
||||
deleteEclipseCheNextVersionSubscription
|
||||
waitForRemovedEclipseCheSubscription
|
||||
|
||||
# Deploy stable version
|
||||
chectl server:deploy --platform openshift --olm-channel stable
|
||||
createEclipseCheStableVersionSubscription
|
||||
waitForInstalledEclipseCheCSV
|
||||
getCheClusterCRFromInstalledCSV | oc apply -n "${NAMESPACE}" -f -
|
||||
|
||||
# Delete Eclipse Che stable version operator
|
||||
deleteEclipseCheStableSubscription
|
||||
sleep 1m
|
||||
pushd ${OPERATOR_REPO}
|
||||
make wait-eclipseche-version VERSION="$(getCheVersionFromInstalledCSV)" NAMESPACE=${NAMESPACE}
|
||||
popd
|
||||
|
||||
# Hack, since we completely reinstall operator by removing the deployment
|
||||
# Webhook won't be available for a while
|
||||
# Delete Eclipse Che stable version (just operator)
|
||||
deleteEclipseCheStableVersionSubscription
|
||||
waitForRemovedEclipseCheSubscription
|
||||
# Hack, since we remove operator pod, webhook won't work.
|
||||
# We have to disable it for a while.
|
||||
oc patch crd checlusters.org.eclipse.che --patch '{"spec": {"conversion": null}}' --type=merge
|
||||
|
||||
# Install Eclipse Che next version operator
|
||||
createEclipseCheNextSubscription
|
||||
sleep 1m
|
||||
|
||||
# Install Eclipse Che next version
|
||||
createEclipseCheNextVersionSubscription
|
||||
waitForInstalledEclipseCheCSV
|
||||
# CI_CHE_OPERATOR_IMAGE it is che operator image built in openshift CI job workflow.
|
||||
# More info about how works image dependencies in ci:https://github.com/openshift/ci-tools/blob/master/TEMPLATES.md#parameters-available-to-templates
|
||||
useCustomOperatorImageInCSV "${CI_CHE_OPERATOR_IMAGE}"
|
||||
waitEclipseCheDeployed "next"
|
||||
pushd ${OPERATOR_REPO}
|
||||
make wait-eclipseche-version VERSION="$(getCheVersionFromInstalledCSV)" NAMESPACE=${NAMESPACE}
|
||||
popd
|
||||
}
|
||||
|
||||
initDefaults
|
||||
discoverOperatorTestNamespace
|
||||
runTests
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
# Red Hat, Inc. - initial API and implementation
|
||||
#
|
||||
|
||||
export DEV_WORKSPACE_CATALOG_SOURCE_NAME="custom-devworkspace-operator-catalog"
|
||||
|
||||
catchFinish() {
|
||||
result=$?
|
||||
|
||||
|
|
@ -180,11 +178,9 @@ collectClusterScopeResources() {
|
|||
done
|
||||
}
|
||||
|
||||
buildCheOperatorImage() {
|
||||
docker build -t "${OPERATOR_IMAGE}" -f Dockerfile --build-arg SKIP_TESTS=true . && docker save "${OPERATOR_IMAGE}" > /tmp/operator.tar
|
||||
}
|
||||
|
||||
copyCheOperatorImageToMinikube() {
|
||||
buildAndCopyCheOperatorImageToMinikube() {
|
||||
docker build -t "${OPERATOR_IMAGE}" -f Dockerfile --build-arg SKIP_TESTS=true .
|
||||
docker save "${OPERATOR_IMAGE}" > /tmp/operator.tar
|
||||
eval $(minikube docker-env) && docker load -i /tmp/operator.tar && rm /tmp/operator.tar
|
||||
}
|
||||
|
||||
|
|
@ -215,7 +211,7 @@ deployEclipseCheWithHelm() {
|
|||
|
||||
if [[ ${customimage} == "true" ]]; then
|
||||
yq -riSY '.spec.template.spec.containers[0].image = "'${OPERATOR_IMAGE}'"' "${OPERATOR_DEPLOYMENT}"
|
||||
yq -riSY '.spec.template.spec.containers[0].imagePullPolicy = "IfNotPresent"' "${OPERATOR_DEPLOYMENT}"
|
||||
yq -riSY '.spec.template.spec.containers[0].imagePullPolicy = "Never"' "${OPERATOR_DEPLOYMENT}"
|
||||
fi
|
||||
|
||||
# Deploy Eclipse Che with Helm
|
||||
|
|
@ -230,9 +226,10 @@ deployEclipseCheWithHelm() {
|
|||
popd
|
||||
|
||||
local cheVersion=$(yq -r '.spec.template.spec.containers[0].env[] | select(.name == "CHE_VERSION") | .value' < "${OPERATOR_DEPLOYMENT}")
|
||||
waitEclipseCheDeployed "${cheVersion}"
|
||||
|
||||
waitDevWorkspaceControllerStarted
|
||||
pushd ${OPERATOR_REPO}
|
||||
make wait-eclipseche-version VERSION="${cheVersion}" NAMESPACE=${NAMESPACE}
|
||||
make wait-devworkspace-running NAMESPACE="devworkspace-controller"
|
||||
popd
|
||||
}
|
||||
|
||||
deployEclipseCheWithOperator() {
|
||||
|
|
@ -247,8 +244,7 @@ deployEclipseCheWithOperator() {
|
|||
yq -riY '.spec.networking.tlsSecretName = "che-tls"' ${checluster}
|
||||
|
||||
if [[ ${customimage} == "true" ]]; then
|
||||
buildCheOperatorImage
|
||||
copyCheOperatorImageToMinikube
|
||||
buildAndCopyCheOperatorImageToMinikube
|
||||
yq -riSY '.spec.template.spec.containers[0].image = "'${OPERATOR_IMAGE}'"' "${templates}"/che-operator/kubernetes/operator.yaml
|
||||
yq -riSY '.spec.template.spec.containers[0].imagePullPolicy = "IfNotPresent"' "${templates}"/che-operator/kubernetes/operator.yaml
|
||||
fi
|
||||
|
|
@ -260,7 +256,9 @@ deployEclipseCheWithOperator() {
|
|||
--installer operator \
|
||||
--templates ${templates}
|
||||
|
||||
waitDevWorkspaceControllerStarted
|
||||
pushd ${OPERATOR_REPO}
|
||||
make wait-devworkspace-running NAMESPACE="devworkspace-controller"
|
||||
popd
|
||||
}
|
||||
|
||||
updateEclipseChe() {
|
||||
|
|
@ -271,13 +269,9 @@ updateEclipseChe() {
|
|||
|
||||
if [[ ${customimage} == "true" ]]; then
|
||||
if [[ ${platform} == "minikube" ]]; then
|
||||
buildCheOperatorImage
|
||||
copyCheOperatorImageToMinikube
|
||||
buildAndCopyCheOperatorImageToMinikube
|
||||
yq -riSY '.spec.template.spec.containers[0].image = "'${OPERATOR_IMAGE}'"' ${templates}/che-operator/kubernetes/operator.yaml
|
||||
yq -riSY '.spec.template.spec.containers[0].imagePullPolicy = "IfNotPresent"' ${templates}/che-operator/kubernetes/operator.yaml
|
||||
else
|
||||
yq -riSY '.spec.template.spec.containers[0].image = "'${OPERATOR_IMAGE}'"' ${templates}/che-operator/openshift/operator.yaml
|
||||
yq -riSY '.spec.template.spec.containers[0].imagePullPolicy = "IfNotPresent"' ${templates}/che-operator/openshift/operator.yaml
|
||||
yq -riSY '.spec.template.spec.containers[0].imagePullPolicy = "Never"' ${templates}/che-operator/kubernetes/operator.yaml
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
@ -287,55 +281,11 @@ updateEclipseChe() {
|
|||
|
||||
local configManagerPath="${templates}/che-operator/kubernetes/operator.yaml"
|
||||
local cheVersion=$(cat "${configManagerPath}" | yq -r '.spec.template.spec.containers[0].env[] | select(.name == "CHE_VERSION") | .value')
|
||||
waitEclipseCheDeployed ${cheVersion}
|
||||
|
||||
waitDevWorkspaceControllerStarted
|
||||
}
|
||||
|
||||
waitEclipseCheDeployed() {
|
||||
local version=$1
|
||||
echo "[INFO] Wait for Eclipse Che '${version}' version"
|
||||
|
||||
export n=0
|
||||
while [ $n -le 500 ]
|
||||
do
|
||||
cheVersion=$(oc get checluster/eclipse-che -n "${NAMESPACE}" -o "jsonpath={.status.cheVersion}")
|
||||
chePhase=$(oc get checluster/eclipse-che -n "${NAMESPACE}" -o "jsonpath={.status.chePhase}" )
|
||||
oc get pods -n ${NAMESPACE}
|
||||
if [[ "${cheVersion}" == "${version}" ]]
|
||||
then
|
||||
echo "[INFO] Eclipse Che '${version}' version has been successfully deployed"
|
||||
break
|
||||
fi
|
||||
sleep 6
|
||||
n=$(( n+1 ))
|
||||
done
|
||||
|
||||
if [ $n -gt 360 ]
|
||||
then
|
||||
echo "[ERROR] Failed to deploy Eclipse Che '${version}' verion"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
waitDevWorkspaceControllerStarted() {
|
||||
echo "[INFO] Wait for Dev Workspace controller started"
|
||||
|
||||
n=0
|
||||
while [ $n -le 24 ]
|
||||
do
|
||||
webhooks=$(oc get mutatingWebhookConfiguration --all-namespaces)
|
||||
if [[ $webhooks =~ .*controller.devfile.io.* ]]; then
|
||||
echo "[INFO] Dev Workspace controller has been deployed"
|
||||
return
|
||||
fi
|
||||
|
||||
sleep 5
|
||||
n=$(( n+1 ))
|
||||
done
|
||||
|
||||
echo "[ERROR] Failed to deploy Dev Workspace controller"
|
||||
exit 1
|
||||
pushd ${OPERATOR_REPO}
|
||||
make wait-eclipseche-version VERSION="${cheVersion}" NAMESPACE=${NAMESPACE}
|
||||
make wait-devworkspace-running NAMESPACE="devworkspace-controller"
|
||||
popd
|
||||
}
|
||||
|
||||
installchectl() {
|
||||
|
|
|
|||
384
Makefile
384
Makefile
|
|
@ -114,8 +114,34 @@ help: ## Display this help.
|
|||
|
||||
##@ Development
|
||||
|
||||
build: generate ## Build Eclipse Che operator binary
|
||||
go build -o bin/manager main.go
|
||||
|
||||
run: SHELL := /bin/bash
|
||||
run: install-che-operands genenerate-env ## Run Eclipse Che operator
|
||||
source $(BASH_ENV_FILE)
|
||||
go run ./main.go
|
||||
|
||||
debug: SHELL := /bin/bash
|
||||
debug: install-che-operands genenerate-env ## Run and debug Eclipse Che operator
|
||||
source $(BASH_ENV_FILE)
|
||||
# dlv has an issue with 'Ctrl-C' termination, that's why we're doing trick with detach.
|
||||
dlv debug --listen=:2345 --headless=true --api-version=2 ./main.go -- &
|
||||
DLV_PID=$!
|
||||
wait $${DLV_PID}
|
||||
|
||||
docker-build: ## Build Eclipse Che operator image
|
||||
if [ "$(SKIP_TESTS)" = true ]; then
|
||||
${IMAGE_TOOL} build -t ${IMG} --build-arg SKIP_TESTS=true .
|
||||
else
|
||||
${IMAGE_TOOL} build -t ${IMG} .
|
||||
fi
|
||||
|
||||
docker-push: ## Push Eclipse Che operator image to a registry
|
||||
${IMAGE_TOOL} push ${IMG}
|
||||
|
||||
update-dev-resources: SHELL := /bin/bash
|
||||
update-dev-resources: validate-requirements ## Update all resources
|
||||
update-dev-resources: validate-requirements ## Update development resources
|
||||
# Update ubi8 image
|
||||
ubiMinimal8Version=$$(skopeo --override-os linux inspect docker://registry.access.redhat.com/ubi8-minimal:latest | jq -r '.Labels.version')
|
||||
ubiMinimal8Release=$$(skopeo --override-os linux inspect docker://registry.access.redhat.com/ubi8-minimal:latest | jq -r '.Labels.release')
|
||||
|
|
@ -132,56 +158,31 @@ update-dev-resources: validate-requirements ## Update all resources
|
|||
$(MAKE) update-helmcharts CHANNEL=next
|
||||
$(MAKE) fmt
|
||||
|
||||
update-rbac: SHELL := /bin/bash
|
||||
update-rbac:
|
||||
CLUSTER_ROLES=(
|
||||
https://raw.githubusercontent.com/devfile/devworkspace-operator/${DEV_WORKSPACE_CONTROLLER_VERSION}/deploy/deployment/openshift/objects/devworkspace-controller-view-workspaces.ClusterRole.yaml
|
||||
https://raw.githubusercontent.com/devfile/devworkspace-operator/${DEV_WORKSPACE_CONTROLLER_VERSION}/deploy/deployment/openshift/objects/devworkspace-controller-edit-workspaces.ClusterRole.yaml
|
||||
https://raw.githubusercontent.com/devfile/devworkspace-operator/${DEV_WORKSPACE_CONTROLLER_VERSION}/deploy/deployment/openshift/objects/devworkspace-controller-leader-election-role.Role.yaml
|
||||
https://raw.githubusercontent.com/devfile/devworkspace-operator/${DEV_WORKSPACE_CONTROLLER_VERSION}/deploy/deployment/openshift/objects/devworkspace-controller-proxy-role.ClusterRole.yaml
|
||||
https://raw.githubusercontent.com/devfile/devworkspace-operator/${DEV_WORKSPACE_CONTROLLER_VERSION}/deploy/deployment/openshift/objects/devworkspace-controller-role.ClusterRole.yaml
|
||||
https://raw.githubusercontent.com/devfile/devworkspace-operator/${DEV_WORKSPACE_CONTROLLER_VERSION}/deploy/deployment/openshift/objects/devworkspace-controller-metrics-reader.ClusterRole.yaml
|
||||
)
|
||||
gen-deployment: SHELL := /bin/bash
|
||||
gen-deployment: manifests download-kustomize kustomize-operator-image ## Generate Eclipse Che k8s deployment resources
|
||||
rm -rf $(DEPLOYMENT_DIR)
|
||||
for TARGET_PLATFORM in kubernetes openshift; do
|
||||
PLATFORM_DIR=$(DEPLOYMENT_DIR)/$${TARGET_PLATFORM}
|
||||
OBJECTS_DIR=$${PLATFORM_DIR}/objects
|
||||
|
||||
# Updates cluster_role.yaml based on DW roles
|
||||
## Removes old cluster roles
|
||||
cat config/rbac/cluster_role.yaml | sed '/CHE-OPERATOR ROLES ONLY: END/q0' > config/rbac/cluster_role.yaml.tmp
|
||||
mv config/rbac/cluster_role.yaml.tmp config/rbac/cluster_role.yaml
|
||||
mkdir -p $${OBJECTS_DIR}
|
||||
|
||||
# Copy new cluster roles
|
||||
for roles in "$${CLUSTER_ROLES[@]}"; do
|
||||
echo " # "$$(basename $$roles) >> config/rbac/cluster_role.yaml
|
||||
COMBINED_FILENAME=$${PLATFORM_DIR}/combined.yaml
|
||||
$(KUSTOMIZE) build config/$${TARGET_PLATFORM} | cat > $${COMBINED_FILENAME} -
|
||||
|
||||
CONTENT=$$(curl -sL $$roles | sed '1,/rules:/d')
|
||||
while IFS= read -r line; do
|
||||
echo " $$line" >> config/rbac/cluster_role.yaml
|
||||
done <<< "$$CONTENT"
|
||||
# Split the giant files output by kustomize per-object
|
||||
csplit -s -f "temp" --suppress-matched "$${COMBINED_FILENAME}" '/^---$$/' '{*}'
|
||||
for file in temp??; do
|
||||
name_kind=$$(yq -r '"\(.metadata.name).\(.kind)"' "$${file}")
|
||||
mv "$${file}" "$${OBJECTS_DIR}/$${name_kind}.yaml"
|
||||
done
|
||||
cp $(PROJECT_DIR)/config/samples/org_v2_checluster.yaml $${PLATFORM_DIR}
|
||||
|
||||
echo "[INFO] Deployments resources generated into $${PLATFORM_DIR}"
|
||||
done
|
||||
|
||||
ROLES=(
|
||||
# currently, there are no other roles we need to incorporate
|
||||
)
|
||||
|
||||
# Updates role.yaml
|
||||
## Removes old roles
|
||||
cat config/rbac/role.yaml | sed '/CHE-OPERATOR ROLES ONLY: END/q0' > config/rbac/role.yaml.tmp
|
||||
mv config/rbac/role.yaml.tmp config/rbac/role.yaml
|
||||
|
||||
## Copy new roles
|
||||
for roles in "$${ROLES[@]}"; do
|
||||
echo "# "$$(basename $$roles) >> config/rbac/role.yaml
|
||||
|
||||
CONTENT=$$(curl -sL $$roles | sed '1,/rules:/d')
|
||||
while IFS= read -r line; do
|
||||
echo "$$line" >> config/rbac/role.yaml
|
||||
done <<< "$$CONTENT"
|
||||
done
|
||||
|
||||
echo "[INFO] Updated config/rbac/role.yaml"
|
||||
echo "[INFO] Updated config/rbac/cluster_role.yam"
|
||||
|
||||
update-helmcharts: SHELL := /bin/bash
|
||||
update-helmcharts: ## Update Helm Charts
|
||||
update-helmcharts: ## Update Helm Charts based on deployment resources
|
||||
[[ -z "$(CHANNEL)" ]] && { echo [ERROR] CHANNEL not defined; exit 1; }
|
||||
|
||||
HELM_DIR=$(PROJECT_DIR)/helmcharts/$(CHANNEL)
|
||||
|
|
@ -233,29 +234,6 @@ update-helmcharts: ## Update Helm Charts
|
|||
|
||||
echo "[INFO] HelmCharts updated $${HELM_DIR}"
|
||||
|
||||
gen-deployment: SHELL := /bin/bash
|
||||
gen-deployment: manifests download-kustomize _kustomize-operator-image ## Generate Eclipse Che k8s deployment resources
|
||||
rm -rf $(DEPLOYMENT_DIR)
|
||||
for TARGET_PLATFORM in kubernetes openshift; do
|
||||
PLATFORM_DIR=$(DEPLOYMENT_DIR)/$${TARGET_PLATFORM}
|
||||
OBJECTS_DIR=$${PLATFORM_DIR}/objects
|
||||
|
||||
mkdir -p $${OBJECTS_DIR}
|
||||
|
||||
COMBINED_FILENAME=$${PLATFORM_DIR}/combined.yaml
|
||||
$(KUSTOMIZE) build config/$${TARGET_PLATFORM} | cat > $${COMBINED_FILENAME} -
|
||||
|
||||
# Split the giant files output by kustomize per-object
|
||||
csplit -s -f "temp" --suppress-matched "$${COMBINED_FILENAME}" '/^---$$/' '{*}'
|
||||
for file in temp??; do
|
||||
name_kind=$$(yq -r '"\(.metadata.name).\(.kind)"' "$${file}")
|
||||
mv "$${file}" "$${OBJECTS_DIR}/$${name_kind}.yaml"
|
||||
done
|
||||
cp $(PROJECT_DIR)/config/samples/org_v2_checluster.yaml $${PLATFORM_DIR}
|
||||
|
||||
echo "[INFO] Deployments resources generated into $${PLATFORM_DIR}"
|
||||
done
|
||||
|
||||
gen-chectl-tmpl: SHELL := /bin/bash
|
||||
gen-chectl-tmpl: ## Generate Eclipse Che k8s deployment resources used by chectl
|
||||
[[ -z "$(TEMPLATES)" ]] && { echo [ERROR] TARGET not defined; exit 1; }
|
||||
|
|
@ -280,45 +258,6 @@ gen-chectl-tmpl: ## Generate Eclipse Che k8s deployment resources used by chectl
|
|||
|
||||
echo "[INFO] Generated chectl templates into $(TEMPLATES)"
|
||||
|
||||
build: generate ## Build Eclipse Che operator binary
|
||||
go build -o bin/manager main.go
|
||||
|
||||
run: SHELL := /bin/bash
|
||||
run: _install-che-operands ## Run Eclipse Che operator
|
||||
source $(BASH_ENV_FILE)
|
||||
go run ./main.go
|
||||
|
||||
debug: SHELL := /bin/bash
|
||||
debug: _install-che-operands ## Run and debug Eclipse Che operator
|
||||
source $(BASH_ENV_FILE)
|
||||
# dlv has an issue with 'Ctrl-C' termination, that's why we're doing trick with detach.
|
||||
dlv debug --listen=:2345 --headless=true --api-version=2 ./main.go -- &
|
||||
DLV_PID=$!
|
||||
wait $${DLV_PID}
|
||||
|
||||
_install-che-operands: SHELL := /bin/bash
|
||||
_install-che-operands: generate manifests download-kustomize genenerate-env download-devworkspace-resources
|
||||
echo "[INFO] Running on $(PLATFORM)"
|
||||
[[ $(PLATFORM) == "kubernetes" ]] && $(MAKE) install-certmgr
|
||||
[[ $(PLATFORM) == "openshift" ]] && $(MAKE) install-devworkspace CHANNEL=next
|
||||
|
||||
$(KUSTOMIZE) build config/$(PLATFORM) | $(K8S_CLI) apply -f -
|
||||
$(MAKE) wait-pod-running SELECTOR="app.kubernetes.io/component=che-operator" NAMESPACE=$(ECLIPSE_CHE_NAMESPACE)
|
||||
|
||||
$(K8S_CLI) scale deploy che-operator -n $(ECLIPSE_CHE_NAMESPACE) --replicas=0
|
||||
$(MAKE) store_tls_cert
|
||||
$(MAKE) create-checluster-cr
|
||||
|
||||
docker-build: ## Build Eclipse Che operator image
|
||||
if [ "$(SKIP_TESTS)" = true ]; then
|
||||
${IMAGE_TOOL} build -t ${IMG} --build-arg SKIP_TESTS=true .
|
||||
else
|
||||
${IMAGE_TOOL} build -t ${IMG} .
|
||||
fi
|
||||
|
||||
docker-push: ## Push Eclipse Che operator image to a registry
|
||||
${IMAGE_TOOL} push ${IMG}
|
||||
|
||||
manifests: download-controller-gen download-addlicense ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
|
||||
$(CONTROLLER_GEN) crd:crdVersions=v1 rbac:roleName=manager-role paths="./..." output:crd:artifacts:config=config/crd/bases
|
||||
|
||||
|
|
@ -356,13 +295,12 @@ ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
|
|||
test: download-devworkspace-resources ## Run tests.
|
||||
export MOCK_API=true; go test -mod=vendor ./... -coverprofile cover.out
|
||||
|
||||
##@ Development utilities
|
||||
|
||||
license: ## Add license to the files
|
||||
FILES=$$(echo $(filter-out $@,$(MAKECMDGOALS)))
|
||||
$(ADD_LICENSE) -f hack/license-header.txt $${FILES}
|
||||
|
||||
genenerate-env: ## Generates environment files to use by bash and vscode
|
||||
# Generates environment files used by bash and vscode
|
||||
genenerate-env:
|
||||
mkdir -p $(INTERNAL_TMP_DIR)
|
||||
cat $(CONFIG_MANAGER) \
|
||||
| yq -r \
|
||||
|
|
@ -388,30 +326,21 @@ genenerate-env: ## Generates environment files to use by bash and vscode
|
|||
|
||||
cat $(BASH_ENV_FILE)
|
||||
|
||||
install-certmgr: SHELL := /bin/bash
|
||||
install-certmgr: ## Install Cert Manager v1.7.1
|
||||
$(K8S_CLI) apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.7.1/cert-manager.yaml
|
||||
$(MAKE) wait-pod-running SELECTOR="app.kubernetes.io/component=controller" NAMESPACE=cert-manager
|
||||
$(MAKE) wait-pod-running SELECTOR="app.kubernetes.io/component=controller" NAMESPACE=cert-manager
|
||||
$(MAKE) wait-pod-running SELECTOR="app.kubernetes.io/component=webhook" NAMESPACE=cert-manager
|
||||
install-che-operands: SHELL := /bin/bash
|
||||
install-che-operands: generate manifests download-kustomize download-devworkspace-resources
|
||||
echo "[INFO] Running on $(PLATFORM)"
|
||||
[[ $(PLATFORM) == "kubernetes" ]] && $(MAKE) install-certmgr
|
||||
[[ $(PLATFORM) == "openshift" ]] && $(MAKE) install-devworkspace CHANNEL=next
|
||||
|
||||
install-devworkspace: SHELL := /bin/bash
|
||||
install-devworkspace: ## Install Dev Workspace operator, supported channels: next and fast
|
||||
[[ -z "$(CHANNEL)" ]] && { echo [ERROR] CHANNEL not defined; exit 1; }
|
||||
$(KUSTOMIZE) build config/$(PLATFORM) | $(K8S_CLI) apply -f -
|
||||
$(MAKE) wait-pod-running SELECTOR="app.kubernetes.io/component=che-operator" NAMESPACE=$(ECLIPSE_CHE_NAMESPACE)
|
||||
|
||||
if [[ $(CHANNEL) == "fast" ]]; then
|
||||
IMAGE="quay.io/devfile/devworkspace-operator-index:release"
|
||||
else
|
||||
IMAGE="quay.io/devfile/devworkspace-operator-index:next"
|
||||
fi
|
||||
$(K8S_CLI) scale deploy che-operator -n $(ECLIPSE_CHE_NAMESPACE) --replicas=0
|
||||
$(MAKE) store_tls_cert
|
||||
$(MAKE) create-checluster-cr
|
||||
|
||||
$(MAKE) create-catalogsource IMAGE="$${IMAGE}" NAME="devworkspace-operator"
|
||||
$(MAKE) create-subscription NAME="devworkspace-operator" PACKAGE_NAME="devworkspace-operator" CHANNEL="$(CHANNEL)" SOURCE="devworkspace-operator" INSTALL_PLAN_APPROVAL="Auto"
|
||||
|
||||
$(MAKE) wait-pod-running SELECTOR="app.kubernetes.io/name=devworkspace-controller,app.kubernetes.io/part-of=devworkspace-operator" NAMESPACE="openshift-operators"
|
||||
$(MAKE) wait-pod-running SELECTOR="app.kubernetes.io/name=devworkspace-webhook-server,app.kubernetes.io/part-of=devworkspace-operator" NAMESPACE="openshift-operators"
|
||||
|
||||
download-devworkspace-resources: ## Downloads Dev Workspace resources
|
||||
# Downloads Dev Workspace resources
|
||||
download-devworkspace-resources:
|
||||
DEVWORKSPACE_RESOURCES=/tmp/devworkspace-operator/templates
|
||||
GATEWAY_RESOURCES=/tmp/header-rewrite-traefik-plugin
|
||||
|
||||
|
|
@ -431,41 +360,61 @@ download-devworkspace-resources: ## Downloads Dev Workspace resources
|
|||
|
||||
echo "[INFO] Gateway resources downloaded into $${GATEWAY_RESOURCES}"
|
||||
|
||||
setup-checluster: create-namespace create-checluster-crd create-checluster-cr ## Setup CheCluster (creates namespace, CRD and CheCluster CR)
|
||||
|
||||
create-checluster-crd: SHELL := /bin/bash
|
||||
create-checluster-crd: ## Creates CheCluster Custom Resource Definition
|
||||
if [[ $(PLATFORM) == "kubernetes" ]]; then
|
||||
$(MAKE) install-certmgr
|
||||
$(K8S_CLI) apply -f $(DEPLOYMENT_DIR)/$(PLATFORM)/objects/che-operator-selfsigned-issuer.Issuer.yaml
|
||||
$(K8S_CLI) apply -f $(DEPLOYMENT_DIR)/$(PLATFORM)/objects/che-operator-serving-cert.Certificate.yaml
|
||||
fi
|
||||
$(K8S_CLI) apply -f $(DEPLOYMENT_DIR)/$(PLATFORM)/objects/checlusters.org.eclipse.che.CustomResourceDefinition.yaml
|
||||
|
||||
create-checluster-cr: SHELL := /bin/bash
|
||||
create-checluster-cr: ## Creates CheCluster Custom Resource V2
|
||||
if [[ "$$($(K8S_CLI) get checluster eclipse-che -n $(ECLIPSE_CHE_NAMESPACE) || false )" ]]; then
|
||||
echo "[INFO] CheCluster already exists."
|
||||
else
|
||||
CHECLUSTER_CR_2_APPLY=/tmp/checluster_cr.yaml
|
||||
cp $(CHECLUSTER_CR_PATH) $${CHECLUSTER_CR_2_APPLY}
|
||||
|
||||
# Update networking.domain field with an actual value
|
||||
if [[ $(PLATFORM) == "kubernetes" ]]; then
|
||||
# kubectl does not have `whoami` command
|
||||
CLUSTER_API_URL=$$(oc whoami --show-server=true) || true;
|
||||
CLUSTER_DOMAIN=$$(echo $${CLUSTER_API_URL} | sed -E 's/https:\/\/(.*):.*/\1/g')
|
||||
yq -riY '.spec.networking.domain = "'$${CLUSTER_DOMAIN}'.nip.io"' $${CHECLUSTER_CR_2_APPLY}
|
||||
fi
|
||||
$(K8S_CLI) apply -f $${CHECLUSTER_CR_2_APPLY} -n $(ECLIPSE_CHE_NAMESPACE)
|
||||
fi
|
||||
|
||||
store_tls_cert: ## Store `che-operator-webhook-server-cert` secret locally
|
||||
# Store `che-operator-webhook-server-cert` secret locally
|
||||
store_tls_cert:
|
||||
mkdir -p /tmp/k8s-webhook-server/serving-certs/
|
||||
$(K8S_CLI) get secret che-operator-webhook-server-cert -n $(ECLIPSE_CHE_NAMESPACE) -o json | jq -r '.data["tls.crt"]' | base64 -d > /tmp/k8s-webhook-server/serving-certs/tls.crt
|
||||
$(K8S_CLI) get secret che-operator-webhook-server-cert -n $(ECLIPSE_CHE_NAMESPACE) -o json | jq -r '.data["tls.key"]' | base64 -d > /tmp/k8s-webhook-server/serving-certs/tls.key
|
||||
|
||||
##@ Deployment
|
||||
update-rbac: SHELL := /bin/bash
|
||||
update-rbac:
|
||||
CLUSTER_ROLES=(
|
||||
https://raw.githubusercontent.com/devfile/devworkspace-operator/${DEV_WORKSPACE_CONTROLLER_VERSION}/deploy/deployment/openshift/objects/devworkspace-controller-view-workspaces.ClusterRole.yaml
|
||||
https://raw.githubusercontent.com/devfile/devworkspace-operator/${DEV_WORKSPACE_CONTROLLER_VERSION}/deploy/deployment/openshift/objects/devworkspace-controller-edit-workspaces.ClusterRole.yaml
|
||||
https://raw.githubusercontent.com/devfile/devworkspace-operator/${DEV_WORKSPACE_CONTROLLER_VERSION}/deploy/deployment/openshift/objects/devworkspace-controller-leader-election-role.Role.yaml
|
||||
https://raw.githubusercontent.com/devfile/devworkspace-operator/${DEV_WORKSPACE_CONTROLLER_VERSION}/deploy/deployment/openshift/objects/devworkspace-controller-proxy-role.ClusterRole.yaml
|
||||
https://raw.githubusercontent.com/devfile/devworkspace-operator/${DEV_WORKSPACE_CONTROLLER_VERSION}/deploy/deployment/openshift/objects/devworkspace-controller-role.ClusterRole.yaml
|
||||
https://raw.githubusercontent.com/devfile/devworkspace-operator/${DEV_WORKSPACE_CONTROLLER_VERSION}/deploy/deployment/openshift/objects/devworkspace-controller-metrics-reader.ClusterRole.yaml
|
||||
)
|
||||
|
||||
# Updates cluster_role.yaml based on DW roles
|
||||
## Removes old cluster roles
|
||||
cat config/rbac/cluster_role.yaml | sed '/CHE-OPERATOR ROLES ONLY: END/q0' > config/rbac/cluster_role.yaml.tmp
|
||||
mv config/rbac/cluster_role.yaml.tmp config/rbac/cluster_role.yaml
|
||||
|
||||
# Copy new cluster roles
|
||||
for roles in "$${CLUSTER_ROLES[@]}"; do
|
||||
echo " # "$$(basename $$roles) >> config/rbac/cluster_role.yaml
|
||||
|
||||
CONTENT=$$(curl -sL $$roles | sed '1,/rules:/d')
|
||||
while IFS= read -r line; do
|
||||
echo " $$line" >> config/rbac/cluster_role.yaml
|
||||
done <<< "$$CONTENT"
|
||||
done
|
||||
|
||||
ROLES=(
|
||||
# currently, there are no other roles we need to incorporate
|
||||
)
|
||||
|
||||
# Updates role.yaml
|
||||
## Removes old roles
|
||||
cat config/rbac/role.yaml | sed '/CHE-OPERATOR ROLES ONLY: END/q0' > config/rbac/role.yaml.tmp
|
||||
mv config/rbac/role.yaml.tmp config/rbac/role.yaml
|
||||
|
||||
## Copy new roles
|
||||
for roles in "$${ROLES[@]}"; do
|
||||
echo "# "$$(basename $$roles) >> config/rbac/role.yaml
|
||||
|
||||
CONTENT=$$(curl -sL $$roles | sed '1,/rules:/d')
|
||||
while IFS= read -r line; do
|
||||
echo "$$line" >> config/rbac/role.yaml
|
||||
done <<< "$$CONTENT"
|
||||
done
|
||||
|
||||
echo "[INFO] Updated config/rbac/role.yaml"
|
||||
echo "[INFO] Updated config/rbac/cluster_role.yam"
|
||||
|
||||
##@ OLM catalog
|
||||
|
||||
.PHONY: bundle
|
||||
bundle: SHELL := /bin/bash
|
||||
|
|
@ -473,7 +422,7 @@ bundle: generate manifests download-kustomize download-operator-sdk ## Generate
|
|||
echo "[INFO] Updating OperatorHub bundle"
|
||||
|
||||
[[ -z "$(CHANNEL)" ]] && { echo [ERROR] CHANNEL not defined; exit 1; }
|
||||
[[ "$(INCREMENT_BUNDLE_VERSION)" == false ]] || $(MAKE) _increment-bundle-version
|
||||
[[ "$(INCREMENT_BUNDLE_VERSION)" == false ]] || $(MAKE) increment-bundle-version
|
||||
|
||||
BUNDLE_PATH=$$($(MAKE) bundle-path)
|
||||
CSV_PATH=$$($(MAKE) csv-path)
|
||||
|
|
@ -581,8 +530,6 @@ catalog-push: ## Push a catalog image
|
|||
[[ -z "$(CATALOG_IMG)" ]] && { echo [ERROR] CATALOG_IMG not defined; exit 1; }
|
||||
$(MAKE) docker-push IMG=$(CATALOG_IMG)
|
||||
|
||||
##@ Utilities
|
||||
|
||||
bundle-path: SHELL := /bin/bash
|
||||
bundle-path: ## Prints path to a bundle directory for a given channel
|
||||
[[ -z "$(CHANNEL)" ]] && { echo [ERROR] CHANNEL not defined; exit 1; }
|
||||
|
|
@ -600,6 +547,8 @@ bundle-version: ## Prints a bundle version for a given channel
|
|||
CSV_PATH=$$($(MAKE) csv-path)
|
||||
echo $$(yq -r ".spec.version" "$${CSV_PATH}")
|
||||
|
||||
##@ Utilities
|
||||
|
||||
OPM ?= $(shell pwd)/bin/opm
|
||||
download-opm: ## Download opm tool
|
||||
command -v $(OPM) >/dev/null 2>&1 && exit
|
||||
|
|
@ -641,20 +590,21 @@ download-operator-sdk: ## Downloads operator sdk tool
|
|||
curl -sL https://github.com/operator-framework/operator-sdk/releases/download/$${OPERATOR_SDK_VERSION}/operator-sdk_$${OS}_$${ARCH} > $${dest}
|
||||
chmod +x $${dest}
|
||||
|
||||
# Check if all required packages are installed
|
||||
validate-requirements: SHELL := /bin/bash
|
||||
validate-requirements: ## Check if all required packages are installed
|
||||
validate-requirements:
|
||||
command -v yq >/dev/null 2>&1 || { echo "[ERROR] yq is not installed. See https://github.com/kislyuk/yq"; exit 1; }
|
||||
command -v skopeo >/dev/null 2>&1 || { echo "[ERROR] skopeo is not installed."; exit 1; }
|
||||
|
||||
# Set a new operator image for kustomize
|
||||
_kustomize-operator-image:
|
||||
kustomize-operator-image:
|
||||
cd config/manager
|
||||
$(KUSTOMIZE) edit set image quay.io/eclipse/che-operator:next=$(IMG)
|
||||
cd ../..
|
||||
|
||||
# Set a new version for the next channel
|
||||
_increment-bundle-version: SHELL := /bin/bash
|
||||
_increment-bundle-version:
|
||||
increment-bundle-version: SHELL := /bin/bash
|
||||
increment-bundle-version:
|
||||
echo "[INFO] Increment bundle version for the next channel"
|
||||
|
||||
STABLE_BUNDLE_VERSION=$$($(MAKE) bundle-version CHANNEL=stable)
|
||||
|
|
@ -681,7 +631,8 @@ _increment-bundle-version:
|
|||
|
||||
echo "[INFO] New next version: $${NEW_NEXT_BUNDLE_VERSION}"
|
||||
|
||||
##@ Kubernetes tools
|
||||
|
||||
##@ Kubernetes helper
|
||||
|
||||
create-catalogsource: SHELL := /bin/bash
|
||||
create-catalogsource: ## Creates catalog source
|
||||
|
|
@ -714,6 +665,7 @@ create-catalogsource: ## Creates catalog source
|
|||
create-subscription: SHELL := /bin/bash
|
||||
create-subscription: ## Creates subscription
|
||||
[[ -z "$(NAME)" ]] && { echo [ERROR] NAME not defined; exit 1; }
|
||||
[[ -z "$(NAMESPACE)" ]] && DEFINED_NAMESPACE="openshift-operators" || DEFINED_NAMESPACE=$(NAMESPACE)
|
||||
[[ -z "$(CHANNEL)" ]] && { echo [ERROR] CHANNEL not defined; exit 1; }
|
||||
[[ -z "$(INSTALL_PLAN_APPROVAL)" ]] && { echo [ERROR] INSTALL_PLAN_APPROVAL not defined; exit 1; }
|
||||
[[ -z "$(PACKAGE_NAME)" ]] && { echo [ERROR] PACKAGE_NAME not defined; exit 1; }
|
||||
|
|
@ -725,7 +677,7 @@ create-subscription: ## Creates subscription
|
|||
"kind": "Subscription",
|
||||
"metadata": {
|
||||
"name": "$(NAME)",
|
||||
"namespace": "openshift-operators"
|
||||
"namespace": "'$${DEFINED_NAMESPACE}'"
|
||||
},
|
||||
"spec": {
|
||||
"channel": "$(CHANNEL)",
|
||||
|
|
@ -738,16 +690,17 @@ create-subscription: ## Creates subscription
|
|||
}' | $(K8S_CLI) apply -f -
|
||||
|
||||
if [[ ${INSTALL_PLAN_APPROVAL} == "Manual" ]]; then
|
||||
$(K8S_CLI) wait subscription $(NAME) -n openshift-operators --for=condition=InstallPlanPending --timeout=60s
|
||||
$(K8S_CLI) wait subscription $(NAME) -n $${DEFINED_NAMESPACE} --for=condition=InstallPlanPending --timeout=60s
|
||||
fi
|
||||
|
||||
approve-installplan: SHELL := /bin/bash
|
||||
approve-installplan: ## Approves install plan
|
||||
[[ -z "$(SUBSCRIPTION_NAME)" ]] && { echo [ERROR] SUBSCRIPTION_NAME not defined; exit 1; }
|
||||
[[ -z "$(NAMESPACE)" ]] && DEFINED_NAMESPACE="openshift-operators" || DEFINED_NAMESPACE=$(NAMESPACE)
|
||||
|
||||
INSTALL_PLAN_NAME=$$($(K8S_CLI) get subscription/$(SUBSCRIPTION_NAME) -n openshift-operators -o jsonpath='{.status.installplan.name}')
|
||||
$(K8S_CLI) patch installplan $${INSTALL_PLAN_NAME} -n openshift-operators --type=merge -p '{"spec":{"approved":true}}'
|
||||
$(K8S_CLI) wait installplan $${INSTALL_PLAN_NAME} -n openshift-operators --for=condition=Installed --timeout=240s
|
||||
INSTALL_PLAN_NAME=$$($(K8S_CLI) get subscription $(SUBSCRIPTION_NAME) -n $${DEFINED_NAMESPACE} -o jsonpath='{.status.installplan.name}')
|
||||
$(K8S_CLI) patch installplan $${INSTALL_PLAN_NAME} -n $${DEFINED_NAMESPACE} --type=merge -p '{"spec":{"approved":true}}'
|
||||
$(K8S_CLI) wait installplan $${INSTALL_PLAN_NAME} -n $${DEFINED_NAMESPACE} --for=condition=Installed --timeout=240s
|
||||
|
||||
create-namespace: SHELL := /bin/bash
|
||||
create-namespace: ## Creates namespace
|
||||
|
|
@ -763,3 +716,84 @@ wait-pod-running: ## Wait until pod is up and running
|
|||
sleep 10s
|
||||
done
|
||||
$(K8S_CLI) wait --for=condition=ready pod -l $(SELECTOR) -n $(NAMESPACE) --timeout=120s
|
||||
|
||||
install-certmgr: SHELL := /bin/bash
|
||||
install-certmgr: ## Install Cert Manager v1.7.1
|
||||
$(K8S_CLI) apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.7.1/cert-manager.yaml
|
||||
$(MAKE) wait-pod-running SELECTOR="app.kubernetes.io/component=controller" NAMESPACE=cert-manager
|
||||
$(MAKE) wait-pod-running SELECTOR="app.kubernetes.io/component=controller" NAMESPACE=cert-manager
|
||||
$(MAKE) wait-pod-running SELECTOR="app.kubernetes.io/component=webhook" NAMESPACE=cert-manager
|
||||
|
||||
install-devworkspace: SHELL := /bin/bash
|
||||
install-devworkspace: ## Install Dev Workspace operator, available channels: next, fast
|
||||
[[ -z "$(CHANNEL)" ]] && { echo [ERROR] CHANNEL not defined; exit 1; }
|
||||
|
||||
if [[ $(CHANNEL) == "fast" ]]; then
|
||||
IMAGE="quay.io/devfile/devworkspace-operator-index:release"
|
||||
else
|
||||
IMAGE="quay.io/devfile/devworkspace-operator-index:next"
|
||||
fi
|
||||
|
||||
$(MAKE) create-catalogsource IMAGE="$${IMAGE}" NAME="devworkspace-operator"
|
||||
$(MAKE) create-subscription NAME="devworkspace-operator" PACKAGE_NAME="devworkspace-operator" CHANNEL="$(CHANNEL)" SOURCE="devworkspace-operator" INSTALL_PLAN_APPROVAL="Auto"
|
||||
$(MAKE) wait-devworkspace-running NAMESPACE="openshift-operators"
|
||||
|
||||
wait-devworkspace-running: SHELL := /bin/bash
|
||||
wait-devworkspace-running: ## Wait until Dev Workspace operator is up and running
|
||||
$(MAKE) wait-pod-running SELECTOR="app.kubernetes.io/name=devworkspace-controller,app.kubernetes.io/part-of=devworkspace-operator"
|
||||
$(MAKE) wait-pod-running SELECTOR="app.kubernetes.io/name=devworkspace-webhook-server,app.kubernetes.io/part-of=devworkspace-operator"
|
||||
|
||||
setup-checluster: create-namespace create-checluster-crd create-checluster-cr ## Setup CheCluster (creates namespace, CRD and CheCluster CR)
|
||||
|
||||
create-checluster-crd: SHELL := /bin/bash
|
||||
create-checluster-crd: ## Creates CheCluster Custom Resource Definition
|
||||
if [[ $(PLATFORM) == "kubernetes" ]]; then
|
||||
$(MAKE) install-certmgr
|
||||
$(K8S_CLI) apply -f $(DEPLOYMENT_DIR)/$(PLATFORM)/objects/che-operator-selfsigned-issuer.Issuer.yaml
|
||||
$(K8S_CLI) apply -f $(DEPLOYMENT_DIR)/$(PLATFORM)/objects/che-operator-serving-cert.Certificate.yaml
|
||||
fi
|
||||
$(K8S_CLI) apply -f $(DEPLOYMENT_DIR)/$(PLATFORM)/objects/checlusters.org.eclipse.che.CustomResourceDefinition.yaml
|
||||
|
||||
create-checluster-cr: SHELL := /bin/bash
|
||||
create-checluster-cr: ## Creates CheCluster Custom Resource V2
|
||||
if [[ "$$($(K8S_CLI) get checluster eclipse-che -n $(ECLIPSE_CHE_NAMESPACE) || false )" ]]; then
|
||||
echo "[INFO] CheCluster already exists."
|
||||
else
|
||||
CHECLUSTER_CR_2_APPLY=/tmp/checluster_cr.yaml
|
||||
cp $(CHECLUSTER_CR_PATH) $${CHECLUSTER_CR_2_APPLY}
|
||||
|
||||
# Update networking.domain field with an actual value
|
||||
if [[ $(PLATFORM) == "kubernetes" ]]; then
|
||||
# kubectl does not have `whoami` command
|
||||
CLUSTER_API_URL=$$(oc whoami --show-server=true) || true;
|
||||
CLUSTER_DOMAIN=$$(echo $${CLUSTER_API_URL} | sed -E 's/https:\/\/(.*):.*/\1/g')
|
||||
yq -riY '.spec.networking.domain = "'$${CLUSTER_DOMAIN}'.nip.io"' $${CHECLUSTER_CR_2_APPLY}
|
||||
fi
|
||||
$(K8S_CLI) apply -f $${CHECLUSTER_CR_2_APPLY} -n $(ECLIPSE_CHE_NAMESPACE)
|
||||
fi
|
||||
|
||||
wait-eclipseche-version: SHELL := /bin/bash
|
||||
wait-eclipseche-version: ## Wait until Eclipse Che given version is up and running
|
||||
echo "[INFO] Wait for Eclipse Che '$(VERSION)' version"
|
||||
|
||||
[[ -z "$(VERSION)" ]] && { echo [ERROR] VERSION not defined; exit 1; }
|
||||
[[ -z "$(NAMESPACE)" ]] && { echo [ERROR] NAMESPACE not defined; exit 1; }
|
||||
|
||||
n=0
|
||||
while [[ $$n -le 500 ]]
|
||||
do
|
||||
$(K8S_CLI) get pods -n $(NAMESPACE)
|
||||
ACTUAL_VERSION=$$($(K8S_CLI) get checluster eclipse-che -n $(NAMESPACE) -o "jsonpath={.status.cheVersion}")
|
||||
if [[ $${ACTUAL_VERSION} == $(VERSION) ]]; then
|
||||
echo "[INFO] Eclipse Che $(VERSION) has been successfully deployed"
|
||||
break
|
||||
fi
|
||||
|
||||
sleep 5
|
||||
n=$$(( n+1 ))
|
||||
done
|
||||
|
||||
if [[ $$n -gt 500 ]]; then
|
||||
echo "[ERROR] Failed to deploy Eclipse Che '${version}' version"
|
||||
exit 1
|
||||
fi
|
||||
|
|
@ -69,7 +69,7 @@ run() {
|
|||
make create-catalogsource NAME="${ECLIPSE_CHE_CATALOG_SOURCE_NAME}" IMAGE="${CATALOG_IMAGE}"
|
||||
popd
|
||||
|
||||
local bundles=$(getCatalogSourceBundles "${ECLIPSE_CHE_CATALOG_SOURCE_NAME}")
|
||||
local bundles=$(discoverCatalogSourceBundles "${ECLIPSE_CHE_CATALOG_SOURCE_NAME}")
|
||||
fetchLatestCSVInfo "${CHANNEL}" "${bundles}"
|
||||
forcePullingOlmImages "${LATEST_CSV_BUNDLE_IMAGE}"
|
||||
|
||||
|
|
@ -80,14 +80,15 @@ run() {
|
|||
CHANNEL="${CHANNEL}" \
|
||||
SOURCE="${ECLIPSE_CHE_CATALOG_SOURCE_NAME}" \
|
||||
SOURCE_NAMESPACE="openshift-marketplace" \
|
||||
INSTALL_PLAN_APPROVAL="Manual"
|
||||
make approve-installplan SUBSCRIPTION_NAME="${ECLIPSE_CHE_SUBSCRIPTION_NAME}"
|
||||
INSTALL_PLAN_APPROVAL="Auto"
|
||||
popd
|
||||
|
||||
sleep 10s
|
||||
waitForInstalledEclipseCheCSV
|
||||
getCheClusterCRFromInstalledCSV | oc apply -n "${NAMESPACE}" -f -
|
||||
|
||||
getCheClusterCRFromCSV | oc apply -n "${NAMESPACE}" -f -
|
||||
waitEclipseCheDeployed "$(getCheVersionFromCSV)"
|
||||
pushd ${OPERATOR_REPO}
|
||||
make wait-eclipseche-version VERSION="$(getCheVersionFromInstalledCSV)" NAMESPACE=${NAMESPACE}
|
||||
popd
|
||||
}
|
||||
|
||||
init "$@"
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ run() {
|
|||
make create-catalogsource NAME="${ECLIPSE_CHE_CATALOG_SOURCE_NAME}" IMAGE="${CATALOG_IMAGE}"
|
||||
popd
|
||||
|
||||
local bundles=$(getCatalogSourceBundles "${ECLIPSE_CHE_CATALOG_SOURCE_NAME}")
|
||||
local bundles=$(discoverCatalogSourceBundles "${ECLIPSE_CHE_CATALOG_SOURCE_NAME}")
|
||||
fetchPreviousCSVInfo "${CHANNEL}" "${bundles}"
|
||||
fetchLatestCSVInfo "${CHANNEL}" "${bundles}"
|
||||
|
||||
|
|
@ -95,14 +95,13 @@ run() {
|
|||
|
||||
sleep 10s
|
||||
|
||||
getCheClusterCRFromCSV | oc apply -n "${NAMESPACE}" -f -
|
||||
waitEclipseCheDeployed "$(getCheVersionFromCSV)"
|
||||
getCheClusterCRFromInstalledCSV | oc apply -n "${NAMESPACE}" -f -
|
||||
|
||||
pushd ${OPERATOR_REPO} || exit 1
|
||||
make wait-eclipseche-version VERSION="$(getCheVersionFromInstalledCSV)" NAMESPACE=${NAMESPACE}
|
||||
make approve-installplan SUBSCRIPTION_NAME="${ECLIPSE_CHE_SUBSCRIPTION_NAME}"
|
||||
make wait-eclipseche-version VERSION="$(getCheVersionFromInstalledCSV)" NAMESPACE=${NAMESPACE}
|
||||
popd
|
||||
|
||||
waitEclipseCheDeployed "$(getCheVersionFromCSV)"
|
||||
}
|
||||
|
||||
init "$@"
|
||||
|
|
|
|||
Loading…
Reference in New Issue