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

Let's add the new cost-tracking tags to workflows #2703

Merged
merged 6 commits into from
Jan 21, 2025
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
3 changes: 3 additions & 0 deletions kube/services/argo-events/workflows/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ data:
karpenter.sh/discovery: ENVIRONMENT
purpose: workflow
workflowname: WORKFLOW_NAME
"vadc:cost-type": user-based-variable
"vadc:usage-type": user-infrastructure
"vadc:environment-type": "ENVIRONMENT_TYPE_CODE"
userData: |
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="BOUNDARY"
Expand Down
11 changes: 9 additions & 2 deletions kube/services/argo-events/workflows/sensor-created.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ spec:
- "-c"
- |
#!/bin/bash
if [ "$ENVIRONMENT" = "vhdcprod" ]; then
ENVIRONMENT_TYPE_CODE="production"
elif [ "$ENVIRONMENT" = "va-testing" ]; then
ENVIRONMENT_TYPE_CODE="testing"
else
ENVIRONMENT_TYPE_CODE="$ENVIRONMENT"
fi

if [ -z "$NODEPOOL_TEMPLATE" ]; then
NODEPOOL_TEMPLATE="/manifests/nodepool.yaml"
Expand All @@ -74,11 +81,11 @@ spec:
fi

if ! kubectl get ec2nodeclass workflow-$WORKFLOW_NAME >/dev/null 2>&1; then
sed -e "s/WORKFLOW_NAME/$WORKFLOW_NAME/" -e "s/GEN3_USERNAME/$GEN3_USERNAME/" -e "s/GEN3_TEAMNAME/$GEN3_TEAMNAME/" -e "s/ENVIRONMENT/$ENVIRONMENT/" "$NODECLASS_TEMPLATE" | kubectl apply -f -
sed -e "s/ENVIRONMENT_TYPE_CODE/$ENVIRONMENT_TYPE_CODE/" -e "s/WORKFLOW_NAME/$WORKFLOW_NAME/" -e "s/GEN3_USERNAME/$GEN3_USERNAME/" -e "s/GEN3_TEAMNAME/$GEN3_TEAMNAME/" -e "s/ENVIRONMENT/$ENVIRONMENT/" "$NODECLASS_TEMPLATE" | kubectl apply -f -
fi

if ! kubectl get nodepool workflow-$WORKFLOW_NAME >/dev/null 2>&1; then
sed -e "s/WORKFLOW_NAME/$WORKFLOW_NAME/" -e "s/GEN3_USERNAME/$GEN3_USERNAME/" -e "s/GEN3_TEAMNAME/$GEN3_TEAMNAME/" -e "s/ENVIRONMENT/$ENVIRONMENT/" "$NODEPOOL_TEMPLATE" | kubectl apply -f -
sed -e "s/ENVIRONMENT_TYPE_CODE/$ENVIRONMENT_TYPE_CODE/" -e "s/WORKFLOW_NAME/$WORKFLOW_NAME/" -e "s/GEN3_USERNAME/$GEN3_USERNAME/" -e "s/GEN3_TEAMNAME/$GEN3_TEAMNAME/" -e "s/ENVIRONMENT/$ENVIRONMENT/" "$NODEPOOL_TEMPLATE" | kubectl apply -f -
fi
env:
- name: WORKFLOW_NAME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ spec:
- "-c"
- |
#!/bin/bash
ENVIRONMENT=$(kubectl -n default get configmap global -o jsonpath="{.data.environment}")

if [ "$ENVIRONMENT" = "vhdcprod" ]; then
ENVIRONMENT_TYPE_CODE="production"
elif [ "$ENVIRONMENT" = "va-testing" ]; then
ENVIRONMENT_TYPE_CODE="testing"
else
ENVIRONMENT_TYPE_CODE="$ENVIRONMENT"
fi

if [ -z "$NODEPOOL_TEMPLATE" ]; then
NODEPOOL_TEMPLATE="/manifests/provisioner.yaml"
fi
Expand All @@ -41,8 +51,6 @@ spec:
NODECLASS_TEMPLATE="/manifests/nodeclass.yaml"
fi

ENVIRONMENT=$(kubectl -n default get configmap global -o jsonpath="{.data.environment}")

WORKFLOWS=$(kubectl get workflows -n argo -o=jsonpath='{range .items[*]}{.metadata.name}{" "}{.metadata.labels.gen3username}{" "}{.metadata.labels.gen3teamproject}{"\n"}')

WORKFLOW_ARRAY=()
Expand All @@ -62,12 +70,12 @@ spec:
if [ ! -z "$workflow_name" ]; then
if ! kubectl get ec2nodeclass workflow-$workflow_name >/dev/null 2>&1; then
echo "No awsnodetemplate found for ${workflow_name}, creating one"
sed -e "s/WORKFLOW_NAME/$workflow_name/" -e "s/GEN3_TEAMNAME/$workflow_team/" -e "s/GEN3_USERNAME/$workflow_user/" -e "s/ENVIRONMENT/$ENVIRONMENT/" "$NODECLASS_TEMPLATE" | kubectl apply -f -
sed -e "s/ENVIRONMENT_TYPE_CODE/$ENVIRONMENT_TYPE_CODE/" -e "s/WORKFLOW_NAME/$workflow_name/" -e "s/GEN3_TEAMNAME/$workflow_team/" -e "s/GEN3_USERNAME/$workflow_user/" -e "s/ENVIRONMENT/$ENVIRONMENT/" "$NODECLASS_TEMPLATE" | kubectl apply -f -
fi

if ! kubectl get nodepool workflow-$workflow_name >/dev/null 2>&1; then
echo "No provisioner found for ${workflow_name}, creating one"
sed -e "s/WORKFLOW_NAME/$workflow_name/" -e "s/GEN3_TEAMNAME/$workflow_team/" -e "s/GEN3_USERNAME/$workflow_user/" -e "s/ENVIRONMENT/$ENVIRONMENT/" "$NODEPOOL_TEMPLATE" | kubectl apply -f -
sed -e "s/ENVIRONMENT_TYPE_CODE/$ENVIRONMENT_TYPE_CODE/" -e "s/WORKFLOW_NAME/$workflow_name/" -e "s/GEN3_TEAMNAME/$workflow_team/" -e "s/GEN3_USERNAME/$workflow_user/" -e "s/ENVIRONMENT/$ENVIRONMENT/" "$NODEPOOL_TEMPLATE" | kubectl apply -f -

fi
fi
Expand Down
Loading