From 3bdfcac1cdb0e62a4f01eb566cdb83a58a4f7756 Mon Sep 17 00:00:00 2001 From: Aidan Hilt Date: Thu, 16 Jan 2025 10:52:52 -0500 Subject: [PATCH] Let's add the new cost-tracking tags to workflows --- kube/services/argo-events/workflows/configmap.yaml | 3 +++ .../argo-events/workflows/sensor-created.yaml | 11 +++++++++-- .../karpenter-reconciler-cronjob.yaml | 12 ++++++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/kube/services/argo-events/workflows/configmap.yaml b/kube/services/argo-events/workflows/configmap.yaml index c084533fe..f0b1b4742 100644 --- a/kube/services/argo-events/workflows/configmap.yaml +++ b/kube/services/argo-events/workflows/configmap.yaml @@ -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" diff --git a/kube/services/argo-events/workflows/sensor-created.yaml b/kube/services/argo-events/workflows/sensor-created.yaml index 05da3bc38..d98dc6a10 100644 --- a/kube/services/argo-events/workflows/sensor-created.yaml +++ b/kube/services/argo-events/workflows/sensor-created.yaml @@ -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" @@ -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 diff --git a/kube/services/karpenter-reconciler/karpenter-reconciler-cronjob.yaml b/kube/services/karpenter-reconciler/karpenter-reconciler-cronjob.yaml index 3c6d58768..89968f24d 100644 --- a/kube/services/karpenter-reconciler/karpenter-reconciler-cronjob.yaml +++ b/kube/services/karpenter-reconciler/karpenter-reconciler-cronjob.yaml @@ -33,6 +33,14 @@ 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/provisioner.yaml" fi @@ -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