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

Cache - Stabilized the deployer script #3634

Merged
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
36 changes: 27 additions & 9 deletions backend/src/cache/deployer/deploy-cache-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,20 @@ set -ex
echo "Start deploying cache service to existing cluster:"

NAMESPACE=${NAMESPACE_TO_WATCH:-kubeflow}
mutatingWebhookConfigName="cache-webhook"
MUTATING_WEBHOOK_CONFIGURATION_NAME="cache-webhook"

# This should fail if there are connectivity problems
# Gotcha: Listing all objects requires list permission,
# but when listing a single oblect kubecttl will fail if it's not found
# unless --ignore-not-found is specified.
kubectl get mutatingwebhookconfigurations "${MUTATING_WEBHOOK_CONFIGURATION_NAME}" --namespace "${NAMESPACE}" --ignore-not-found >webhooks.txt

if grep "${MUTATING_WEBHOOK_CONFIGURATION_NAME}" --word-regexp <webhooks.txt; then
echo "Webhook is already installed. Sleeping forever."
sleep infinity
fi


export CA_FILE="ca_cert"
rm -f ${CA_FILE}
touch ${CA_FILE}
Expand All @@ -36,16 +49,21 @@ echo "Signed certificate generated for cache server"
NAMESPACE="$NAMESPACE" ./webhook-patch-ca-bundle.sh --cert_input_path "${CA_FILE}" <./cache-configmap.yaml.template >./cache-configmap-ca-bundle.yaml
echo "CA_BUNDLE patched successfully"

checkWebhookConfig() {
webhookconfig=$(kubectl get mutatingwebhookconfigurations -n ${NAMESPACE} ${mutatingWebhookConfigName})
}

# Create MutatingWebhookConfiguration
cat ./cache-configmap-ca-bundle.yaml
kubectl apply -f ./cache-configmap-ca-bundle.yaml --namespace "${NAMESPACE}"

# TODO: Check whether we really need to check for the existence of the webhook
# Usually the Kubernetes objects appear immediately.
while true; do
if ! checkWebhookConfig; then
kubectl apply -f ./cache-configmap-ca-bundle.yaml --namespace "${NAMESPACE}"
fi
sleep 10
# Should fail if there are connectivity problems
kubectl get mutatingwebhookconfigurations "${MUTATING_WEBHOOK_CONFIGURATION_NAME}" --namespace "${NAMESPACE}" --ignore-not-found >webhooks.txt

if grep "${MUTATING_WEBHOOK_CONFIGURATION_NAME}" --word-regexp <webhooks.txt; then
echo "Webhook has been installed. Sleeping forever."
sleep infinity
else
echo "Webhook is not visible yet. Waiting a bit."
sleep 10s
fi
done