From fd2fc0edafe291b6903452c898a1f2e6ffb63772 Mon Sep 17 00:00:00 2001 From: Madhu Kanoor Date: Wed, 14 Feb 2024 15:47:55 -0500 Subject: [PATCH] chore: allow for minikube deployments to use quay images (#676) --- Taskfile.dist.yaml | 14 ++++++++ scripts/eda_kube.sh | 55 ++++++++++++++++++++++++++++++-- tools/deploy/eda-ui/service.yaml | 6 ++-- 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/Taskfile.dist.yaml b/Taskfile.dist.yaml index 315df25c1..5d6dd7173 100644 --- a/Taskfile.dist.yaml +++ b/Taskfile.dist.yaml @@ -241,6 +241,13 @@ tasks: vars: CLI_ARGS: build-api {{.CLI_ARGS}} + minikube:build:ui: + desc: "Build EDA UI image and push to minikube" + cmds: + - task: minikube + vars: + CLI_ARGS: build-ui {{.CLI_ARGS}} + minikube:deploy: desc: "Build deployment and deploy to minikube" cmds: @@ -248,6 +255,13 @@ tasks: vars: CLI_ARGS: deploy {{.CLI_ARGS}} + minikube:quay-deploy: + desc: "Build deployment from quay deploy to minikube" + cmds: + - task: minikube + vars: + CLI_ARGS: quay-deploy {{.CLI_ARGS}} + minikube:clean: desc: "Clean deployment directory and clean minikube resources" cmds: diff --git a/scripts/eda_kube.sh b/scripts/eda_kube.sh index b91ba0722..a01f275fe 100755 --- a/scripts/eda_kube.sh +++ b/scripts/eda_kube.sh @@ -22,6 +22,11 @@ source "${SCRIPTS_DIR}"/common/utils.sh trap handle_errors ERR +export EDA_IMAGE=${EDA_IMAGE:-'quay.io/ansible/eda-server:main'} +export EDA_UI_IMAGE=${EDA_UI_IMAGE:-'quay.io/ansible/eda-ui:main'} +export EDA_IMAGE_PULL_POLICY=${EDA_IMAGE_PULL_POLICY:-'Always'} +export EDA_UI_IMAGE_PULL_POLICY=${EDA_UI_IMAGE_PULL_POLICY:-'Always'} + handle_errors() { log-err "An error occurred on or around line ${BASH_LINENO[0]}. Unable to continue." exit 1 @@ -76,6 +81,41 @@ build-deployment() { kustomize build "${DEPLOY_DIR}" -o "${DEPLOY_DIR}/temp" } +build-quay-deployment() { + local _temp_dir="${DEPLOY_DIR}"/temp + declare -a app_dirs=("eda-api" "eda-activation-worker" "eda-default-worker" "eda-scheduler") + + log-info "Using Deployment Directory: ${DEPLOY_DIR}/temp" + + if [ -d "${_temp_dir}" ]; then + rm -rf "${_temp_dir}" + fi + mkdir "${_temp_dir}" + + for app_dir in "${app_dirs[@]}" + do + cd "${DEPLOY_DIR}"/"$app_dir" + log-debug "kustomize edit set image aap-eda=${EDA_IMAGE}" + kustomize edit set image aap-eda="${EDA_IMAGE}" + kustomize edit add patch --group apps --version v1 --name "$app_dir" --kind Deployment --patch "[{\"op\": \"replace\", \"path\": \"/spec/template/spec/containers/0/imagePullPolicy\", \"value\": \""${EDA_IMAGE_PULL_POLICY}"\"}]" + done + + cd "${DEPLOY_DIR}"/eda-ui + log-debug "kustomize edit set image eda-ui=${EDA_UI_IMAGE}" + kustomize edit set image eda-ui="${EDA_UI_IMAGE}" + kustomize edit add patch --group apps --version v1 --name eda-ui --kind Deployment --patch "[{\"op\": \"replace\", \"path\": \"/spec/template/spec/containers/0/imagePullPolicy\", \"value\": \""${EDA_UI_IMAGE_PULL_POLICY}"\"}]" + + cd "${PROJECT_DIR}" + log-debug "kustomize build ${DEPLOY_DIR} -o ${DEPLOY_DIR}/temp" + kustomize build "${DEPLOY_DIR}" -o "${DEPLOY_DIR}/temp" + + for app_dir in "${app_dirs[@]}" + do + git checkout -- "${DEPLOY_DIR}/${app_dir}/kustomization.yaml" + done + git checkout -- "${DEPLOY_DIR}/eda-ui/kustomization.yaml" +} + build-deployment-api() { local _api_image="aap-eda:${1}" local _temp_dir="${DEPLOY_DIR}"/temp @@ -124,11 +164,20 @@ build-all() { build-deployment "${1}" } +quay-deploy() { + build-quay-deployment "${1}" + deploy "${1}" +} + build-api() { build-eda-api-image "${1}" build-deployment-api "${1}" } +build-ui() { + build-eda-ui-image "${1}" +} + remove-image() { local _image_name="${1}" @@ -217,9 +266,9 @@ port-forward() { } port-forward-ui() { - local _local_port=${PORT:-"8080"} + local _local_port=${PORT:-"8443"} local _svc_name=eda-ui - local _svc_port=8080 + local _svc_port=8443 log-debug "port-forward ${_svc_name} ${_local_port} ${_svc_port}" port-forward "${_svc_name}" "${_local_port}" "${_svc_port}" @@ -255,9 +304,11 @@ get-eda-logs() { case ${CMD} in "build") build-all "${VERSION}" ;; "build-api") build-api "${VERSION}" ;; + "build-ui") build-ui "${VERSION}" ;; "clean") clean-deployment "${VERSION}";; "clean-api") clean-api-deployment "${VERSION}";; "deploy") deploy "${VERSION}" ;; + "quay-deploy") quay-deploy "${VERSION}" ;; "port-forward-api") port-forward-api ${PORT} ;; "port-forward-ui") port-forward-ui ${PORT} ;; "port-forward-pg") port-forward-pg 5432 ;; diff --git a/tools/deploy/eda-ui/service.yaml b/tools/deploy/eda-ui/service.yaml index fe15c0b3c..92a0ae8b4 100644 --- a/tools/deploy/eda-ui/service.yaml +++ b/tools/deploy/eda-ui/service.yaml @@ -5,8 +5,8 @@ metadata: spec: ports: - name: "8080" - port: 8080 - targetPort: 8080 + port: 8443 + targetPort: 443 selector: app: eda - comp: ui \ No newline at end of file + comp: ui