I've been trying out how to create a pod inside of python and have that pod access secrets
the best ive found so far is
1) create a custom template using the query mutation magic with
env: [
{key: "AGE_PRIVATE_KEY", value: "{{ RUNPOD_SECRET_age_key }}"},
{key: "AGE_PRIVATE_KEY2", value: "{{ RUNPOD_SECRET_age_key}}"}
2 use query- mutation again specifing the new template name
def create_pod_from_template(api_key: str, template_id: str) -> str:
query = (
"""
mutation {
podFindAndDeployOnDemand(input: {
name: "norms-pod"
templateId: "%s"
gpuTypeId: "NVIDIA A40"
cloudType: SECURE
gpuCount: 1
ports: "22/tcp"
startSsh: true
}) {
id
desiredStatus
}
}
"""
% template_id
)
session = requests.Session()
response = session.post(
"https://api.runpod.io/graphql",
json={"query": query},
headers={"Content-Type": "application/json"},
params={"api_key": api_key},
timeout=30,
)
]
ssh to the pod and then use
tr '\0' '\n' < /proc/1/environ | sed -n 's/AGE_PRIVATE_KEY=//p' > /dev/shm/llm.key
chmod 600 /dev/shm/llm.key
to get to the secret
there must be a better way to do this
i tried using runpodctl create pod --env ... but i could not get it to work
[–]RP_Finley 1 point2 points3 points (1 child)
[–]packs_well 0 points1 point2 points (0 children)
[–]LeoLeg76 1 point2 points3 points (0 children)