infrapuzzle/k8s/n8n/_tmp_generate-token.yaml

65 lines
2.9 KiB
YAML

# --- Garmin Token Generator Pod ---
# This pod is a temporary, interactive tool to generate Garmin Connect session tokens.
#
# --- WORKFLOW ---
# 1. Ensure the `garmin-credentials` secret is applied in the `n8n` namespace.
# 2. Apply this manifest: `kubectl apply -f token-generator-pod.yaml`
# 3. View the logs to see instructions: `kubectl logs -n n8n -f garmin-token-generator`
# 4. Exec into the pod and run the login command provided in the logs.
# 5. Retrieve the generated token data from within the pod.
# 6. Create the `garmin-tokens` Kubernetes secret.
# 7. Delete this pod: `kubectl delete pod -n n8n garmin-token-generator`
#
apiVersion: v1
kind: Pod
metadata:
name: garmin-token-generator
namespace: n8n
spec:
volumes:
# This is temporary storage that will be deleted when the pod is deleted.
# We use it to hold the generated token files.
- name: garmin-connect-storage
emptyDir: {}
containers:
- name: helper
image: python:3.12-slim
# Mount the garmin-credentials secret as environment variables
envFrom:
- secretRef:
name: garmin-credentials
# The main command installs dependencies, prints instructions, and then sleeps.
# This keeps the pod running so you can exec into it.
command: ["/bin/sh", "-c"]
args:
- |
set -e
echo "--- Garmin Token Generator Pod ---"
echo "[Step 1/3] Installing dependencies (git and uv)..."
# Set debconf to non-interactive mode to prevent installation prompts and fix warnings.
export DEBIAN_FRONTEND=noninteractive
# Redirect noisy output to /dev/null
apt-get update > /dev/null && apt-get install -y git --no-install-recommends > /dev/null && rm -rf /var/lib/apt/lists/*
pip install uv > /dev/null
echo "[Step 2/3] Setup complete. Pod is ready for interactive login."
echo "------------------------------------------------------------------"
echo "ACTION REQUIRED:"
echo "1. Ensure the 'garmin-credentials' secret has been applied to this namespace."
echo "2. Open a new terminal."
echo "3. Connect to this pod by running:"
echo " kubectl exec -it -n n8n garmin-token-generator -- /bin/sh"
echo ""
echo "4. Inside the pod's shell, run the following simplified command:"
echo " uvx --from garminconnect gcexport --username \"$GARMIN_EMAIL\" --password \"$GARMIN_PASSWORD\""
echo ""
echo "5. Follow the prompts to enter your MFA code."
echo "6. Once successful, the tokens will be saved to /root/.garminconnect"
echo "------------------------------------------------------------------"
echo "[Step 3/3] Sleeping indefinitely. This pod will remain running until you delete it."
sleep infinity
volumeMounts:
# Mount the temporary storage at the path where the library saves tokens.
- name: garmin-connect-storage
mountPath: "/root/.garminconnect"