Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app-serving: Refactor stages #188

Merged
merged 2 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 20 additions & 71 deletions app_serving/abort-java-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
templates:
- name: exit-handler
steps:
- - name: notify-bluegreen-abort-failure
- - name: notify-abort-failure
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yml 에서 이렇게 depth 가 두 번 들어가는건 어떤 의미인가요? (몰라서 질문드립니다 ㅠ)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yml 에서 이렇게 depth 가 두 번 들어가는건 어떤 의미인가요? (몰라서 질문드립니다 ㅠ)

첫번째 - 는 yaml 에서 list 를 의미하는 것이고, 두번째 - 는 실제로 넘어가는 값입니다.
- name: notify-bluegreen-abort-failure 이렇게 - 가 포함되어 값이 넘어갑니다.

templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
Expand All @@ -42,35 +42,17 @@ spec:
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "BLUEGREEN_ABORT_FAILED"
value: "ABORT_FAILED"
- name: output
value: "{{workflow.outputs.parameters.abort_output_global}}"
when: "{{workflow.status}} != Succeeded && '{{workflow.parameters.strategy}}' == 'blue-green'"
- - name: notify-canary-abort-failure
templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
arguments:
parameters:
- name: organization_id
value: "{{workflow.parameters.organization_id}}"
- name: asa_id
value: "{{workflow.parameters.asa_id}}"
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "CANARY_ABORT_FAILED"
- name: output
value: "{{workflow.outputs.parameters.abort_output_global}}"
when: "{{workflow.status}} != Succeeded && '{{workflow.parameters.strategy}}' == 'canary'"
when: "{{workflow.status}} != Succeeded"

- name: main
steps:
- - name: notify-bluegreen-abort-start
- - name: notify-abort-start
templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
when: "'{{workflow.parameters.strategy}}' == 'blue-green'"
arguments:
parameters:
- name: organization_id
Expand All @@ -80,14 +62,18 @@ spec:
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "BLUEGREEN_ABORTING"
value: "ABORTING"
- name: output
value: ""
- - name: notify-canary-abort-start
- - name: abort-app
template: abort-app
## Stage for updating preview endpoint to 'N/A'
## All other values shouldn't be updated.
## (These values for endpoint & helm_revision are discarded by the API)
- - name: update-endpoint-url
templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
when: "'{{workflow.parameters.strategy}}' == canary"
name: update-tks-asa-endpoint
template: updateTksAsaEndpoint
arguments:
parameters:
- name: organization_id
Expand All @@ -96,12 +82,12 @@ spec:
value: "{{workflow.parameters.asa_id}}"
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "CANARY_ABORTING"
- name: output
- name: endpoint
value: ""
- - name: abort-app
template: abort-app
- name: preview_endpoint
value: "N/A"
- name: helm_revision
value: 0
- - name: notify-abort-success
templateRef:
name: update-tks-asa-status
Expand All @@ -115,27 +101,9 @@ spec:
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "{{steps.abort-app.outputs.parameters.status}}"
value: "ABORT_SUCCESS"
- name: output
value: "{{steps.abort-app.outputs.parameters.abort_output}}"
- - name: update-endpoint-url
templateRef:
name: update-tks-asa-endpoint
template: updateTksAsaEndpoint
arguments:
parameters:
- name: organization_id
value: "{{workflow.parameters.organization_id}}"
- name: asa_id
value: "{{workflow.parameters.asa_id}}"
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: endpoint
value: ""
- name: preview_endpoint
value: "N/A"
- name: helm_revision
value: "{{steps.abort-app.outputs.parameters.revision}}"

#######################
# Template Definition #
Expand All @@ -151,12 +119,6 @@ spec:
valueFrom:
path: /mnt/out/abort_output.log
globalName: abort_output_global
- name: status
valueFrom:
path: /mnt/out/abort_status
- name: revision
valueFrom:
path: /mnt/out/revision
container:
image: harbor-cicd.taco-cat.xyz/tks/appserving-worker:latest
volumeMounts:
Expand Down Expand Up @@ -288,8 +250,6 @@ spec:
exit 1
fi

# write revision
write_revision

# Perform abort
kubectl argo rollouts abort ${app_name} -n $ns
Expand All @@ -309,7 +269,7 @@ spec:
check_rollout_replicas



# TODO: Is just "undoing without revision" not enough?
#==========================================================
# undo to the latest active revision
#==========================================================
Expand All @@ -327,14 +287,3 @@ spec:
#==========================================================
check_rollout_phase "Healthy" "Healthy"



#==========================================================
# write information
#==========================================================
# Write deployment status to file for next step
if [[ "$strategy" == "blue-green" ]]; then
echo "BLUEGREEN_ABORT_SUCCESS" > /mnt/out/abort_status
elif [[ "$strategy" == "canary" ]]; then
echo "CANARY_ABORT_SUCCESS" > /mnt/out/abort_status
fi
91 changes: 19 additions & 72 deletions app_serving/promote-java-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
templates:
- name: exit-handler
steps:
- - name: notify-bluegreen-promote-failure
- - name: notify-promote-failure
templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
Expand All @@ -42,35 +42,17 @@ spec:
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "BLUEGREEN_PROMOTE_FAILED"
value: "PROMOTE_FAILED"
- name: output
value: "{{workflow.outputs.parameters.promote_output_global}}"
when: "{{workflow.status}} != Succeeded && '{{workflow.parameters.strategy}}' == 'blue-green'"
- - name: notify-canary-promote-failure
templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
arguments:
parameters:
- name: organization_id
value: "{{workflow.parameters.organization_id}}"
- name: asa_id
value: "{{workflow.parameters.asa_id}}"
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "CANARY_PROMOTE_FAILED"
- name: output
value: "{{workflow.outputs.parameters.promote_output_global}}"
when: "{{workflow.status}} != Succeeded && '{{workflow.parameters.strategy}}' == canary"
when: "{{workflow.status}} != Succeeded"

