@@ -36,6 +36,14 @@ if ! docker ps -q --filter "name=^${CONTAINER_NAME}$" --filter "health=healthy"
3636 exit 1
3737fi
3838
39+ # Run a command inside the cluster container with KUBECONFIG pre-configured.
40+ cluster_exec () {
41+ docker exec " ${CONTAINER_NAME} " sh -c " KUBECONFIG=/etc/rancher/k3s/k3s.yaml $* "
42+ }
43+
44+ # Path inside the container where the chart is copied for helm upgrades.
45+ CONTAINER_CHART_DIR=/tmp/openshell-chart
46+
3947build_gateway=0
4048build_sandbox=0
4149needs_helm_upgrade=0
376384if [[ " ${needs_helm_upgrade} " == " 1" ]]; then
377385 helm_start=$( date +%s)
378386 echo " Upgrading helm release..."
379- helm_wait_args=()
387+ helm_wait_args=" "
380388 if [[ " ${DEPLOY_FAST_HELM_WAIT} " == " 1" ]]; then
381- helm_wait_args+=( --wait)
389+ helm_wait_args= " --wait"
382390 fi
383391
392+ # Copy the local chart source into the container so helm can read it.
393+ docker exec " ${CONTAINER_NAME} " rm -rf " ${CONTAINER_CHART_DIR} "
394+ docker cp deploy/helm/openshell " ${CONTAINER_NAME} :${CONTAINER_CHART_DIR} "
395+
384396 # grpcEndpoint must be explicitly set to https:// because the chart always
385397 # terminates mTLS (there is no server.tls.enabled toggle). Without this,
386398 # a prior Helm override or chart default change could silently regress
387399 # sandbox callbacks to plaintext.
388400 # Retrieve the existing handshake secret from the running release, or generate
389401 # a new one if this is the first deploy with the mandatory secret.
390- EXISTING_SECRET=$( helm get values openshell -n openshell -o json 2> /dev/null \
391- | grep -o ' "sshHandshakeSecret": "[^"]*"' \
392- | cut -d' "' -f4) || true
402+ EXISTING_SECRET=$( cluster_exec " helm get values openshell -n openshell -o json 2>/dev/null \
403+ | grep -o '\ " sshHandshakeSecret\" : \ " [^\ " ]*\ " ' \
404+ | cut -d'\ " ' -f4" ) || true
393405 SSH_HANDSHAKE_SECRET=" ${EXISTING_SECRET:- $(openssl rand -hex 32)} "
394406
395- helm upgrade openshell deploy/helm/openshell \
407+ cluster_exec " helm upgrade openshell ${CONTAINER_CHART_DIR} \
396408 --namespace openshell \
397409 --set image.repository=${IMAGE_REPO_BASE} /gateway \
398410 --set image.tag=${IMAGE_TAG} \
@@ -403,20 +415,20 @@ if [[ "${needs_helm_upgrade}" == "1" ]]; then
403415 --set server.tls.clientCaSecretName=openshell-server-client-ca \
404416 --set server.tls.clientTlsSecretName=openshell-client-tls \
405417 --set server.sshHandshakeSecret=${SSH_HANDSHAKE_SECRET} \
406- " ${helm_wait_args[@] } "
418+ ${helm_wait_args} "
407419 helm_end=$( date +%s)
408420 log_duration " Helm upgrade" " ${helm_start} " " ${helm_end} "
409421fi
410422
411423if [[ " ${# pushed_images[@]} " -gt 0 ]]; then
412424 rollout_start=$( date +%s)
413425 echo " Restarting deployment to pick up updated images..."
414- if kubectl get statefulset/openshell -n openshell > /dev/null 2>&1 ; then
415- kubectl rollout restart statefulset/openshell -n openshell
416- kubectl rollout status statefulset/openshell -n openshell
417- elif kubectl get deployment/openshell -n openshell > /dev/null 2>&1 ; then
418- kubectl rollout restart deployment/openshell -n openshell
419- kubectl rollout status deployment/openshell -n openshell
426+ if cluster_exec " kubectl get statefulset/openshell -n openshell" > /dev/null 2>&1 ; then
427+ cluster_exec " kubectl rollout restart statefulset/openshell -n openshell"
428+ cluster_exec " kubectl rollout status statefulset/openshell -n openshell"
429+ elif cluster_exec " kubectl get deployment/openshell -n openshell" > /dev/null 2>&1 ; then
430+ cluster_exec " kubectl rollout restart deployment/openshell -n openshell"
431+ cluster_exec " kubectl rollout status deployment/openshell -n openshell"
420432 else
421433 echo " Warning: no openshell workload found to roll out in namespace 'openshell'."
422434 fi
0 commit comments