Skip to content

Instantly share code, notes, and snippets.

@danhawkins
Last active April 27, 2022 15:56
Show Gist options
  • Save danhawkins/830494be232be440b3f7f4472763e01b to your computer and use it in GitHub Desktop.
Save danhawkins/830494be232be440b3f7f4472763e01b to your computer and use it in GitHub Desktop.
Start Livebook Pod
#!/bin/sh
# Name of our app/service and executable name from the release
SVC_NAME="test-svc"
EXEC_NAME="test_svc"
# Name for the pod
LIVEBOOK_NAME="danny-livebook"
# Fetch the require env from the service pod
POD_NAME=`kubectl get pod -l app=${SVC_NAME} -o=name`
RELEASE_NODE=`kubectl exec ${POD_NAME} -- ./bin/${EXEC_NAME} eval 'IO.puts(System.get_env("RELEASE_NODE"))'`
RELEASE_COOKIE=`kubectl exec ${POD_NAME} -- ./bin/${EXEC_NAME} eval 'IO.puts(System.get_env("RELEASE_COOKIE"))'`
echo "Found $RELEASE_NODE for pod ${POD_NAME}"
echo "Starting connected livebook"
kubectl run $LIVEBOOK_NAME \
--image=livebook/livebook \
--env LIVEBOOK_DEFAULT_RUNTIME="attached:${RELEASE_NODE}:${RELEASE_COOKIE}" \
--env RELEASE_DISTRIBUTION="name" \
--env RELEASE_NODE="livebook@127.0.0.1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment