Skip to content

Commit

Permalink
Merge pull request #132 from openinfradev/tks-issues-305
Browse files Browse the repository at this point in the history
AppServing: handle configmap and secrets
  • Loading branch information
robertchoi80 authored Jan 13, 2023
2 parents 394fe00 + dcb7932 commit cdffabd
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
46 changes: 44 additions & 2 deletions app_serving/serve-java-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ spec:
value: "FILE_PATH_IN_THE_IMAGE"
- name: profile
value: "default"
- name: extra_env
value: ""
- name: app_config
value: ""
- name: app_secret
value: ""
# resource_spec: possible values are tiny, medium, large
- name: resource_spec
value: "medium"
Expand All @@ -62,6 +68,8 @@ spec:
value: "tks-info.tks"
- name: git_repo_url
value: "github.com/openinfradev"
- name: harbor_pw_secret
value: "harbor-core"

templates:
- name: exit-handler
Expand Down Expand Up @@ -256,7 +264,7 @@ spec:
docker build --network host -t $image_name . 2> >(tee -a $BUILD_LOG >&2)
# Get harbor admin password from secret
harbor_password=$(kubectl get secret -n harbor harbor-core -o jsonpath='{.data.HARBOR_ADMIN_PASSWORD}' | base64 -d)
harbor_password=$(kubectl get secret -n harbor {{workflow.parameters.harbor_pw_secret}} -o jsonpath='{.data.HARBOR_ADMIN_PASSWORD}' | base64 -d)
# Extract registry URL from image URL
registry_url=$(echo $image_name | awk -F/ '{ print $1 }')
Expand Down Expand Up @@ -296,6 +304,11 @@ spec:
DEPLOY_LOG='/mnt/out/deploy_output.log'
mkdir -p /apps/
# temporary debug
echo "===== Application Config =====\n"
echo "{{workflow.parameters.app_config}}"
echo "==============================\n"
# fetch manifests from git
cd /apps
git clone https://{{workflow.parameters.git_repo_url}}/app-serve-template.git
Expand Down Expand Up @@ -350,10 +363,37 @@ spec:
sed -i "s/PV_SIZE/{{workflow.parameters.pv_size}}/g" ./values.yaml
sed -i "s#PV_MOUNT_PATH#{{workflow.parameters.pv_mount_path}}#g" ./values.yaml
# write app_config to file that is embedded into configmap by helm chart later
# the filename must be same as the one in the configmap.
if [[ -n "{{workflow.parameters.app_config}}" ]]; then
app_conf="{{workflow.parameters.app_config}}"
echo "$app_conf" > config_content.yaml
sed -i "s/CONFIGMAP_ENABLED/true/g" ./values.yaml
else
sed -i "s/CONFIGMAP_ENABLED/false/g" ./values.yaml
fi
# write secret data to file that is embedded into secret by helm chart later
if [[ -n "{{workflow.parameters.app_secret}}" ]]; then
app_secret="{{workflow.parameters.app_secret}}"
echo "$app_secret" > secret_data
sed -i "s/SECRET_ENABLED/true/g" ./values.yaml
else
sed -i "s/SECRET_ENABLED/false/g" ./values.yaml
fi
extra_env_str=""
if [[ -n "{{workflow.parameters.extra_env}}" ]]; then
extra_env_str="--set-json 'extraEnv={{workflow.parameters.extra_env}}'"
fi
# TODO: parse image tag and use it as APP_VERSION in Chart.yaml?
#
# Debug
echo "===== values ====="
cat values.yaml
fi
Expand All @@ -380,9 +420,11 @@ spec:
## TODO: this might be temporary. Once everything is confirmed,
## the helm chart can be pulled from internal helm repo.
helm upgrade --install --kubeconfig /etc/kubeconfig_temp -f /apps/app-serve-template/tomcat-vo.yaml -n {{workflow.parameters.namespace}} {{workflow.parameters.app_name}} . 2> >(tee -a $DEPLOY_LOG >&2)
## For springboot app case ##
else
cd /apps/app-serve-template/chart
helm upgrade --install --kubeconfig /etc/kubeconfig_temp -f values-{{workflow.parameters.resource_spec}}.yaml -n {{workflow.parameters.namespace}} {{workflow.parameters.app_name}} . 2> >(tee -a $DEPLOY_LOG >&2)
helm template test . --debug
eval "helm upgrade --install --kubeconfig /etc/kubeconfig_temp -f values-{{workflow.parameters.resource_spec}}.yaml $extra_env_str -n {{workflow.parameters.namespace}} {{workflow.parameters.app_name}} ." 2> >(tee -a $DEPLOY_LOG >&2)
fi
# Just make sure helm release is deployed before status cmd
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.appserving-worker
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM docker:20.10.16-git

MAINTAINER Cloud Co, SK Telecom

ENV HELM_VER v3.9.4
ENV HELM_VER v3.10.1

USER root

Expand Down

0 comments on commit cdffabd

Please sign in to comment.