- name: main
steps:
- - name: notify-bluegreen-promote-start
- - name: notify-promote-start
templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
when: "'{{workflow.parameters.strategy}}' == 'blue-green'"
arguments:
parameters:
- name: organization_id
Expand All @@ -80,14 +62,18 @@ spec:
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "BLUEGREEN_PROMOTING"
value: "PROMOTING"
- name: output
value: ""
- - name: notify-canary-promote-start
- - name: promote-app
template: promote-app
## Stage for updating preview endpoint to 'N/A'
## All other values shouldn't be updated.
## (These values for endpoint & helm_revision are discarded by the API)
- - name: update-endpoint-url
templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
when: "'{{workflow.parameters.strategy}}' == canary"
name: update-tks-asa-endpoint
template: updateTksAsaEndpoint
arguments:
parameters:
- name: organization_id
Expand All @@ -96,12 +82,12 @@ spec:
value: "{{workflow.parameters.asa_id}}"
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "CANARY_PROMOTING"
- name: output
- name: endpoint
value: ""
- - name: promote-app
template: promote-app
- name: preview_endpoint
value: "N/A"
- name: helm_revision
value: 0
- - name: notify-promote-success
templateRef:
name: update-tks-asa-status
Expand All @@ -115,27 +101,9 @@ spec:
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "{{steps.promote-app.outputs.parameters.status}}"
value: "PROMOTE_SUCCESS"
- name: output
value: "{{steps.promote-app.outputs.parameters.promote_output}}"
- - name: update-endpoint-url
templateRef:
name: update-tks-asa-endpoint
template: updateTksAsaEndpoint
arguments:
parameters:
- name: organization_id
value: "{{workflow.parameters.organization_id}}"
- name: asa_id
value: "{{workflow.parameters.asa_id}}"
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: endpoint
value: ""
- name: preview_endpoint
value: "N/A"
- name: helm_revision
value: "{{steps.promote-app.outputs.parameters.revision}}"

#######################
# Template Definition #
Expand All @@ -154,12 +122,6 @@ spec:
# - name: endpoint
# valueFrom:
# path: /mnt/out/endpoint
- name: status
valueFrom:
path: /mnt/out/promote_status
- name: revision
valueFrom:
path: /mnt/out/revision
container:
image: harbor-cicd.taco-cat.xyz/tks/appserving-worker:latest
volumeMounts:
Expand Down Expand Up @@ -272,7 +234,6 @@ spec:
}



#==========================================================
# Start promoting Rollout
#==========================================================
Expand All @@ -286,9 +247,6 @@ spec:
exit 1
fi

# write revision
write_revision

# Perform promotion
kubectl argo rollouts promote ${app_name} -n {{workflow.parameters.namespace}}

Expand All @@ -305,14 +263,3 @@ spec:
#==========================================================
check_rollout_replicas



#==========================================================
# write information
#==========================================================
# Write deployment status to file for next step
if [[ "$strategy" == "blue-green" ]]; then
echo "BLUEGREEN_PROMOTE_SUCCESS" > /mnt/out/promote_status
elif [[ "$strategy" == "canary" ]]; then
echo "CANARY_PROMOTE_SUCCESS" > /mnt/out/promote_status
fi
32 changes: 16 additions & 16 deletions app_serving/rollback-java-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,6 @@ spec:
value: ""
- - name: rollback-app
template: rollback-app
- - name: notify-rollback-success
templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
arguments:
parameters:
- name: organization_id
value: "{{workflow.parameters.organization_id}}"
- name: asa_id
value: "{{workflow.parameters.asa_id}}"
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "{{steps.rollback-app.outputs.parameters.status}}"
- name: output
value: "{{steps.rollback-app.outputs.parameters.rollback_output}}"
- - name: update-endpoint-url
templateRef:
name: update-tks-asa-endpoint
Expand All @@ -101,6 +85,22 @@ spec:
value: "N/A"
- name: helm_revision
value: "{{steps.rollback-app.outputs.parameters.revision}}"
- - name: notify-rollback-success
templateRef:
name: update-tks-asa-status
template: updateTksAsaStatus
arguments:
parameters:
- name: organization_id
value: "{{workflow.parameters.organization_id}}"
- name: asa_id
value: "{{workflow.parameters.asa_id}}"
- name: asa_task_id
value: "{{workflow.parameters.asa_task_id}}"
- name: status
value: "{{steps.rollback-app.outputs.parameters.status}}"
- name: output
value: "{{steps.rollback-app.outputs.parameters.rollback_output}}"

#######################
# Template Definition #
Expand Down
Loading