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

Add bearer auth support to update-deployment-patch #11

Merged
merged 2 commits into from
Feb 4, 2025
Merged
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
30 changes: 30 additions & 0 deletions pac/tasks/update-deployment-patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ spec:
value: $(params.image)
script: |-
#!/bin/bash
# check if the updated deployment is a bearer authentication case.
# in other words check if the three configMap variables have been set in ${DEPLOYMENT_NAME}-app-config during the helm chart installation
INCLUDE_MODEL_ENDPOINT_SECRET=$(kubectl get configmap ${DEPLOYMENT_NAME}-app-config -n ${DEPLOYMENT_NAMESPACE} -o jsonpath="{.data.INCLUDE_MODEL_ENDPOINT_SECRET}")
Copy link
Contributor

Choose a reason for hiding this comment

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

what is adding these the key/value pairs to the config map? i.e. .data.INCLUDE_MODEL_ENDPOINT_SECRET

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

cool ... add a comment here explaining that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added an extra comment in 88d5e25

MODEL_ENDPOINT_SECRET_NAME=$(kubectl get configmap ${DEPLOYMENT_NAME}-app-config -n ${DEPLOYMENT_NAMESPACE} -o jsonpath="{.data.MODEL_ENDPOINT_SECRET_NAME}")
MODEL_ENDPOINT_SECRET_KEY=$(kubectl get configmap ${DEPLOYMENT_NAME}-app-config -n ${DEPLOYMENT_NAMESPACE} -o jsonpath="{.data.MODEL_ENDPOINT_SECRET_KEY}")

# add the bearer secret in case is needed
if [[ ${INCLUDE_MODEL_ENDPOINT_SECRET} == "true" && -n ${MODEL_ENDPOINT_SECRET_NAME} && -n ${MODEL_ENDPOINT_SECRET_KEY} ]]; then
kubectl patch deployment ${DEPLOYMENT_NAME} --namespace ${DEPLOYMENT_NAMESPACE} --type 'merge' --patch "$( cat <<EOF
spec:
template:
Expand All @@ -40,6 +48,28 @@ spec:
envFrom:
- configMapRef:
name: $DEPLOYMENT_NAME-model-config
env:
- name: MODEL_ENDPOINT_BEARER
valueFrom:
secretKeyRef:
name: $MODEL_ENDPOINT_SECRET_NAME
key: $MODEL_ENDPOINT_SECRET_KEY
EOF
)"
else
# default case
kubectl patch deployment ${DEPLOYMENT_NAME} --namespace ${DEPLOYMENT_NAMESPACE} --type 'merge' --patch "$( cat <<EOF
spec:
template:
spec:
containers:
- name: $CONTAINER_NAME
image: $NEW_IMAGE
envFrom:
- configMapRef:
name: $DEPLOYMENT_NAME-model-config
EOF
)"
fi

echo "Successfully updated ${CONTAINER_NAME} container's image to ${NEW_IMAGE}"
Loading